diff --git a/executor_test.go b/executor_test.go index 8e61a9e960..8f3c794c9d 100644 --- a/executor_test.go +++ b/executor_test.go @@ -937,3 +937,24 @@ func TestVarInheritance(t *testing.T) { ) } } + +func TestFuzzyModel(t *testing.T) { + t.Parallel() + + NewExecutorTest(t, + WithName("fuzzy"), + WithExecutorOptions( + task.WithDir("testdata/fuzzy"), + ), + WithTask("instal"), + WithRunError(), + ) + + NewExecutorTest(t, + WithName("not-fuzzy"), + WithExecutorOptions( + task.WithDir("testdata/fuzzy"), + ), + WithTask("install"), + ) +} diff --git a/setup.go b/setup.go index 13f03dd40b..0e94f3e67a 100644 --- a/setup.go +++ b/setup.go @@ -95,7 +95,7 @@ func (e *Executor) readTaskfile(node taskfile.Node) error { } func (e *Executor) setupFuzzyModel() { - if e.Taskfile != nil { + if e.Taskfile == nil { return } diff --git a/testdata/fuzzy/Taskfile.yml b/testdata/fuzzy/Taskfile.yml new file mode 100644 index 0000000000..a05ed02e3c --- /dev/null +++ b/testdata/fuzzy/Taskfile.yml @@ -0,0 +1,4 @@ +version: 3 + +tasks: + install: echo 'install' diff --git a/testdata/fuzzy/testdata/TestFuzzyModel-fuzzy-err-run.golden b/testdata/fuzzy/testdata/TestFuzzyModel-fuzzy-err-run.golden new file mode 100644 index 0000000000..c4724624eb --- /dev/null +++ b/testdata/fuzzy/testdata/TestFuzzyModel-fuzzy-err-run.golden @@ -0,0 +1 @@ +task: Task "instal" does not exist. Did you mean "install"? \ No newline at end of file diff --git a/testdata/fuzzy/testdata/TestFuzzyModel-fuzzy.golden b/testdata/fuzzy/testdata/TestFuzzyModel-fuzzy.golden new file mode 100644 index 0000000000..56e8128e82 --- /dev/null +++ b/testdata/fuzzy/testdata/TestFuzzyModel-fuzzy.golden @@ -0,0 +1 @@ +task: No tasks with description available. Try --list-all to list all tasks diff --git a/testdata/fuzzy/testdata/TestFuzzyModel-not-fuzzy.golden b/testdata/fuzzy/testdata/TestFuzzyModel-not-fuzzy.golden new file mode 100644 index 0000000000..cc931bc399 --- /dev/null +++ b/testdata/fuzzy/testdata/TestFuzzyModel-not-fuzzy.golden @@ -0,0 +1,2 @@ +task: [install] echo 'install' +install