Skip to content

Commit

Permalink
call the callback only on fail or success
Browse files Browse the repository at this point in the history
Don't call the callback on retry
  • Loading branch information
aminya committed Sep 17, 2020
1 parent 4f0acf4 commit 8450f16
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions script/test
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ function spawnTest(executablePath, testArguments, options, callback, testName, f
callback(error)
})

// on close
// on close
cp.on('close', exitCode => {
if (finalize) { finalize() } // if finalizer provided
if (exitCode !== 0) {
retryOrFailTest(stderrOutput, executablePath, testArguments, options, callback, testName, finalize)
}
callback(null, {
exitCode,
step: testName,
testCommand: `You can run the test again using: \n\t ${executablePath} ${testArguments.join(' ')}`,
})
if (finalize) { finalize() } // if finalizer provided
if (exitCode !== 0) {
retryOrFailTest(stderrOutput, executablePath, testArguments, options, callback, testName, finalize)
} else {
callback(null, {
exitCode,
step: testName,
testCommand: `You can run the test again using: \n\t ${executablePath} ${testArguments.join(' ')}`,
})
}
})

}
Expand All @@ -131,6 +132,11 @@ function retryOrFailTest(stderrOutput, executablePath, testArguments, options, c
// fail the test
console.log(`##[error] Tests for ${testName} failed.`.red)
console.log(stderrOutput)
callback(null, {
exitCode,
step: testName,
testCommand: `You can run the test again using: \n\t ${executablePath} ${testArguments.join(' ')}`,
})
}
}

Expand Down

0 comments on commit 8450f16

Please sign in to comment.