diff --git a/task_test.go b/task_test.go index 6f0214c9..cac097b0 100644 --- a/task_test.go +++ b/task_test.go @@ -432,3 +432,25 @@ func TestExpand(t *testing.T) { assert.NoError(t, e.Run(taskfile.Call{Task: "pwd"})) assert.Equal(t, home, strings.TrimSpace(buff.String())) } + +func TestDryRun(t *testing.T) { + const dir = "testdata/dryrun" + + file := filepath.Join(dir, "file.txt") + _ = os.Remove(file) + + var buff bytes.Buffer + + e := task.Executor{ + Dir: dir, + Stdout: &buff, + Stderr: &buff, + DryRun: true, + } + assert.NoError(t, e.Setup()) + assert.NoError(t, e.Run(taskfile.Call{Task: "build"})) + + if _, err := os.Stat(file); err == nil { + t.Errorf("File should not exist %s", file) + } +} diff --git a/testdata/dryrun/Taskfile.yml b/testdata/dryrun/Taskfile.yml new file mode 100644 index 00000000..62c6dde7 --- /dev/null +++ b/testdata/dryrun/Taskfile.yml @@ -0,0 +1,3 @@ +build: + cmds: + - touch file.txt \ No newline at end of file