From 40993195b8da0d042161a7b7bb0f6831dcfb4da1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 13 May 2020 15:14:43 -0700 Subject: [PATCH] Fix wasm tests on CI (#616) * wasm: Improve error message on missing language symbol * Fix source file existence checks in build-wasm command --- cli/src/wasm.rs | 6 +++--- lib/binding_web/binding.js | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/src/wasm.rs b/cli/src/wasm.rs index 8c123e3b..47cea90a 100644 --- a/cli/src/wasm.rs +++ b/cli/src/wasm.rs @@ -89,11 +89,11 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu let scanner_cc_path = src.join("scanner.cc"); let scanner_cpp_path = src.join("scanner.cpp"); - if scanner_cc_path.exists() { + if language_dir.join(&scanner_cc_path).exists() { command.arg("-xc++").arg(&scanner_cc_path); - } else if scanner_cpp_path.exists() { + } else if language_dir.join(&scanner_cpp_path).exists() { command.arg("-xc++").arg(&scanner_cpp_path); - } else if scanner_c_path.exists() { + } else if language_dir.join(&scanner_c_path).exists() { command.arg(&scanner_c_path); } diff --git a/lib/binding_web/binding.js b/lib/binding_web/binding.js index feedb37f..eb6d4d8a 100644 --- a/lib/binding_web/binding.js +++ b/lib/binding_web/binding.js @@ -872,10 +872,14 @@ class Language { return bytes .then(bytes => loadWebAssemblyModule(bytes, {loadAsync: true})) .then(mod => { - const functionName = Object.keys(mod).find(key => + const symbolNames = Object.keys(mod) + const functionName = symbolNames.find(key => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_") ); + if (!functionName) { + console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames, null, 2)}`) + } const languageAddress = mod[functionName](); return new Language(INTERNAL, languageAddress); });