Skip to content

Commit

Permalink
Call npx directly from Rascal
Browse files Browse the repository at this point in the history
  • Loading branch information
sungshik committed Jul 10, 2024
1 parent e660dde commit c8b408d
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool doTransformTest(list[ConversionUnit] units, RepositoryStats expect, str nam
assert (true | it && s in repo | r <- pats, include(/#<s:.*>$/) := r) : "Patterns list contains pattern(s) outside repository";

// Test behavioral properties of the TextMate grammar

loc lProject = |project://rascal-textmate-core|;
loc lGrammar = lProject + "/target/generated-test-grammars/<name>.tmLanguage.json";
toJSON(tm, l = resolveLocation(lGrammar));
Expand All @@ -83,10 +83,16 @@ bool doTransformTest(list[ConversionUnit] units, RepositoryStats expect, str nam
} elseif (!exists(lTester)) {
println("[LOG] No tokenizer available (`<resolveLocation(lTester).path>` does not exist)");
} else {
bool windows = startsWith(getSystemProperty("os.name"), "Windows");
loc lExec = lProject + "/src/test/sh/lang/textmate/conversion-tests.<windows ? "bat" : "sh">";

if (<output, exitCode> := execWithCode(lExec, args = [name]) && exitCode != 0) {
bool windows = startsWith(getSystemProperty("os.name"), "Windows");
loc lExec = |PATH:///npx<windows ? ".cmd" : "">|;
list[str] args = [
"vscode-tmgrammar-test",
"--grammar",
resolveLocation(lGrammar).path[(windows ? 1 : 0)..],
resolveLocation(lTest).path[(windows ? 1 : 0)..]
];

if (<output, exitCode> := execWithCode(lExec, args = args) && exitCode != 0) {
println(output);
assert false : "Actual tokenization does not match expected tokenization (see output above for details)";
}
Expand Down

0 comments on commit c8b408d

Please sign in to comment.