call the callback only on fail or success

Don't call the callback on retry
This commit is contained in:
Amin Yahyaabadi
2020-08-30 08:52:37 -05:00
parent 4f0acf4a83
commit 8450f16bdb

View File

@@ -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(' ')}`,
})
}
})
}
@@ -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(' ')}`,
})
}
}