aboutsummaryrefslogtreecommitdiff
path: root/test/sandbox.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-21 06:33:31 +0000
committerGitHub <noreply@github.com>2021-01-21 14:33:31 +0800
commite675262d51103122720aded924f5571e12086fc9 (patch)
tree517855b5eb23c0850c97e0fafa158747befb11ee /test/sandbox.js
parentc1e771a89a65751016bbafd56d710accf6d7bf21 (diff)
downloadtracifyjs-e675262d51103122720aded924f5571e12086fc9.tar.gz
tracifyjs-e675262d51103122720aded924f5571e12086fc9.zip
suppress false positives in `ufuzz` (#4577)
Diffstat (limited to 'test/sandbox.js')
-rw-r--r--test/sandbox.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/test/sandbox.js b/test/sandbox.js
index 540b2339..bd4c7a8d 100644
--- a/test/sandbox.js
+++ b/test/sandbox.js
@@ -235,17 +235,26 @@ function run_code_exec(code, toplevel, timeout) {
} catch (ex) {
var msg = ex.message.replace(/\r\n/g, "\n");
if (/ETIMEDOUT/.test(msg)) return new Error("Script execution timed out.");
- var value = msg.slice(msg.indexOf("\n") + 1, msg.indexOf("\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n"));
- try {
- value = vm.runInNewContext("(" + value.replace(/<([1-9][0-9]*) empty items?>/g, function(match, count) {
+ var end = msg.indexOf("\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n");
+ var details;
+ if (end >= 0) {
+ var start = msg.indexOf("\n") + 1;
+ details = msg.slice(start, end).replace(/<([1-9][0-9]*) empty items?>/g, function(match, count) {
return new Array(+count).join();
- }) + ")");
- } catch (e) {}
+ });
+ try {
+ details = vm.runInNewContext("(" + details + ")");
+ } catch (e) {}
+ }
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
- if (!match) return value;
+ if (!match) return details;
ex = new global[match[1]](match[2]);
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
- for (var name in value) ex[name] = value[name];
+ if (typeof details == "object") {
+ for (var name in details) ex[name] = details[name];
+ } else if (end >= 0) {
+ ex.details = details;
+ }
return ex;
}
}