Skip to content

Commit

Permalink
workaround GitHub Actions quirks (#5678)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Sep 26, 2022
1 parent f9b811c commit 8ca4007
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@ exports.run_code = semver.satisfies(process.version, "0.8") ? function(code, top
} while (prev !== stdout);
return stdout;
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
if ([
var stdout = ([
/\b(async[ \t]+function|Promise|setImmediate|setInterval|setTimeout)\b/,
/\basync([ \t]+|[ \t]*#)[^\s()[\]{}#:;,.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
/\basync[ \t]*\*[ \t]*[^\s()[\]{}#:;,.&|!~=*%/+-]+\s*\(/,
/\basync([ \t]*\*)?[ \t]*\[[\s\S]*?\]\s*\(/,
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
].some(function(pattern) {
return pattern.test(code);
})) {
return run_code_exec(code, toplevel, timeout);
} else {
return run_code_vm(code, toplevel, timeout);
}
}) ? run_code_exec : run_code_vm)(code, toplevel, timeout);
return stdout.length > 1000 ? stdout.slice(0, 1000) + "…《" + stdout.length + "》" : stdout;
};
exports.same_stdout = semver.satisfies(process.version, "0.12") ? function(expected, actual) {
if (typeof expected != typeof actual) return false;
Expand Down Expand Up @@ -286,6 +283,7 @@ function run_code_exec(code, toplevel, timeout) {
var result = spawnSync(process.argv[0], [ '--max-old-space-size=2048' ], {
encoding: "utf8",
input: code,
maxBuffer: 1073741824,
stdio: "pipe",
timeout: timeout || 5000,
});
Expand Down

0 comments on commit 8ca4007

Please sign in to comment.