Skip to content

Commit 4099319

Browse files
authored
Fix wasm tests on CI (tree-sitter#616)
* wasm: Improve error message on missing language symbol * Fix source file existence checks in build-wasm command
1 parent 2934e21 commit 4099319

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cli/src/wasm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu
8989
let scanner_cc_path = src.join("scanner.cc");
9090
let scanner_cpp_path = src.join("scanner.cpp");
9191

92-
if scanner_cc_path.exists() {
92+
if language_dir.join(&scanner_cc_path).exists() {
9393
command.arg("-xc++").arg(&scanner_cc_path);
94-
} else if scanner_cpp_path.exists() {
94+
} else if language_dir.join(&scanner_cpp_path).exists() {
9595
command.arg("-xc++").arg(&scanner_cpp_path);
96-
} else if scanner_c_path.exists() {
96+
} else if language_dir.join(&scanner_c_path).exists() {
9797
command.arg(&scanner_c_path);
9898
}
9999

lib/binding_web/binding.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,14 @@ class Language {
872872
return bytes
873873
.then(bytes => loadWebAssemblyModule(bytes, {loadAsync: true}))
874874
.then(mod => {
875-
const functionName = Object.keys(mod).find(key =>
875+
const symbolNames = Object.keys(mod)
876+
const functionName = symbolNames.find(key =>
876877
LANGUAGE_FUNCTION_REGEX.test(key) &&
877878
!key.includes("external_scanner_")
878879
);
880+
if (!functionName) {
881+
console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames, null, 2)}`)
882+
}
879883
const languageAddress = mod[functionName]();
880884
return new Language(INTERNAL, languageAddress);
881885
});

0 commit comments

Comments
 (0)