1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:47:35 +00:00

LibJS/test-js: Clean up test-js code

This commit also exposes JSONObject's implementation of stringify to the
public, so that it can be used by test-js without having to go through
the interpreter's environment.
This commit is contained in:
Matthew Olsson 2020-07-04 11:37:50 -07:00 committed by Andreas Kling
parent 4c6fd49169
commit 26acc8ba88
5 changed files with 193 additions and 171 deletions

View file

@ -11,16 +11,6 @@ else
export UBSAN_OPTIONS=print_stacktrace=1
fi
# FIXME: Support "find -name" in Serenity to remove the file name checks below
test_files_tmp=$(find . -type f | cut -b 3- | sort)
for f in $test_files_tmp; do
if [ "$f" = "test-common.js" ] || [ "$f" = "run-tests.sh" ]; then
continue
fi
test_files=("${test_files[@]}" "$f");
done
$js_program "$test_root" "${test_files[@]}"
$js_program "$test_root"
exit $!

View file

@ -425,7 +425,7 @@ describe = (message, callback) => {
suiteMessage = defaultSuiteMessage;
}
test = (message, callback) => {
const getTestFunction = successMessage => (message, callback) => {
if (!__TestResults__[suiteMessage])
__TestResults__[suiteMessage] = {};
@ -437,13 +437,15 @@ test = (message, callback) => {
try {
callback();
suite[message] = {
passed: true,
result: successMessage,
};
} catch (e) {
suite[message] = {
passed: false,
result: "fail",
};
}
}
test = getTestFunction("pass");
})();