From a33544101a32fc6cd9dc23189077fa7aa76ae97f Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Mon, 28 Apr 2025 01:00:54 +0200 Subject: [PATCH] fix: fuzzy model was not instanciated (#2200) * fix: fuzzy model was not instanciated * add test * add test --- executor_test.go | 21 +++++++++++++++++++ setup.go | 2 +- testdata/fuzzy/Taskfile.yml | 4 ++++ .../TestFuzzyModel-fuzzy-err-run.golden | 1 + .../testdata/TestFuzzyModel-fuzzy.golden | 1 + .../testdata/TestFuzzyModel-not-fuzzy.golden | 2 ++ 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 testdata/fuzzy/Taskfile.yml create mode 100644 testdata/fuzzy/testdata/TestFuzzyModel-fuzzy-err-run.golden create mode 100644 testdata/fuzzy/testdata/TestFuzzyModel-fuzzy.golden create mode 100644 testdata/fuzzy/testdata/TestFuzzyModel-not-fuzzy.golden diff --git a/executor_test.go b/executor_test.go index 8e61a9e9..8f3c794c 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 13f03dd4..0e94f3e6 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 00000000..a05ed02e --- /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 00000000..c4724624 --- /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 00000000..56e8128e --- /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 00000000..cc931bc3 --- /dev/null +++ b/testdata/fuzzy/testdata/TestFuzzyModel-not-fuzzy.golden @@ -0,0 +1,2 @@ +task: [install] echo 'install' +install