go/cli: an outcome not known is not a refusal; the Go binding is checked in the Go toolchain
mesh/merge-gate pass: builds mesh-sdk, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: THE CHANGE ALTERS ITS OWN CHECK (merge-check.sh): main's version judged it; the change's judges the pull requests after it merges; it…
mesh/delivery delivered
mesh/merge-gate pass: builds mesh-sdk, sent nowhere; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: THE CHANGE ALTERS ITS OWN CHECK (merge-check.sh): main's version judged it; the change's judges the pull requests after it merges; it…
mesh/delivery delivered
Review of hq ADR 0272: a line whose answer did not come in time may have run, and saying "nothing ran" there is a lie. Answer.Unknown and NotKnown say it may have run and name the call to look at. The SDK's repo-check ran in the TypeScript toolchain only and said "NOT TESTED HERE: go/". go/merge-check.sh now runs the Go binding in the Go toolchain, declared by the root check (mesh-check-also), as the lab does. Released as go/v0.1.9 (go/v0.1.8 is mesh-sdk #12's).
This commit is contained in:
@@ -54,11 +54,24 @@ type Answer struct {
|
||||
Refused string `json:"refused,omitempty"`
|
||||
// Cut says the output was longer than one bus message and was cut there.
|
||||
Cut bool `json:"cut,omitempty"`
|
||||
// Unknown says the line was asked and its outcome is not known: no answer came in time, and it may have
|
||||
// run. Never said as a refusal, which means nothing ran.
|
||||
Unknown string `json:"unknown,omitempty"`
|
||||
}
|
||||
|
||||
// Refusal is an answer saying that nothing ran, and why.
|
||||
func Refusal(why string) Answer { return Answer{Exit: 1, Refused: why} }
|
||||
|
||||
// NotKnown is an answer saying the line was asked and what came of it is not known: it may have run. call is
|
||||
// the controller's call the line runs as, when it is known, which `calls` answers.
|
||||
func NotKnown(call, why string) Answer {
|
||||
where := "the controller's `calls` lists what came of each line"
|
||||
if call != "" {
|
||||
where = "see the call " + call + " (`calls " + call + "`)"
|
||||
}
|
||||
return Answer{Exit: 1, Unknown: why + "; the line may have run — " + where}
|
||||
}
|
||||
|
||||
// ErrTooLong is a request or an answer over its bound.
|
||||
var ErrTooLong = errors.New("longer than the protocol allows")
|
||||
|
||||
|
||||
+15
-2
@@ -26,7 +26,8 @@ func TestARequestAndAnAnswerSurviveTheirRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
b.Reset()
|
||||
sent := Answer{Stdout: []byte("ok\n\xff"), Stderr: []byte("said"), Exit: 3, Terminal: true, Why: "the terminal", Cut: true}
|
||||
sent := Answer{Stdout: []byte("ok\n\xff"), Stderr: []byte("said"), Exit: 3, Terminal: true, Why: "the terminal", Cut: true,
|
||||
Unknown: "no answer; the line may have run — see the call call-1"}
|
||||
if err := WriteAnswer(&b, sent); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -34,7 +35,8 @@ func TestARequestAndAnAnswerSurviveTheirRoundTrip(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(a.Stdout, sent.Stdout) || string(a.Stderr) != "said" || a.Exit != 3 || !a.Terminal || a.Why != sent.Why || !a.Cut {
|
||||
if !bytes.Equal(a.Stdout, sent.Stdout) || string(a.Stderr) != "said" || a.Exit != 3 || !a.Terminal || a.Why != sent.Why || !a.Cut ||
|
||||
a.Unknown != sent.Unknown {
|
||||
t.Fatalf("the answer came back as %+v", a)
|
||||
}
|
||||
}
|
||||
@@ -90,3 +92,14 @@ func TestAskSpeaksTheProtocolOverASocket(t *testing.T) {
|
||||
t.Fatalf("a missing socket was not said: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// An outcome not known is never a refusal: it says the line may have run, and exits non-zero.
|
||||
func TestAnUnknownOutcomeIsNotARefusal(t *testing.T) {
|
||||
a := NotKnown("call-7", "no answer within 6m0s")
|
||||
if a.Refused != "" || a.Exit == 0 || !strings.Contains(a.Unknown, "may have run") || !strings.Contains(a.Unknown, "call-7") {
|
||||
t.Fatalf("an unknown outcome reads as %+v", a)
|
||||
}
|
||||
if b := NotKnown("", "no answer"); strings.Contains(b.Unknown, "call ") {
|
||||
t.Fatalf("an unknown outcome with no call names one: %+v", b)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user