|
|
|
@ -53,7 +53,7 @@ func (fct fileContentTest) Run(t *testing.T) {
|
|
|
|
|
Stderr: io.Discard,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup(), "e.Setup()")
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: fct.Target}), "e.Run(target)")
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: fct.Target}), "e.Run(target)")
|
|
|
|
|
|
|
|
|
|
for name, expectContent := range fct.Files {
|
|
|
|
|
t.Run(fct.name(name), func(t *testing.T) {
|
|
|
|
@ -76,7 +76,7 @@ func TestEmptyTask(t *testing.T) {
|
|
|
|
|
Stderr: io.Discard,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup(), "e.Setup()")
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestEnv(t *testing.T) {
|
|
|
|
@ -141,7 +141,7 @@ func TestSpecialVars(t *testing.T) {
|
|
|
|
|
Silent: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: test.target}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: test.target}))
|
|
|
|
|
assert.Equal(t, test.expected+"\n", buff.String())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -160,7 +160,7 @@ func TestConcurrency(t *testing.T) {
|
|
|
|
|
Concurrency: 1,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup(), "e.Setup()")
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: target}), "e.Run(target)")
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: target}), "e.Run(target)")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestParams(t *testing.T) {
|
|
|
|
@ -212,7 +212,7 @@ func TestDeps(t *testing.T) {
|
|
|
|
|
Stderr: io.Discard,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
|
|
|
|
|
for _, f := range files {
|
|
|
|
|
f = filepathext.SmartJoin(dir, f)
|
|
|
|
@ -249,15 +249,15 @@ func TestStatus(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
// gen-foo creates foo.txt, and will always fail it's status check.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-foo"}))
|
|
|
|
|
// gen-foo creates bar.txt, and will pass its status-check the 3. time it
|
|
|
|
|
// is run. It creates bar.txt, but also lists it as its source. So, the checksum
|
|
|
|
|
// for the file won't match before after the second run as we the file
|
|
|
|
|
// only exists after the first run.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-bar"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-bar"}))
|
|
|
|
|
// gen-silent-baz is marked as being silent, and should only produce output
|
|
|
|
|
// if e.Verbose is set to true.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
|
|
|
|
|
for _, f := range files {
|
|
|
|
|
if _, err := os.Stat(filepathext.SmartJoin(dir, f)); err != nil {
|
|
|
|
@ -266,10 +266,10 @@ func TestStatus(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Run gen-bar a second time to produce a checksum file that matches bar.txt
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-bar"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-bar"}))
|
|
|
|
|
|
|
|
|
|
// Run gen-bar a third time, to make sure we've triggered the status check.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-bar"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-bar"}))
|
|
|
|
|
|
|
|
|
|
// We're silent, so no output should have been produced.
|
|
|
|
|
assert.Empty(t, buff.String())
|
|
|
|
@ -278,7 +278,7 @@ func TestStatus(t *testing.T) {
|
|
|
|
|
// for the next test.
|
|
|
|
|
err := os.Remove(filepathext.SmartJoin(dir, "bar.txt"))
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-bar"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-bar"}))
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// Global silence switched of, so we should see output unless the task itself
|
|
|
|
@ -286,34 +286,34 @@ func TestStatus(t *testing.T) {
|
|
|
|
|
e.Silent = false
|
|
|
|
|
|
|
|
|
|
// all: not up-to-date
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-foo"}))
|
|
|
|
|
assert.Equal(t, "task: [gen-foo] touch foo.txt", strings.TrimSpace(buff.String()))
|
|
|
|
|
buff.Reset()
|
|
|
|
|
// status: not up-to-date
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-foo"}))
|
|
|
|
|
assert.Equal(t, "task: [gen-foo] touch foo.txt", strings.TrimSpace(buff.String()))
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// sources: not up-to-date
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-bar"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-bar"}))
|
|
|
|
|
assert.Equal(t, "task: [gen-bar] touch bar.txt", strings.TrimSpace(buff.String()))
|
|
|
|
|
buff.Reset()
|
|
|
|
|
// all: up-to-date
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-bar"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-bar"}))
|
|
|
|
|
assert.Equal(t, `task: Task "gen-bar" is up to date`, strings.TrimSpace(buff.String()))
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// sources: not up-to-date, no output produced.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
assert.Empty(t, buff.String())
|
|
|
|
|
|
|
|
|
|
// up-to-date, no output produced
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
assert.Empty(t, buff.String())
|
|
|
|
|
|
|
|
|
|
e.Verbose = true
|
|
|
|
|
// up-to-date, output produced due to Verbose mode.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "gen-silent-baz"}))
|
|
|
|
|
assert.Equal(t, `task: Task "gen-silent-baz" is up to date`, strings.TrimSpace(buff.String()))
|
|
|
|
|
buff.Reset()
|
|
|
|
|
}
|
|
|
|
@ -330,13 +330,13 @@ func TestPrecondition(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// A precondition that has been met
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "foo"}))
|
|
|
|
|
if buff.String() != "" {
|
|
|
|
|
t.Errorf("Got Output when none was expected: %s", buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A precondition that was not met
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "impossible"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "impossible"}))
|
|
|
|
|
|
|
|
|
|
if buff.String() != "task: 1 != 0 obviously!\n" {
|
|
|
|
|
t.Errorf("Wrong output message: %s", buff.String())
|
|
|
|
@ -344,7 +344,7 @@ func TestPrecondition(t *testing.T) {
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// Calling a task with a precondition in a dependency fails the task
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "depends_on_impossible"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "depends_on_impossible"}))
|
|
|
|
|
|
|
|
|
|
if buff.String() != "task: 1 != 0 obviously!\n" {
|
|
|
|
|
t.Errorf("Wrong output message: %s", buff.String())
|
|
|
|
@ -352,7 +352,7 @@ func TestPrecondition(t *testing.T) {
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// Calling a task with a precondition in a cmd fails the task
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "executes_failing_task_as_cmd"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "executes_failing_task_as_cmd"}))
|
|
|
|
|
if buff.String() != "task: 1 != 0 obviously!\n" {
|
|
|
|
|
t.Errorf("Wrong output message: %s", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -393,7 +393,7 @@ func TestGenerates(t *testing.T) {
|
|
|
|
|
fmt.Sprintf("task: Task \"%s\" is up to date\n", theTask)
|
|
|
|
|
|
|
|
|
|
// Run task for the first time.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: theTask}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: theTask}))
|
|
|
|
|
|
|
|
|
|
if _, err := os.Stat(srcFile); err != nil {
|
|
|
|
|
t.Errorf("File should exist: %v", err)
|
|
|
|
@ -408,7 +408,7 @@ func TestGenerates(t *testing.T) {
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// Re-run task to ensure it's now found to be up-to-date.
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: theTask}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: theTask}))
|
|
|
|
|
if buff.String() != upToDate {
|
|
|
|
|
t.Errorf("Wrong output message: %s", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -446,7 +446,7 @@ func TestStatusChecksum(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: test.task}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: test.task}))
|
|
|
|
|
for _, f := range test.files {
|
|
|
|
|
_, err := os.Stat(filepathext.SmartJoin(dir, f))
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -459,7 +459,7 @@ func TestStatusChecksum(t *testing.T) {
|
|
|
|
|
time := s.ModTime()
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: test.task}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: test.task}))
|
|
|
|
|
assert.Equal(t, `task: Task "`+test.task+`" is up to date`+"\n", buff.String())
|
|
|
|
|
|
|
|
|
|
s, err = os.Stat(filepathext.SmartJoin(tempdir, "checksum/"+test.task))
|
|
|
|
@ -482,7 +482,7 @@ func TestAlias(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "f"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "f"}))
|
|
|
|
|
assert.Equal(t, string(data), buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -496,7 +496,7 @@ func TestDuplicateAlias(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "x"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "x"}))
|
|
|
|
|
assert.Equal(t, "", buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -514,7 +514,7 @@ func TestAliasSummary(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "f"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "f"}))
|
|
|
|
|
assert.Equal(t, string(data), buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -528,7 +528,7 @@ func TestLabelUpToDate(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "foo"}))
|
|
|
|
|
assert.Contains(t, buff.String(), "foobar")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -543,7 +543,7 @@ func TestLabelSummary(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "foo"}))
|
|
|
|
|
assert.Contains(t, buff.String(), "foobar")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -554,7 +554,7 @@ func TestLabelInStatus(t *testing.T) {
|
|
|
|
|
Dir: dir,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
err := e.Status(context.Background(), ast.Call{Task: "foo"})
|
|
|
|
|
err := e.Status(context.Background(), &ast.Call{Task: "foo"})
|
|
|
|
|
assert.ErrorContains(t, err, "foobar")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -568,7 +568,7 @@ func TestLabelWithVariableExpansion(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "foo"}))
|
|
|
|
|
assert.Contains(t, buff.String(), "foobaz")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -582,7 +582,7 @@ func TestLabelInSummary(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "foo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "foo"}))
|
|
|
|
|
assert.Contains(t, buff.String(), "foobar")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -618,7 +618,7 @@ func TestPromptInSummary(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "foo"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "foo"})
|
|
|
|
|
|
|
|
|
|
if test.wantError {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
@ -646,7 +646,7 @@ func TestPromptWithIndirectTask(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "bar"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "bar"})
|
|
|
|
|
assert.Contains(t, outBuff.String(), "show-prompt")
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
}
|
|
|
|
@ -679,7 +679,7 @@ func TestPromptAssumeYes(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "foo"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "foo"})
|
|
|
|
|
|
|
|
|
|
if !test.assumeYes {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
@ -791,7 +791,7 @@ func TestStatusVariables(t *testing.T) {
|
|
|
|
|
Verbose: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "build"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "build"}))
|
|
|
|
|
|
|
|
|
|
assert.Contains(t, buff.String(), "3e464c4b03f4b65d740e1e130d4d108a")
|
|
|
|
|
|
|
|
|
@ -832,7 +832,7 @@ func TestCyclicDep(t *testing.T) {
|
|
|
|
|
Stderr: io.Discard,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
assert.IsType(t, &errors.TaskCalledTooManyTimesError{}, e.Run(context.Background(), ast.Call{Task: "task-1"}))
|
|
|
|
|
assert.IsType(t, &errors.TaskCalledTooManyTimesError{}, e.Run(context.Background(), &ast.Call{Task: "task-1"}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTaskVersion(t *testing.T) {
|
|
|
|
@ -875,10 +875,10 @@ func TestTaskIgnoreErrors(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "task-should-pass"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "task-should-fail"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "cmd-should-pass"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "cmd-should-fail"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "task-should-pass"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "task-should-fail"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "cmd-should-pass"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "cmd-should-fail"}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestExpand(t *testing.T) {
|
|
|
|
@ -896,7 +896,7 @@ func TestExpand(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "pwd"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "pwd"}))
|
|
|
|
|
assert.Equal(t, home, strings.TrimSpace(buff.String()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -915,7 +915,7 @@ func TestDry(t *testing.T) {
|
|
|
|
|
Dry: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "build"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "build"}))
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "task: [build] touch file.txt", strings.TrimSpace(buff.String()))
|
|
|
|
|
if _, err := os.Stat(file); err == nil {
|
|
|
|
@ -939,13 +939,13 @@ func TestDryChecksum(t *testing.T) {
|
|
|
|
|
Dry: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
|
|
|
|
|
_, err := os.Stat(checksumFile)
|
|
|
|
|
require.Error(t, err, "checksum file should not exist")
|
|
|
|
|
|
|
|
|
|
e.Dry = false
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
_, err = os.Stat(checksumFile)
|
|
|
|
|
require.NoError(t, err, "checksum file should exist")
|
|
|
|
|
}
|
|
|
|
@ -1127,11 +1127,11 @@ func TestIncludesRelativePath(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "common:pwd"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "common:pwd"}))
|
|
|
|
|
assert.Contains(t, buff.String(), "testdata/includes_rel_path/common")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "included:common:pwd"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "included:common:pwd"}))
|
|
|
|
|
assert.Contains(t, buff.String(), "testdata/includes_rel_path/common")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1159,7 +1159,7 @@ func TestIncludesInternal(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: test.task})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: test.task})
|
|
|
|
|
if test.expectedErr {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
} else {
|
|
|
|
@ -1193,7 +1193,7 @@ func TestIncludesInterpolation(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: test.task})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: test.task})
|
|
|
|
|
if test.expectedErr {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
} else {
|
|
|
|
@ -1228,7 +1228,7 @@ func TestInternalTask(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: test.task})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: test.task})
|
|
|
|
|
if test.expectedErr {
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
} else {
|
|
|
|
@ -1297,7 +1297,7 @@ func TestSummary(t *testing.T) {
|
|
|
|
|
Silent: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "task-with-summary"}, ast.Call{Task: "other-task-with-summary"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "task-with-summary"}, &ast.Call{Task: "other-task-with-summary"}))
|
|
|
|
|
|
|
|
|
|
data, err := os.ReadFile(filepathext.SmartJoin(dir, "task-with-summary.txt"))
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@ -1321,7 +1321,7 @@ func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "whereami"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "whereami"}))
|
|
|
|
|
|
|
|
|
|
// got should be the "dir" part of "testdata/dir"
|
|
|
|
|
got := strings.TrimSuffix(filepath.Base(out.String()), "\n")
|
|
|
|
@ -1339,7 +1339,7 @@ func TestWhenDirAttributeAndDirExistsItRunsInThatDir(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "whereami"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "whereami"}))
|
|
|
|
|
|
|
|
|
|
got := strings.TrimSuffix(filepath.Base(out.String()), "\n")
|
|
|
|
|
assert.Equal(t, expected, got, "Mismatch in the working directory")
|
|
|
|
@ -1363,7 +1363,7 @@ func TestWhenDirAttributeItCreatesMissingAndRunsInThatDir(t *testing.T) {
|
|
|
|
|
t.Errorf("Directory should not exist: %v", err)
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: target}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: target}))
|
|
|
|
|
|
|
|
|
|
got := strings.TrimSuffix(filepath.Base(out.String()), "\n")
|
|
|
|
|
assert.Equal(t, expected, got, "Mismatch in the working directory")
|
|
|
|
@ -1390,7 +1390,7 @@ func TestDynamicVariablesRunOnTheNewCreatedDir(t *testing.T) {
|
|
|
|
|
t.Errorf("Directory should not exist: %v", err)
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: target}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: target}))
|
|
|
|
|
|
|
|
|
|
got := strings.TrimSuffix(filepath.Base(out.String()), "\n")
|
|
|
|
|
assert.Equal(t, expected, got, "Mismatch in the working directory")
|
|
|
|
@ -1448,7 +1448,7 @@ func TestShortTaskNotation(t *testing.T) {
|
|
|
|
|
Silent: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
assert.Equal(t, "string-slice-1\nstring-slice-2\nstring\n", buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1592,7 +1592,7 @@ func TestExitImmediately(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
assert.Contains(t, buff.String(), `"this_should_fail": executable file not found in $PATH`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1628,7 +1628,7 @@ echo ran
|
|
|
|
|
task: [task-1] echo 'task-1 ran successfully'
|
|
|
|
|
task-1 ran successfully
|
|
|
|
|
`)
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "task-2"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "task-2"}))
|
|
|
|
|
assert.Contains(t, buff.String(), expectedOutputOrder)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1653,7 +1653,7 @@ func TestIgnoreNilElements(t *testing.T) {
|
|
|
|
|
Silent: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
assert.Equal(t, "string-slice-1\n", buff.String())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -1679,7 +1679,7 @@ task: [bye] echo 'Bye!'
|
|
|
|
|
Bye!
|
|
|
|
|
::endgroup::
|
|
|
|
|
`)
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "bye"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "bye"}))
|
|
|
|
|
t.Log(buff.String())
|
|
|
|
|
assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder)
|
|
|
|
|
}
|
|
|
|
@ -1694,7 +1694,7 @@ func TestOutputGroupErrorOnlySwallowsOutputOnSuccess(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "passing"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "passing"}))
|
|
|
|
|
t.Log(buff.String())
|
|
|
|
|
assert.Empty(t, buff.String())
|
|
|
|
|
}
|
|
|
|
@ -1709,7 +1709,7 @@ func TestOutputGroupErrorOnlyShowsOutputOnFailure(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
require.Error(t, e.Run(context.Background(), ast.Call{Task: "failing"}))
|
|
|
|
|
require.Error(t, e.Run(context.Background(), &ast.Call{Task: "failing"}))
|
|
|
|
|
t.Log(buff.String())
|
|
|
|
|
assert.Contains(t, "failing-output", strings.TrimSpace(buff.String()))
|
|
|
|
|
assert.NotContains(t, "passing", strings.TrimSpace(buff.String()))
|
|
|
|
@ -1739,7 +1739,7 @@ VAR_1 is included-default-var1
|
|
|
|
|
task: [included3:task1] echo "VAR_2 is included-default-var2"
|
|
|
|
|
VAR_2 is included-default-var2
|
|
|
|
|
`)
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "task1"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "task1"}))
|
|
|
|
|
t.Log(buff.String())
|
|
|
|
|
assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder)
|
|
|
|
|
}
|
|
|
|
@ -1762,7 +1762,7 @@ Hello foo
|
|
|
|
|
task: [bar:lib:greet] echo 'Hello bar'
|
|
|
|
|
Hello bar
|
|
|
|
|
`)
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
t.Log(buff.String())
|
|
|
|
|
assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder)
|
|
|
|
|
}
|
|
|
|
@ -1795,7 +1795,7 @@ func TestErrorCode(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: test.task})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: test.task})
|
|
|
|
|
require.Error(t, err)
|
|
|
|
|
taskRunErr, ok := err.(*errors.TaskRunError)
|
|
|
|
|
assert.True(t, ok, "cannot cast returned error to *task.TaskRunError")
|
|
|
|
@ -1847,7 +1847,7 @@ func TestEvaluateSymlinksInPaths(t *testing.T) {
|
|
|
|
|
for _, test := range tests {
|
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: test.task})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: test.task})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, test.expected, strings.TrimSpace(buff.String()))
|
|
|
|
|
buff.Reset()
|
|
|
|
@ -1886,7 +1886,7 @@ func TestTaskfileWalk(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
assert.Equal(t, test.expected, buff.String())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -1902,7 +1902,7 @@ func TestUserWorkingDirectory(t *testing.T) {
|
|
|
|
|
wd, err := os.Getwd()
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "default"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
|
|
|
|
|
assert.Equal(t, fmt.Sprintf("%s\n", wd), buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1922,7 +1922,7 @@ func TestUserWorkingDirectoryWithIncluded(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "included:echo"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "included:echo"}))
|
|
|
|
|
assert.Equal(t, fmt.Sprintf("%s\n", wd), buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1934,7 +1934,7 @@ func TestPlatforms(t *testing.T) {
|
|
|
|
|
Stderr: &buff,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "build-" + runtime.GOOS}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "build-" + runtime.GOOS}))
|
|
|
|
|
assert.Equal(t, fmt.Sprintf("task: [build-%s] echo 'Running task on %s'\nRunning task on %s\n", runtime.GOOS, runtime.GOOS, runtime.GOOS), buff.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1947,7 +1947,7 @@ func TestPOSIXShellOptsGlobalLevel(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "pipefail"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "pipefail"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "pipefail\ton\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -1961,7 +1961,7 @@ func TestPOSIXShellOptsTaskLevel(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "pipefail"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "pipefail"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "pipefail\ton\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -1975,7 +1975,7 @@ func TestPOSIXShellOptsCommandLevel(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "pipefail"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "pipefail"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "pipefail\ton\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -1989,7 +1989,7 @@ func TestBashShellOptsGlobalLevel(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "globstar"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "globstar"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "globstar\ton\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -2003,7 +2003,7 @@ func TestBashShellOptsTaskLevel(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "globstar"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "globstar"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "globstar\ton\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -2017,7 +2017,7 @@ func TestBashShellOptsCommandLevel(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "globstar"})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "globstar"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "globstar\ton\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -2035,7 +2035,7 @@ func TestSplitArgs(t *testing.T) {
|
|
|
|
|
vars := &ast.Vars{}
|
|
|
|
|
vars.Set("CLI_ARGS", ast.Var{Value: "foo bar 'foo bar baz'"})
|
|
|
|
|
|
|
|
|
|
err := e.Run(context.Background(), ast.Call{Task: "default", Vars: vars})
|
|
|
|
|
err := e.Run(context.Background(), &ast.Call{Task: "default", Vars: vars})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
assert.Equal(t, "3\n", buff.String())
|
|
|
|
|
}
|
|
|
|
@ -2063,20 +2063,20 @@ func TestSilence(t *testing.T) {
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
|
|
|
|
|
// First verify that the silent flag is in place.
|
|
|
|
|
task, err := e.GetTask(ast.Call{Task: "task-test-silent-calls-chatty-silenced"})
|
|
|
|
|
task, err := e.GetTask(&ast.Call{Task: "task-test-silent-calls-chatty-silenced"})
|
|
|
|
|
require.NoError(t, err, "Unable to look up task task-test-silent-calls-chatty-silenced")
|
|
|
|
|
require.True(t, task.Cmds[0].Silent, "The task task-test-silent-calls-chatty-silenced should have a silent call to chatty")
|
|
|
|
|
|
|
|
|
|
// Then test the two basic cases where the task is silent or not.
|
|
|
|
|
// A silenced task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "silent"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "silent"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Empty(t, buff.String(), "siWhile running lent: Expected not see output, because the task is silent")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A chatty (not silent) task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "chatty"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "chatty"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotEmpty(t, buff.String(), "chWhile running atty: Expected to see output, because the task is not silent")
|
|
|
|
|
|
|
|
|
@ -2084,42 +2084,42 @@ func TestSilence(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Then test invoking the two task from other tasks.
|
|
|
|
|
// A silenced task that calls a chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-silent-calls-chatty-non-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-silent-calls-chatty-non-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotEmpty(t, buff.String(), "While running task-test-silent-calls-chatty-non-silenced: Expected to see output. The task is silenced, but the called task is not. Silence does not propagate to called tasks.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A silent task that does a silent call to a chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-silent-calls-chatty-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-silent-calls-chatty-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Empty(t, buff.String(), "While running task-test-silent-calls-chatty-silenced: Expected not to see output. The task calls chatty task, but the call is silenced.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A chatty task that does a call to a chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-chatty-calls-chatty-non-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-chatty-calls-chatty-non-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotEmpty(t, buff.String(), "While running task-test-chatty-calls-chatty-non-silenced: Expected to see output. Both caller and callee are chatty and not silenced.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A chatty task that does a silenced call to a chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-chatty-calls-chatty-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-chatty-calls-chatty-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotEmpty(t, buff.String(), "While running task-test-chatty-calls-chatty-silenced: Expected to see output. Call to a chatty task is silenced, but the parent task is not.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A chatty task with no cmd's of its own that does a silenced call to a chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-no-cmds-calls-chatty-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-no-cmds-calls-chatty-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Empty(t, buff.String(), "While running task-test-no-cmds-calls-chatty-silenced: Expected not to see output. While the task itself is not silenced, it does not have any cmds and only does an invocation of a silenced task.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A chatty task that does a silenced invocation of a task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-chatty-calls-silenced-cmd"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-chatty-calls-silenced-cmd"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Empty(t, buff.String(), "While running task-test-chatty-calls-silenced-cmd: Expected not to see output. While the task itself is not silenced, its call to the chatty task is silent.")
|
|
|
|
|
|
|
|
|
@ -2127,21 +2127,21 @@ func TestSilence(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Then test calls via dependencies.
|
|
|
|
|
// A silent task that depends on a chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-is-silent-depends-on-chatty-non-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-is-silent-depends-on-chatty-non-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NotEmpty(t, buff.String(), "While running task-test-is-silent-depends-on-chatty-non-silenced: Expected to see output. The task is silent and depends on a chatty task. Dependencies does not inherit silence.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A silent task that depends on a silenced chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-is-silent-depends-on-chatty-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-is-silent-depends-on-chatty-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Empty(t, buff.String(), "While running task-test-is-silent-depends-on-chatty-silenced: Expected not to see output. The task is silent and has a silenced dependency on a chatty task.")
|
|
|
|
|
|
|
|
|
|
buff.Reset()
|
|
|
|
|
|
|
|
|
|
// A chatty task that, depends on a silenced chatty task.
|
|
|
|
|
err = e.Run(context.Background(), ast.Call{Task: "task-test-is-chatty-depends-on-chatty-silenced"})
|
|
|
|
|
err = e.Run(context.Background(), &ast.Call{Task: "task-test-is-chatty-depends-on-chatty-silenced"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Empty(t, buff.String(), "While running task-test-is-chatty-depends-on-chatty-silenced: Expected not to see output. The task is chatty but does not have commands and has a silenced dependency on a chatty task.")
|
|
|
|
|
|
|
|
|
@ -2189,7 +2189,7 @@ func TestForce(t *testing.T) {
|
|
|
|
|
ForceAll: tt.forceAll,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: "task-with-dep"}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "task-with-dep"}))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2244,7 +2244,7 @@ func TestFor(t *testing.T) {
|
|
|
|
|
Force: true,
|
|
|
|
|
}
|
|
|
|
|
require.NoError(t, e.Setup())
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), ast.Call{Task: test.name}))
|
|
|
|
|
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: test.name}))
|
|
|
|
|
assert.Equal(t, test.expectedOutput, buff.String())
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|