assigner: a composition step with no machine judged ends could not run (A-467a)
A step whose every machine is away never passes: it ends could not run, naming each machine and why. An away machine is still not asked and still said as a warning when another machine is judged. Builds: design 47 G A-467a, A-467
This commit is contained in:
@@ -133,6 +133,8 @@ type compositionRun struct {
|
||||
// machineEnd is what one machine came to.
|
||||
type machineEnd struct {
|
||||
failed, couldNot, warning string
|
||||
// judged is set where the composer judged the machine, composing or not (A-467a).
|
||||
judged bool
|
||||
}
|
||||
|
||||
// run runs one composition step and answers what it came to: failed when a machine does not compose, could not run when a machine
|
||||
@@ -172,7 +174,11 @@ func (r *compositionRun) run(ctx context.Context, _ string, run meshwants.StepRu
|
||||
setPhase(ctx, meshwants.StepProgressEventPhaseReport)
|
||||
var out stepOutcome
|
||||
var failed, couldNot []string
|
||||
judged := 0
|
||||
for _, e := range ends {
|
||||
if e.judged {
|
||||
judged++
|
||||
}
|
||||
failed = appendSome(failed, e.failed)
|
||||
couldNot = appendSome(couldNot, e.couldNot)
|
||||
out.Warnings = appendSome(out.Warnings, e.warning)
|
||||
@@ -182,6 +188,14 @@ func (r *compositionRun) run(ctx context.Context, _ string, run meshwants.StepRu
|
||||
out.Outcome, out.Said = meshwants.StepEndedOutcomeFailed, strings.Join(failed, "; ")
|
||||
case len(couldNot) > 0:
|
||||
out.Outcome, out.Said = meshwants.StepEndedOutcomeCouldNotRun, strings.Join(couldNot, "; ")
|
||||
case judged == 0: // a step that judged no machine never passes (A-467a): each machine not judged is named with why
|
||||
said := "no machine was judged"
|
||||
if len(out.Warnings) == 0 {
|
||||
said += ": the step has no machine"
|
||||
} else {
|
||||
said += ": " + strings.Join(out.Warnings, "; ")
|
||||
}
|
||||
out.Outcome, out.Said = meshwants.StepEndedOutcomeCouldNotRun, said
|
||||
default:
|
||||
out.Outcome = meshwants.StepEndedOutcomePassed
|
||||
}
|
||||
@@ -270,9 +284,9 @@ func verdictOf(node string, answer []byte) machineEnd {
|
||||
case m.NotJudged != "": // a step never passes on a machine it did not judge (A-467)
|
||||
return machineEnd{couldNot: node + " was not judged: " + m.NotJudged}
|
||||
case !m.Composes:
|
||||
return machineEnd{failed: node + " does not compose: " + strings.Join(appendSome(append(slices.Clone(m.Problems), m.Refusals...), m.Reason), "; ")}
|
||||
return machineEnd{judged: true, failed: node + " does not compose: " + strings.Join(appendSome(append(slices.Clone(m.Problems), m.Refusals...), m.Reason), "; ")}
|
||||
}
|
||||
return machineEnd{}
|
||||
return machineEnd{judged: true}
|
||||
}
|
||||
return machineEnd{couldNot: node + ": the composer's verdict has no case " + changeCase}
|
||||
}
|
||||
|
||||
@@ -226,6 +226,20 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
|
||||
t.Errorf("a machine not judged came to %+v", out)
|
||||
}
|
||||
|
||||
// No machine judged: every machine away, or no machine, never passes; each is named with why (A-467a).
|
||||
for name, machines := range map[string][]string{"every machine away": {"shanks"}, "no machine": {}} { // none placed: the inputs say so already
|
||||
want := "no machine was judged"
|
||||
if len(machines) == 0 {
|
||||
want = "has no machine to compose"
|
||||
}
|
||||
none := newRunStand(t, "src2:e1", "src2:e1", "d1")
|
||||
none.r.inputs.machines = func(string, string) []string { return machines }
|
||||
if out := none.r.run(context.Background(), "ask-step", step); out.Outcome != meshwants.StepEndedOutcomeCouldNotRun ||
|
||||
!strings.Contains(out.Said, want) || (len(machines) > 0 && !strings.Contains(out.Said, "shanks is away")) || len(none.asks) != 0 {
|
||||
t.Errorf("%s came to %+v, %d asks", name, out, len(none.asks))
|
||||
}
|
||||
}
|
||||
|
||||
// At the inputs state's cap the ask is refused, naming the store (§354).
|
||||
full := newRunStand(t, "src2:e1", "src2:e1", "d1")
|
||||
full.r.keeper.used = func() (int64, error) { return inputsCap, nil }
|
||||
|
||||
Reference in New Issue
Block a user