1
0
mirror of https://github.com/go-task/task.git synced 2025-06-15 00:15:10 +02:00

fix: only rewrite checksum files if the checksum has changed

This commit is contained in:
Andrew Berry
2023-06-03 18:20:08 -04:00
committed by GitHub
parent 1936142042
commit 082cdcc358
2 changed files with 13 additions and 2 deletions

View File

@ -508,9 +508,10 @@ func TestStatusChecksum(t *testing.T) {
}
var buff bytes.Buffer
tempdir := filepathext.SmartJoin(dir, ".task")
e := task.Executor{
Dir: dir,
TempDir: filepathext.SmartJoin(dir, ".task"),
TempDir: tempdir,
Stdout: &buff,
Stderr: &buff,
}
@ -522,9 +523,19 @@ func TestStatusChecksum(t *testing.T) {
require.NoError(t, err)
}
// Capture the modification time, so we can ensure the checksum file
// is not regenerated when the hash hasn't changed.
s, err := os.Stat(filepathext.SmartJoin(tempdir, "checksum/"+test.task))
require.NoError(t, err)
time := s.ModTime()
buff.Reset()
require.NoError(t, e.Run(context.Background(), taskfile.Call{Task: test.task}))
assert.Equal(t, `task: Task "`+test.task+`" is up to date`+"\n", buff.String())
s, err = os.Stat(filepathext.SmartJoin(tempdir, "checksum/"+test.task))
require.NoError(t, err)
assert.Equal(t, time, s.ModTime())
})
}
}