Skip to content

Commit

Permalink
test: handle redundant timeouts (#2650)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 committed Apr 23, 2021
1 parent edb1a57 commit 3b4eff8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions smoketests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const runTest = (package, cliArgs = [], logMessage, isSubPackage = false) => {
});

return new Promise((resolve) => {
setTimeout(() => {
const timeout = setTimeout(() => {
console.log(' timeout: killing process');
proc.kill();
}, 30000);
Expand Down Expand Up @@ -66,11 +66,13 @@ const runTest = (package, cliArgs = [], logMessage, isSubPackage = false) => {

proc.on('exit', () => {
swapPkgName(`.${package}`, isSubPackage);
clearTimeout(timeout);
resolve(hasPassed);
});

proc.on('error', () => {
swapPkgName(`.${package}`, isSubPackage);
clearTimeout(timeout);
resolve(false);
});
});
Expand All @@ -87,7 +89,7 @@ const runTestStdout = ({ packageName, cliArgs, logMessage, isSubPackage } = {})
proc.stdin.setDefaultEncoding('utf-8');

return new Promise((resolve) => {
setTimeout(() => {
const timeout = setTimeout(() => {
console.log(' timeout: killing process');
proc.kill();
}, 30000);
Expand All @@ -111,11 +113,13 @@ const runTestStdout = ({ packageName, cliArgs, logMessage, isSubPackage } = {})

proc.on('exit', () => {
swapPkgName(`.${packageName}`, isSubPackage);
clearTimeout(timeout);
resolve(hasPassed);
});

proc.on('error', () => {
swapPkgName(`.${packageName}`, isSubPackage);
clearTimeout(timeout);
resolve(false);
});
});
Expand All @@ -136,7 +140,8 @@ const runTestWithHelp = (package, cliArgs = [], logMessage, isSubPackage = false
});

return new Promise((resolve) => {
setTimeout(() => {
const timeout = setTimeout(() => {
console.log(' timeout: killing process');
proc.kill();
}, 30000);

Expand Down Expand Up @@ -166,11 +171,13 @@ const runTestWithHelp = (package, cliArgs = [], logMessage, isSubPackage = false

proc.on('exit', () => {
swapPkgName(`.${package}`, isSubPackage);
clearTimeout(timeout);
resolve(hasPassed);
});

proc.on('error', () => {
swapPkgName(`.${package}`, isSubPackage);
clearTimeout(timeout);
resolve(false);
});
});
Expand Down

0 comments on commit 3b4eff8

Please sign in to comment.