summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-03-08 07:09:41 +0330
committerLinus Groh <mail@linusgroh.de>2022-03-16 15:44:52 +0000
commit8b50009e9b42a0de810617bff3db994bbfa99264 (patch)
tree1c39af1ced9f274fc33477a3cef7b7c9df5bfc2a /Userland/Libraries/LibJS
parent3063aedb0c5ca7afda8e13ff8fcc063c7bd98678 (diff)
downloadserenity-8b50009e9b42a0de810617bff3db994bbfa99264.zip
LibTest: Provide detailed per-file JSON output with --per-file
This makes test-js style runners dump out output in the same format as libjs-test262's per-file output.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Tests/test-common.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/test-common.js b/Userland/Libraries/LibJS/Tests/test-common.js
index a43477902e..bbdc80fc9b 100644
--- a/Userland/Libraries/LibJS/Tests/test-common.js
+++ b/Userland/Libraries/LibJS/Tests/test-common.js
@@ -536,6 +536,7 @@ class ExpectationError extends Error {
__TestResults__[suiteMessage][defaultSuiteMessage] = {
result: "fail",
details: String(e),
+ duration: 0,
};
}
suiteMessage = defaultSuiteMessage;
@@ -549,19 +550,25 @@ class ExpectationError extends Error {
suite[message] = {
result: "fail",
details: "Another test with the same message did already run",
+ duration: 0,
};
return;
}
+ const now = () => Temporal.Now.instant().epochNanoseconds;
+ const start = now();
+ const time_us = () => Number(BigInt.asIntN(53, (now() - start) / 1000n));
try {
callback();
suite[message] = {
result: "pass",
+ duration: time_us(),
};
} catch (e) {
suite[message] = {
result: "fail",
details: String(e),
+ duration: time_us(),
};
}
};
@@ -577,12 +584,14 @@ class ExpectationError extends Error {
suite[message] = {
result: "fail",
details: "Another test with the same message did already run",
+ duration: 0,
};
return;
}
suite[message] = {
result: "skip",
+ duration: 0,
};
};
})();