implement CLI --reduce-test and reduce tests in ufuzz (#3705)

This commit is contained in:
kzc
2020-02-05 21:50:59 -05:00
committed by GitHub
parent c93ca6ee53
commit b0040ba654
5 changed files with 420 additions and 3 deletions

View File

@@ -54,14 +54,15 @@ function createContext() {
}
}
exports.run_code = function(code, toplevel) {
exports.run_code = function(code, toplevel, timeout) {
timeout = timeout || 5000;
var stdout = "";
var original_write = process.stdout.write;
process.stdout.write = function(chunk) {
stdout += chunk;
};
try {
vm.runInContext(toplevel ? "(function(){" + code + "})()" : code, createContext(), { timeout: 5000 });
vm.runInContext(toplevel ? "(function(){" + code + "})()" : code, createContext(), { timeout: timeout });
return stdout;
} catch (ex) {
return ex;