| 974 | } |
| 975 | |
| 976 | func TestDry(t *testing.T) { |
| 977 | t.Parallel() |
| 978 | |
| 979 | const dir = "testdata/dry" |
| 980 | |
| 981 | file := filepathext.SmartJoin(dir, "file.txt") |
| 982 | _ = os.Remove(file) |
| 983 | |
| 984 | var buff bytes.Buffer |
| 985 | |
| 986 | e := task.NewExecutor( |
| 987 | task.WithDir(dir), |
| 988 | task.WithStdout(&buff), |
| 989 | task.WithStderr(&buff), |
| 990 | task.WithDry(true), |
| 991 | ) |
| 992 | require.NoError(t, e.Setup()) |
| 993 | require.NoError(t, e.Run(t.Context(), &task.Call{Task: "build"})) |
| 994 | |
| 995 | assert.Equal(t, "task: [build] touch file.txt", strings.TrimSpace(buff.String())) |
| 996 | if _, err := os.Stat(file); err == nil { |
| 997 | t.Errorf("File should not exist %s", file) |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | // TestDryChecksum tests if the checksum file is not being written to disk |
| 1002 | // if the dry mode is enabled. |