diff --git a/Taskfile.yml b/Taskfile.yml index 9401a29c..70c45244 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,8 +9,8 @@ lint: - golint . - golint ./cmd/task -# TODO: have tests test: + deps: [install] cmds: - go test -v diff --git a/task_test.go b/task_test.go new file mode 100644 index 00000000..0c6e5cba --- /dev/null +++ b/task_test.go @@ -0,0 +1,45 @@ +package task_test + +import ( + "os" + "os/exec" + "path/filepath" + "testing" +) + +func TestDeps(t *testing.T) { + const dir = "testdata/deps" + + files := []string{ + "d1.txt", + "d2.txt", + "d3.txt", + "d11.txt", + "d12.txt", + "d13.txt", + "d21.txt", + "d22.txt", + "d23.txt", + "d31.txt", + "d32.txt", + "d33.txt", + } + + for _, f := range files { + _ = os.Remove(f) + } + + c := exec.Command("task") + c.Dir = dir + if err := c.Run(); err != nil { + t.Error(err) + return + } + + for _, f := range files { + f = filepath.Join(dir, f) + if _, err := os.Stat(f); err != nil { + t.Errorf("File %s should exists", f) + } + } +} diff --git a/testdata/deps/.gitignore b/testdata/deps/.gitignore new file mode 100644 index 00000000..2211df63 --- /dev/null +++ b/testdata/deps/.gitignore @@ -0,0 +1 @@ +*.txt diff --git a/testdata/deps/Taskfile.yml b/testdata/deps/Taskfile.yml new file mode 100644 index 00000000..dd82345c --- /dev/null +++ b/testdata/deps/Taskfile.yml @@ -0,0 +1,53 @@ +default: + deps: [d1, d2, d3] + +d1: + deps: [d11, d12, d13] + cmds: + - echo 'Text' > d1.txt + +d2: + deps: [d21, d22, d23] + cmds: + - echo 'Text' > d2.txt + +d3: + deps: [d31, d32, d33] + cmds: + - echo 'Text' > d3.txt + +d11: + cmds: + - echo 'Text' > d11.txt + +d12: + cmds: + - echo 'Text' > d12.txt + +d13: + cmds: + - echo 'Text' > d13.txt + +d21: + cmds: + - echo 'Text' > d21.txt + +d22: + cmds: + - echo 'Text' > d22.txt + +d23: + cmds: + - echo 'Text' > d23.txt + +d31: + cmds: + - echo 'Text' > d31.txt + +d32: + cmds: + - echo 'Text' > d32.txt + +d33: + cmds: + - echo 'Text' > d33.txt