Skip to content

Commit

Permalink
Download all inputs when running plz test & plz cover (#3069)
Browse files Browse the repository at this point in the history
This is a follow-up for #3066
  • Loading branch information
janhancic authored Feb 8, 2024
1 parent 87a776b commit c339ee1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/core/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,6 @@ func (state *BuildState) GetPreloadedSubincludes() []BuildLabel {

// DownloadInputsIfNeeded downloads all the inputs (or runtime files) for a target if we are building remotely.
func (state *BuildState) DownloadInputsIfNeeded(target *BuildTarget, runtime bool) error {
// TODO(jan): Remove this function once `DownloadAllInputs` has been fully implemented across both build & test.
if state.RemoteClient != nil {
state.LogBuildResult(target, TargetBuilding, "Downloading inputs...")
for input := range state.IterInputs(target, runtime) {
Expand Down
30 changes: 20 additions & 10 deletions src/test/test_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,7 @@ func test(state *core.BuildState, label core.BuildLabel, target *core.BuildTarge

// If the user passed --shell then just prepare the directory.
if state.PrepareOnly {
if err := state.DownloadInputsIfNeeded(target, true); err != nil {
state.LogBuildError(label, core.TargetTestFailed, err, "Failed to download test inputs")
return
}
if err := core.PrepareRuntimeDir(state, target, target.TestDir(run)); err != nil {
state.LogBuildError(label, core.TargetTestFailed, err, "Failed to prepare test directory")
return
}
target.SetState(core.Stopped)
state.LogBuildResult(target, core.TargetTestStopped, "Test stopped")
prepareOnly(state, label, target, run)
return
}

Expand Down Expand Up @@ -268,6 +259,25 @@ func doFlakeRun(state *core.BuildState, target *core.BuildTarget, run int, runRe
return results, coverage
}

func prepareOnly(state *core.BuildState, label core.BuildLabel, target *core.BuildTarget, runNumber int) {
if state.RemoteClient != nil {
// Targets were built remotely so we can simply download the inputs and place them in the
// tmp/ folder and exit.
if err := state.DownloadAllInputs(target, target.TestDir(runNumber), true); err != nil {
state.LogBuildError(label, core.TargetTestFailed, err, "Failed to download test inputs")
return
}
} else {
if err := core.PrepareRuntimeDir(state, target, target.TestDir(runNumber)); err != nil {
state.LogBuildError(label, core.TargetTestFailed, err, "Failed to prepare test directory")
return
}
}

target.SetState(core.Stopped)
state.LogBuildResult(target, core.TargetTestStopped, "Test stopped")
}

func getFlakeStatus(flake int, flakes int) string {
if flakes == 1 {
return "Testing..."
Expand Down

0 comments on commit c339ee1

Please sign in to comment.