diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go index 77cdf4e2..6000bd0b 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go @@ -311,7 +311,10 @@ func TestATestRunsEndMovesEveryReaderAndIsCountedOnce(t *testing.T) { // passing end moves the other artifact's step to passed, marked a rerun by the caller and naming the new ask, and the // pipeline says pipeline-ended again; a step a person accepted does not move. func TestARerunOfATestRunMovesEveryReaderThatDidNotPass(t *testing.T) { - for _, accepted := range []bool{false, true} { + // takeUp: the rerun's run is ended by the restart's take-up, its bounds gone while the runner was away; a carried reader + // with rerun false, its step passed already, says no step-ended again (A-470l). + for _, c := range []struct{ accepted, takeUp bool }{{false, false}, {true, false}, {false, true}} { + accepted := c.accepted f := newRunFixture() reg := catalog.Registration{Module: "app", Branches: []string{"main"}, Policy: catalog.Policy{Steps: catalog.StepStatuses{Lint: "bypass", Unit: "required", Integration: "bypass", Composition: "bypass", Review: "bypass", Approval: "bypass"}}} @@ -350,6 +353,35 @@ func TestARerunOfATestRunMovesEveryReaderThatDidNotPass(t *testing.T) { t.Fatal(err) } again := a.Result.Ask + if c.takeUp { + run := unit.Shared[0].Run + r, rev, _ := f.runs.Get(run) + r.Readers[0].Rerun, r.Readers[0].By = false, "" // the program's step passed already + if _, err := f.runs.Update(run, r, rev); err != nil { + t.Fatal(err) + } + e := f.store[p.Pipeline] + e.p.Steps[stepIndex(e.p, "unit", "app:program")].Outcome = seat.StepResultOutcomePassed + f.store[p.Pipeline] = e + for k := range f.clock.bound { + delete(f.clock.bound, k) + } + said := len(f.said) + if n, err := f.h.TakeUp(); err != nil || n != 1 { + t.Fatalf("take-up = %d, %v", n, err) + } + for _, ev := range f.said[said:] { + if ev.Result.Artifact == "app:program" { + t.Errorf("a carried reader with rerun false said %s again: %+v", ev.Result.Outcome, ev) + } + } + q := f.pipeline(p) + if stepNamed(q, "app:program", "unit").Outcome != seat.StepResultOutcomePassed || stepNamed(q, "app:tools", "unit").Outcome != seat.StepResultOutcomeCouldNotRun { + t.Errorf("after the take-up program %s, tools %s; want passed kept, tools could not run", + stepNamed(q, "app:program", "unit").Outcome, stepNamed(q, "app:tools", "unit").Outcome) + } + continue + } r, _, _ := f.runs.Get(unit.Shared[0].Run) if again == "" || again == unit.Ask || r.Ask != again || r.Ended != nil || len(r.Readers) != 2 || r.Readers[0].Rerun == accepted || (!accepted && r.Readers[0].By != "op@shanks") { t.Fatalf("the rerun's run = %+v (ask %s), want a new run under the same key carrying the program, marked unless accepted", r, again)