MCPcopy Create free account
hub / github.com/go-task/task / TestDeferredCmds

Function TestDeferredCmds

task_test.go:2253–2281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2251}
2252
2253func TestDeferredCmds(t *testing.T) {
2254 t.Parallel()
2255
2256 const dir = "testdata/deferred"
2257 var buff bytes.Buffer
2258 e := task.NewExecutor(
2259 task.WithDir(dir),
2260 task.WithStdout(&buff),
2261 task.WithStderr(&buff),
2262 )
2263 require.NoError(t, e.Setup())
2264
2265 expectedOutputOrder := strings.TrimSpace(`
2266task: [task-2] echo 'cmd ran'
2267cmd ran
2268task: [task-2] exit 1
2269task: [task-2] echo 'failing' && exit 2
2270failing
2271echo ran
2272task-1 ran successfully
2273task: [task-1] echo 'task-1 ran successfully'
2274task-1 ran successfully
2275`)
2276 require.Error(t, e.Run(t.Context(), &task.Call{Task: "task-2"}))
2277 assert.Contains(t, buff.String(), expectedOutputOrder)
2278 buff.Reset()
2279 require.NoError(t, e.Run(t.Context(), &task.Call{Task: "parent"}))
2280 assert.Contains(t, buff.String(), "child task deferred value-from-parent")
2281}
2282
2283func TestExitCodeZero(t *testing.T) {
2284 t.Parallel()

Callers

nothing calls this directly

Calls 4

SetupMethod · 0.95
RunMethod · 0.95
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…