mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
Updated test for file watcher interval param
Updated Interval Setting Priority
This commit is contained in:
@@ -1503,9 +1503,6 @@ Hello, World!
|
||||
assert.NoError(t, e.Setup())
|
||||
buff.Reset()
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
err := os.MkdirAll(dir+"/src", 0755)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -1514,6 +1511,9 @@ Hello, World!
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
go func(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
@@ -1535,9 +1535,10 @@ Hello, World!
|
||||
}
|
||||
time.Sleep(70 * time.Millisecond)
|
||||
cancel()
|
||||
|
||||
assert.Equal(t, expectedOutput, strings.TrimSpace(buff.String()))
|
||||
buff.Reset()
|
||||
err = os.RemoveAll(dir + "/.task")
|
||||
assert.NoError(t, err)
|
||||
err = os.RemoveAll(dir + "/src")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
2
testdata/watcher_interval/Taskfile.yaml
vendored
2
testdata/watcher_interval/Taskfile.yaml
vendored
@@ -5,7 +5,7 @@ version: '3'
|
||||
vars:
|
||||
GREETING: Hello, World!
|
||||
|
||||
interval: "50ms"
|
||||
interval: "30ms"
|
||||
|
||||
tasks:
|
||||
default:
|
||||
|
10
watch.go
10
watch.go
@@ -39,17 +39,17 @@ func (e *Executor) watchTasks(calls ...taskfile.Call) error {
|
||||
|
||||
var watchIntervalString string
|
||||
|
||||
if e.Taskfile.Interval != "" {
|
||||
watchIntervalString = e.Taskfile.Interval
|
||||
} else if e.Interval != "" {
|
||||
if e.Interval != "" {
|
||||
watchIntervalString = e.Interval
|
||||
} else if e.Taskfile.Interval != "" {
|
||||
watchIntervalString = e.Taskfile.Interval
|
||||
}
|
||||
|
||||
watchInterval := defaultWatchInterval
|
||||
|
||||
if watchIntervalString != "" {
|
||||
var err error
|
||||
watchInterval, err = parsedWatchInterval(watchIntervalString)
|
||||
watchInterval, err = parseWatchInterval(watchIntervalString)
|
||||
if err != nil {
|
||||
e.Logger.Errf(logger.Red, "%v", err)
|
||||
}
|
||||
@@ -185,7 +185,7 @@ func shouldIgnoreFile(path string) bool {
|
||||
return strings.Contains(path, "/.git") || strings.Contains(path, "/.task") || strings.Contains(path, "/node_modules")
|
||||
}
|
||||
|
||||
func parsedWatchInterval(watchInterval string) (time.Duration, error) {
|
||||
func parseWatchInterval(watchInterval string) (time.Duration, error) {
|
||||
v, err := time.ParseDuration(watchInterval)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf(`task: Could not parse watch interval "%s": %v`, watchInterval, err)
|
||||
|
Reference in New Issue
Block a user