package main import ( "context" "encoding/json" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" "strings" "testing" "time" buildrun "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildrun" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun/conformance" "git.novox.be/novox/mesh-sdk/go/forgekey" ) // 1901/AC7: the module's own parse path (testFailures, as the test step calls it on a command that failed) keeps the // failure contract on every captured node --test and tsc case of the SDK's conformance kit. func TestTheTestStepKeepsTheFailureContract(t *testing.T) { conformance.Run(t, conformance.NodeTest, func(o conformance.Output) []sdkstep.Failure { return testFailures(".", "test", o.Dir, forgekey.Ran{Status: 1, Stdout: o.Stdout, Stderr: o.Stderr}, o.Report) }) conformance.Run(t, conformance.TypeCheck, func(o conformance.Output) []sdkstep.Failure { return testFailures(".", "type-check", o.Dir, forgekey.Ran{Status: 2, Stdout: o.Stdout, Stderr: o.Stderr}, "") }) } // 1890/AC7: the module's own start sweep (endLeftRunning, as main runs it) keeps the conformance kit's left-running // case: a step a previous process left running is ended at once and said, whatever its age, and a step of this process // is kept. func TestTheStartSweepEndsWhatAPreviousProcessLeft(t *testing.T) { conformance.LeftRunning(t, func(ctx context.Context, scan buildrun.Scan, node string, before time.Time, logf func(string, ...any)) { (&Module{Node: node}).endLeftRunning(ctx, scan, before, logf) }) } // ADR 0664 §1 (issue 1748): the module's own paths from a failed fetch or install to its step's error say a network that did // not answer as a transport fault, and a failure of the source (a package the registry lacks) as none. func TestTheStepsSayAFailedNetworkAsATransportFault(t *testing.T) { conformance.Passing(t, []string{conformance.GitFetch, conformance.NpmCI}, func(runner, words string) error { switch runner { case conformance.GitFetch: run := func(context.Context, []string, string, ...string) forgekey.Ran { return forgekey.Ran{Status: 128, Stderr: words} } return steprun.FetchCommit(context.Background(), run, t.TempDir(), "ssh://mesh-forge/o/r.git", strings.Repeat("a", 40), "") default: bad := &fakeNpm{ran: forgekey.Ran{Status: 1, Stderr: words}} return toolchainIn(t, bad).Ensure(context.Background(), Recipe{Steps: "k", Lock: "k"}.Version()) } }) } // A-489b, design 47 G §24: the module's own steps can say a pipeline step's end, or // every step ask the runner sends it is refused ("this build module says no step's end"), as the first live pipeline met. func TestTheStepsCanSayAStepsEnd(t *testing.T) { conformance.StepEnds(t, (&Module{Node: "kitnode"}).askSteps(nil)) } // A-489c (A-489a): the module's puller counts the runs its steps state says started, not the bus's deliveries (an ask given back before // it ran is no run), so the poison rule never ends an ask that never ran. func TestThePullerCountsRunsThatStarted(t *testing.T) { conformance.RunsCounted(t, func(read func(string) (json.RawMessage, error)) *steprun.Puller { m := &Module{Node: "kitnode", Capacity: func() int { return 1 }} m.ReadSteps = StateRead{Get: read} return m.Puller(nil, steprun.NewFakeAsks()) }) }