Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash authored and lijunchen committed Sep 11, 2024
1 parent 696cbfb commit 0df9e07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
1 change: 1 addition & 0 deletions crates/moon/src/cli/generate_test_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ fn generate_driver(data: &str, pkgname: &str, target_backend: Option<TargetBacke
"/../moonbuild/template/with_args_driver_template.mbt"
)).to_string()
}
.replace("\r\n", "\n")
.replace("fn moonbit_test_driver_internal_get_file_name(file_name : MoonbitTestDriverInternalExternString) -> String { panic() }\n", "")
.replace("type MoonbitTestDriverInternalExternString\n", "");

Expand Down
32 changes: 11 additions & 21 deletions crates/moonrun/src/template/js_glue.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,23 @@ const spectest = {
throw new WebAssembly.Exception(tag, [], { traceStack: true })
},
},
test: {
get_file_name: () => globalThis.testParams.fileName,
get_index: () => globalThis.testParams.index,
}
};

try {
let instance = new WebAssembly.Instance(module, spectest);
if (instance.exports.execute) {
if (test_mode) {
for (param of testParams) {
try {
globalThis.testParams = {
fileName: param[0],
index: parseInt(param[1])
};
instance.exports.execute(param[0], parseInt(param[1]));
} catch (e) {
console.log("----- BEGIN MOON TEST RESULT -----")
console.log(`{"package": "${packageName}", "filename": "${param[0]}", "index": "${param[1]}", "test_name": "${param[1]}", "message": "${e.stack.toString().replaceAll("\\", "\\\\").split('\n').join('\\n')}"}`);
console.log("----- END MOON TEST RESULT -----")
}
if (test_mode) {
for (param of testParams) {
try {
instance.exports.execute(param[0], parseInt(param[1]));
} catch (e) {
console.log("----- BEGIN MOON TEST RESULT -----")
console.log(`{"package": "${packageName}", "filename": "${param[0]}", "index": "${param[1]}", "test_name": "${param[1]}", "message": "${e.stack.toString().replaceAll("\\", "\\\\").split('\n').join('\\n')}"}`);
console.log("----- END MOON TEST RESULT -----")
}
}
else {
instance.exports._start();
}
}
else {
instance.exports._start();
}
}
catch (e) {
Expand Down

0 comments on commit 0df9e07

Please sign in to comment.