1
0
mirror of https://github.com/go-task/task.git synced 2025-06-13 06:01:32 +03:00

add checksum based status check, alternative to timestamp based

This commit is contained in:
Andrey Nering
2017-09-16 11:44:13 -03:00
parent 95f7b9443f
commit c295a1998a
15 changed files with 315 additions and 97 deletions

View File

@ -312,6 +312,40 @@ func TestGenerates(t *testing.T) {
}
}
func TestStatusChecksum(t *testing.T) {
const dir = "testdata/checksum"
files := []string{
"generated.txt",
".task/build",
}
for _, f := range files {
_ = os.Remove(filepath.Join(dir, f))
_, err := os.Stat(filepath.Join(dir, f))
assert.Error(t, err)
}
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
}
assert.NoError(t, e.ReadTaskfile())
assert.NoError(t, e.Run(task.Call{Task: "build"}))
for _, f := range files {
_, err := os.Stat(filepath.Join(dir, f))
assert.NoError(t, err)
}
buff.Reset()
assert.NoError(t, e.Run(task.Call{Task: "build"}))
assert.Equal(t, `task: Task "build" is up to date`+"\n", buff.String())
}
func TestInit(t *testing.T) {
const dir = "testdata/init"
var file = filepath.Join(dir, "Taskfile.yml")