Build TypeScript with the installed node and name no Node version (issue 1572, ADR 0477)
This commit is contained in:
@@ -74,7 +74,7 @@ func (s *keptStates) waitEnd(t *testing.T) delivery.Step {
|
||||
}
|
||||
|
||||
func moduleWith(states *keptStates, installed string) *Module {
|
||||
return &Module{Node: "ace", Recipe: Recipe{Steps: "1", Node: "v26.10.0", Lock: "lock"},
|
||||
return &Module{Node: "ace", Recipe: Recipe{Steps: "1", Lock: "lock"},
|
||||
Probe: func(context.Context) (string, error) { return installed, nil },
|
||||
Toolchains: states.putToolchain, Steps: states.putStep, Ctx: context.Background()}
|
||||
}
|
||||
@@ -102,11 +102,14 @@ func TestStartWritesTheToolchainAndHealthIsHealthy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// 1488/AC3: a probe answering v26.11.0: every step tool's step ends refused naming both versions, ace.typescript
|
||||
// holds v26.11.0, and the health tool answers unhealthy naming both.
|
||||
func TestAnotherNodeRefusesEveryStepAndHealthIsUnhealthy(t *testing.T) {
|
||||
// 1572/AC2 (ADR 0477 §2): a node that cannot be run: every step tool's step ends refused naming the cause, and the
|
||||
// health tool answers unhealthy naming it.
|
||||
func TestANodeThatCannotBeRunRefusesEveryStepAndHealthIsUnhealthy(t *testing.T) {
|
||||
states := newStates()
|
||||
m := moduleWith(states, "v26.11.0")
|
||||
m := moduleWith(states, "")
|
||||
m.Probe = func(context.Context) (string, error) {
|
||||
return "", errors.New("exec: node: executable file not found in $PATH")
|
||||
}
|
||||
ran := false
|
||||
run := func(context.Context, map[string]any) (any, error) { ran = true; return "done", nil }
|
||||
steps := append([]StepTool{
|
||||
@@ -137,19 +140,16 @@ func TestAnotherNodeRefusesEveryStepAndHealthIsUnhealthy(t *testing.T) {
|
||||
}
|
||||
reason = err.Error()
|
||||
}
|
||||
if !strings.Contains(reason, "v26.11.0") || !strings.Contains(reason, "v26.10.0") {
|
||||
t.Errorf("%s: the refusal %q does not name both versions", tool.Name, reason)
|
||||
if !strings.Contains(reason, "executable file not found") {
|
||||
t.Errorf("%s: the refusal %q does not name the cause", tool.Name, reason)
|
||||
}
|
||||
}
|
||||
if ran {
|
||||
t.Errorf("a step ran on a node that refuses")
|
||||
}
|
||||
if tc, _ := states.toolchain("ace.typescript"); tc.Version != "v26.11.0" {
|
||||
t.Errorf("ace.typescript holds %q, want the installed v26.11.0", tc.Version)
|
||||
}
|
||||
a := m.Health(context.Background())
|
||||
if a.State != health.StateUnhealthy || !strings.Contains(a.Why, "v26.11.0") || !strings.Contains(a.Why, "v26.10.0") {
|
||||
t.Errorf("health = %+v, want unhealthy naming both versions", a)
|
||||
if a.State != health.StateUnhealthy || !strings.Contains(a.Why, "executable file not found") {
|
||||
t.Errorf("health = %+v, want unhealthy naming the cause", a)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,19 +162,18 @@ func isLong(steps []StepTool, name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 1488/AC2: the recipe version moves with one byte of the lock and with the Node version, and with the recipe's own
|
||||
// version; equal recipes have the same one.
|
||||
// 1488/AC2, 1572/AC3: the recipe version moves with one byte of the lock and with the recipe's own version; equal
|
||||
// recipes have the same one.
|
||||
func TestRecipeVersionMovesWithEachOfItsValues(t *testing.T) {
|
||||
lock := []byte(`{"lockfileVersion":3}`)
|
||||
base := Recipe{Steps: "1", Node: "v26.10.0", Lock: LockHash(lock)}
|
||||
if base.Version() != (Recipe{Steps: "1", Node: "v26.10.0", Lock: LockHash(lock)}).Version() {
|
||||
base := Recipe{Steps: "1", Lock: LockHash(lock)}
|
||||
if base.Version() != (Recipe{Steps: "1", Lock: LockHash(lock)}).Version() {
|
||||
t.Errorf("one recipe has two versions")
|
||||
}
|
||||
seen := map[string]string{base.Version(): "base"}
|
||||
for name, r := range map[string]Recipe{
|
||||
"one byte of the lock": {Steps: "1", Node: "v26.10.0", Lock: LockHash([]byte(`{"lockfileVersion":4}`))},
|
||||
"node": {Steps: "1", Node: "v26.11.0", Lock: LockHash(lock)},
|
||||
"steps": {Steps: "2", Node: "v26.10.0", Lock: LockHash(lock)},
|
||||
"one byte of the lock": {Steps: "1", Lock: LockHash([]byte(`{"lockfileVersion":4}`))},
|
||||
"steps": {Steps: "2", Lock: LockHash(lock)},
|
||||
} {
|
||||
v := r.Version()
|
||||
if was, dup := seen[v]; dup {
|
||||
@@ -193,7 +192,7 @@ func TestReadRecipeHashesTheLockFile(t *testing.T) {
|
||||
}
|
||||
os.WriteFile(path, []byte("a"), 0o600)
|
||||
a, err := ReadRecipe(path)
|
||||
if err != nil || a.Node != "v26.10.0" {
|
||||
if err != nil || a.Steps != RecipeSteps {
|
||||
t.Fatalf("= %+v, %v", a, err)
|
||||
}
|
||||
os.WriteFile(path, []byte("b"), 0o600)
|
||||
@@ -207,7 +206,7 @@ func TestReadRecipeHashesTheLockFile(t *testing.T) {
|
||||
func TestACheckReadsTheRecipeAgain(t *testing.T) {
|
||||
states := newStates()
|
||||
m := moduleWith(states, "v26.10.0")
|
||||
r2 := Recipe{Steps: "1", Node: "v26.10.0", Lock: "other"}
|
||||
r2 := Recipe{Steps: "1", Lock: "other"}
|
||||
m.Reload = func() (Recipe, error) { return r2, nil }
|
||||
if err := m.Check(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user