Skip to content

Commit ec71568

Browse files
committed
JBang: ignore malformed directives test due to regression in JBang (jbangdev/jbang#2236)
Additionally: make PIP comment parsing in JBangIntegration more robust.
1 parent 2b2fbe0 commit ec71568

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ repos:
33
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
6+
exclude: ^integration-tests/jbang/EmptyPIPComments\.j$
67
- id: end-of-file-fixer
78
- id: check-yaml
89
- id: check-added-large-files

integration-tests/jbang/EmptyPIPComments.j

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//DEPS org.graalvm.python:jbang:${env.GRAALPY_VERSION:26.0.0}
44
//PIP
55
// one blank after PIP
6-
//PIP
6+
//PIP
77
// three blanks after PIP
8-
//PIP
8+
//PIP
99

1010
public class EmptyPIPComments {
1111
public static void main(String[] args) {

integration-tests/test_jbang_integration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def check_empty_comments(self, work_dir, java_file, log):
317317
self.assertEqual(0, result, f"command: {command}\n stdout: {out}")
318318
self.assertNotIn("[graalpy jbang integration]", out)
319319

320+
@unittest.skip # https://github.com/jbangdev/jbang/issues/2236
320321
def test_malformed_tag_formats(self):
321322
jbang_templates_dir = os.path.join(os.path.dirname(__file__), "jbang")
322323
work_dir = self.tmpdir

org.graalvm.python.jbang/src/main/java/org/graalvm/python/jbang/JBangIntegration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,11 @@ public static Map<String, Object> postBuild(Path temporaryJar, Path pomFile,
180180
resourcesDirectory = Path.of(path);
181181
}
182182
} else if (comment.startsWith(PIP)) {
183-
pkgs.addAll(Arrays.stream(comment.substring(PIP.length()).trim().split(" "))
184-
.filter(s -> !s.trim().isEmpty()).collect(Collectors.toList()));
183+
String content = comment.substring(PIP.length()).trim();
184+
if (!content.isEmpty()) {
185+
pkgs.addAll(Arrays.stream(content.split("\\s+")).filter(x -> !x.isBlank())
186+
.collect(Collectors.toList()));
187+
}
185188
}
186189
}
187190
if (!pkgs.isEmpty()) {

0 commit comments

Comments
 (0)