1
0
mirror of https://github.com/go-task/task.git synced 2025-08-08 22:36:57 +02:00

fix(watcher): fix some v3.43.x regressions (#2271)

This commit is contained in:
Andrey Nering
2025-06-08 19:44:08 -03:00
committed by GitHub
parent 9cc2d65091
commit 7782bc92ae
2 changed files with 85 additions and 62 deletions

View File

@@ -31,16 +31,17 @@ task: Started watching for tasks: default
task: [default] echo "Task running!"
Task running!
task: task "default" finished running
task: Task "default" is up to date
task: [default] echo "Task running!"
Task running!
task: task "default" finished running
`)
var buff bytes.Buffer
e := task.NewExecutor(
task.ExecutorWithDir(dir),
task.ExecutorWithStdout(&buff),
task.ExecutorWithStderr(&buff),
task.ExecutorWithWatch(true),
task.WithDir(dir),
task.WithStdout(&buff),
task.WithStderr(&buff),
task.WithWatch(true),
)
require.NoError(t, e.Setup())
@@ -71,16 +72,16 @@ task: task "default" finished running
}
}()
time.Sleep(10 * time.Millisecond)
time.Sleep(200 * time.Millisecond)
err = os.WriteFile(filePath, []byte("test updated"), 0o644)
require.NoError(t, err)
time.Sleep(150 * time.Millisecond)
time.Sleep(200 * time.Millisecond)
cancel()
assert.Equal(t, expectedOutput, strings.TrimSpace(buff.String()))
}
func TestShouldIgnoreFile(t *testing.T) {
func TestShouldIgnore(t *testing.T) {
t.Parallel()
tt := []struct {
@@ -95,7 +96,7 @@ func TestShouldIgnoreFile(t *testing.T) {
ct := ct
t.Run(fmt.Sprintf("ignore - %d", k), func(t *testing.T) {
t.Parallel()
require.Equal(t, task.ShouldIgnoreFile(ct.path), ct.expect)
require.Equal(t, task.ShouldIgnore(ct.path), ct.expect)
})
}
}