aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-25 13:14:36 +0800
committerGitHub <noreply@github.com>2020-12-25 13:14:36 +0800
commitbb45f48ab74c25a108bb480ca5dd24f94599a35a (patch)
treed2de88990741d94a2b1cce799102f6e62f70033b
parentb2f27fd873665013e0e6c9a54e0162e88955d489 (diff)
downloadtracifyjs-bb45f48ab74c25a108bb480ca5dd24f94599a35a.tar.gz
tracifyjs-bb45f48ab74c25a108bb480ca5dd24f94599a35a.zip
workaround v8 heisenbug (#4453)
-rw-r--r--test/sandbox.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/sandbox.js b/test/sandbox.js
index f659427d..78a3435e 100644
--- a/test/sandbox.js
+++ b/test/sandbox.js
@@ -64,7 +64,7 @@ function createContext() {
}
}
-exports.run_code = function(code, toplevel, timeout) {
+function run_code(code, toplevel, timeout) {
timeout = timeout || 5000;
var stdout = "";
var original_write = process.stdout.write;
@@ -79,7 +79,17 @@ exports.run_code = function(code, toplevel, timeout) {
} finally {
process.stdout.write = original_write;
}
-};
+}
+
+exports.run_code = semver.satisfies(process.version, "0.8") ? function(code, toplevel, timeout) {
+ var stdout = run_code(code, toplevel, timeout);
+ if (typeof stdout != "string" || !/arguments/.test(code)) return stdout;
+ do {
+ var prev = stdout;
+ stdout = run_code(code, toplevel, timeout);
+ } while (prev !== stdout);
+ return stdout;
+} : run_code;
function strip_func_ids(text) {
return ("" + text).replace(/F[0-9]{6}N/g, "<F<>N>");