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

Prevent TestFileWatcherInterval from running on CI

This test can fail intermittently. It's fine to run it only locally.

We were already doing this for TestSignalSentToProcessGroup.
This commit is contained in:
Andrey Nering
2022-12-17 11:08:41 -03:00
parent a98b41d657
commit d6d51a2f8b
3 changed files with 83 additions and 65 deletions

View File

@ -10,7 +10,6 @@ import (
"runtime"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
@ -1649,67 +1648,6 @@ func TestEvaluateSymlinksInPaths(t *testing.T) {
assert.NoError(t, err)
}
func TestFileWatcherInterval(t *testing.T) {
const dir = "testdata/watcher_interval"
expectedOutput := strings.TrimSpace(`
task: Started watching for tasks: default
task: [default] echo "Hello, World!"
Hello, World!
task: [default] echo "Hello, World!"
Hello, World!
`)
var buff bytes.Buffer
e := &task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
Watch: true,
}
assert.NoError(t, e.Setup())
buff.Reset()
err := os.MkdirAll(filepathext.SmartJoin(dir, "src"), 0755)
assert.NoError(t, err)
err = os.WriteFile(filepathext.SmartJoin(dir, "src/a"), []byte("test"), 0644)
if err != nil {
t.Fatal(err)
}
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
go func(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
default:
err := e.Run(ctx, taskfile.Call{Task: "default"})
if err != nil {
return
}
}
}
}(ctx)
time.Sleep(10 * time.Millisecond)
err = os.WriteFile(filepathext.SmartJoin(dir, "src/a"), []byte("test updated"), 0644)
if err != nil {
t.Fatal(err)
}
time.Sleep(700 * time.Millisecond)
cancel()
assert.Equal(t, expectedOutput, strings.TrimSpace(buff.String()))
buff.Reset()
err = os.RemoveAll(filepathext.SmartJoin(dir, ".task"))
assert.NoError(t, err)
err = os.RemoveAll(filepathext.SmartJoin(dir, "src"))
assert.NoError(t, err)
}
func TestTaskfileWalk(t *testing.T) {
tests := []struct {
name string