| index 6d21aefeb..30215349f 100644 |
| --- a/approved_moves_copy_test.go |
| +++ b/approved_moves_copy_test.go |
| @@ -1707,12 +1707,53 @@ func findUnrecorded(ems []movesEmission, rows []copyRow) []movesEmission { |
| return out |
| } |
| |
| +// rootfsApprovedPatterns is the pattern of every approved, built row of the |
| +// rootfs deck (rootfsBuiltTexts through formatPattern), so a row's %s |
| +// matches the code's fill-in. |
| +func rootfsApprovedPatterns(rows []copyRow) map[string]bool { |
| + out := map[string]bool{} |
| + for text := range rootfsBuiltTexts(rows) { |
| + out[formatPattern(text)] = true |
| + } |
| + return out |
| +} |
| + |
| +// recordedElsewhere reports whether an emission no moves row carries is, |
| +// whole, the pattern of an approved, built row of another deck: the move |
| +// doors' refusal of a rootfs instance is RFS-3-C23 (rootfs Plan 3 Task 13), |
| +// as movesExemptionHolds takes such a row for a legacy exemption. A value |
| +// the gate could not derive, or a fragment, is never one. |
| +func recordedElsewhere(e movesEmission, elsewhere map[string]bool) bool { |
| + return !e.underived && !e.fragment && elsewhere[e.pattern] |
| +} |
| + |
| +func TestMovesRecordedElsewhere(t *testing.T) { |
| + elsewhere := rootfsApprovedPatterns(mustParseRootfsRecord(t)) |
| + c23 := formatPattern("%s is a rootfs instance, and a rootfs instance does not move. create a new instance where you want it") |
| + for _, tc := range []struct { |
| + e movesEmission |
| + want bool |
| + }{ |
| + {movesEmission{pattern: c23}, true}, |
| + {movesEmission{pattern: c23, underived: true}, false}, |
| + {movesEmission{pattern: c23, fragment: true}, false}, |
| + {movesEmission{pattern: c23 + " now"}, false}, |
| + {movesEmission{pattern: "a sentence in neither deck"}, false}, |
| + } { |
| + if got := recordedElsewhere(tc.e, elsewhere); got != tc.want { |
| + t.Errorf("recordedElsewhere(%s) = %v, want %v", tc.e, got, tc.want) |
| + } |
| + } |
| +} |
| + |
| // Every sentence the moves code emits to an operator (an HTTP error body, a |
| -// check's Reason, a phase 1 copy table's text) has a row in the record. A |
| -// sentence with no row is a finding: add it as a pending row. It is not a |
| -// reason to loosen this test. |
| +// check's Reason, a phase 1 copy table's text) has a row in the record, or |
| +// is the whole of an approved, built row of the rootfs deck |
| +// (recordedElsewhere). A sentence with no row is a finding: add it as a |
| +// pending row. It is not a reason to loosen this test. |
| func TestMovesStringsAreRecorded(t *testing.T) { |
| rows := mustParseMovesRecord(t) |
| + elsewhere := rootfsApprovedPatterns(mustParseRootfsRecord(t)) |
| var all []movesEmission |
| for _, f := range movesScanFiles { |
| all = append(all, scanMovesFile(t, f)...) |
| @@ -1721,6 +1762,9 @@ func TestMovesStringsAreRecorded(t *testing.T) { |
| t.Fatalf("the scan found only %d emissions; it has stopped reading the code", len(all)) |
| } |
| for _, e := range findUnrecorded(all, rows) { |
| + if recordedElsewhere(e, elsewhere) { |
| + continue |
| + } |
| t.Errorf("no row of the record carries %s", e) |
| } |
| } |