1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

feat: make CHECKSUM and TIMESTAMP vars available in cmds commands (#1872)

This commit is contained in:
Niklas Rousset
2024-12-31 16:04:42 +01:00
committed by GitHub
parent dc2eceb634
commit c1e14c461b
5 changed files with 62 additions and 16 deletions

View File

@@ -976,6 +976,39 @@ func TestStatusVariables(t *testing.T) {
assert.Contains(t, buff.String(), tf)
}
func TestCmdsVariables(t *testing.T) {
t.Parallel()
const dir = "testdata/cmds_vars"
_ = os.RemoveAll(filepathext.SmartJoin(dir, ".task"))
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
TempDir: task.TempDir{
Remote: filepathext.SmartJoin(dir, ".task"),
Fingerprint: filepathext.SmartJoin(dir, ".task"),
},
Stdout: &buff,
Stderr: &buff,
Silent: false,
Verbose: true,
}
require.NoError(t, e.Setup())
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "build"}))
assert.Contains(t, buff.String(), "3e464c4b03f4b65d740e1e130d4d108a")
inf, err := os.Stat(filepathext.SmartJoin(dir, "source.txt"))
require.NoError(t, err)
ts := fmt.Sprintf("%d", inf.ModTime().Unix())
tf := inf.ModTime().String()
assert.Contains(t, buff.String(), ts)
assert.Contains(t, buff.String(), tf)
}
func TestInit(t *testing.T) {
t.Parallel()