mirror of https://github.com/sbt/sbt.git
[2.x] fix: Fix scripted test loading build definition twice on first test in batch (#8946)
This commit is contained in:
parent
132443b16e
commit
1852b4a454
|
|
@ -238,19 +238,21 @@ final class ScriptedTests(
|
|||
IO.copyDirectory(originalDir, tempTestDir)
|
||||
|
||||
val runTest = () => {
|
||||
// Reload and initialize (to reload contents of .sbtrc files)
|
||||
def sbtHandlerError = sys error "Missing sbt handler. Scripted is misconfigured."
|
||||
val sbtHandler = handlers.getOrElse('>', sbtHandlerError)
|
||||
val statement = Statement("reload;initialize", Nil, successExpected = true, line = -1)
|
||||
|
||||
// Run reload inside the hook to reuse error handling for pending tests
|
||||
val wrapHook = (file: File) => {
|
||||
preHook(file)
|
||||
try runner.processStatement(sbtHandler, statement, states)
|
||||
catch {
|
||||
case t: Throwable =>
|
||||
val newMsg = "Reload for scripted batch execution failed."
|
||||
throw new TestException(statement, newMsg, t)
|
||||
// Reload only when a previous sbt instance exists; a new instance already loads the project on boot
|
||||
if (states(sbtHandler) != None) {
|
||||
val statement =
|
||||
Statement("reload;initialize", Nil, successExpected = true, line = -1)
|
||||
try runner.processStatement(sbtHandler, statement, states)
|
||||
catch {
|
||||
case t: Throwable =>
|
||||
val newMsg = "Reload for scripted batch execution failed."
|
||||
throw new TestException(statement, newMsg, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue