Give the gate a short changed list as an argument, as before, so an older judge still runs (issue 1247, review round 1)

This commit is contained in:
2026-10-19 15:40:20 +02:00
parent dd802c81a7
commit da5a5c9b67
2 changed files with 51 additions and 9 deletions
+25 -4
View File
@@ -81,15 +81,36 @@ func TestAShortListOfChangedPathsStaysAsItWasAndIsInTheFileToo(t *testing.T) { /
}
}
func TestTheGateReadsTheChangedPathsFromTheFile(t *testing.T) { // 1247/AC3
// theGatesCommand is the command gateLayer hands the toolchain for the merge gate, given the environment of the check.
func theGatesCommand(t *testing.T, env []string) string {
t.Helper()
var args []string
gateLayer(t.Context(), CheckSpec{}, t.TempDir(), t.TempDir(), "gate", filepath.Join(t.TempDir(), "verdict.json"), nil,
gateLayer(t.Context(), CheckSpec{}, t.TempDir(), t.TempDir(), "gate", filepath.Join(t.TempDir(), "verdict.json"), env,
func(dir string, env []string, command ...string) []string { return command },
func(a []string) error { args = a; return errors.New("stop here") }, &tail{}, "bus", "name", false, "", nil,
func(string, string, ...any) {})
command := strings.Join(args, " ")
return strings.Join(args, " ")
}
func TestTheGateIsGivenAShortListAsBeforeSoAnOlderJudgeStillRuns(t *testing.T) { // 1247/AC3
env, err := changedEnvironment(t.TempDir(), []string{"a.go", "b.go"}, func(string) {})
if err != nil {
t.Fatal(err)
}
command := theGatesCommand(t, env)
if !strings.Contains(command, `--changed "$MESH_CHECK_CHANGED"`) || strings.Contains(command, "--changed-file") {
t.Errorf("a short list is not given to the gate as --changed alone: %s", command)
}
}
func TestTheGateReadsACutListFromTheFile(t *testing.T) { // 1247/AC3
env, err := changedEnvironment(t.TempDir(), manyPaths(), func(string) {})
if err != nil {
t.Fatal(err)
}
command := theGatesCommand(t, env)
if !strings.Contains(command, `--changed-file "$MESH_CHECK_CHANGED_FILE"`) || strings.Contains(command, `--changed "`) {
t.Errorf("the gate's command does not read the paths from the file: %s", command)
t.Errorf("a cut list is not given to the gate through the file alone: %s", command)
}
}