From cdbb742496ec6535250bfc1dd195d00a2d2f10a1 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 6 May 2019 16:29:35 +0200 Subject: [PATCH] add more cancellation tests --- command/build_cancellation_test.go | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/command/build_cancellation_test.go b/command/build_cancellation_test.go index da8fd7838..f1a5959db 100644 --- a/command/build_cancellation_test.go +++ b/command/build_cancellation_test.go @@ -27,26 +27,26 @@ func TestBuildCommand_RunContext_CtxCancel(t *testing.T) { 4, 1, }, - // {"cancel 1 locked build - debug - parallel=true", - // []string{"-parallel=true", "-debug=true", filepath.Join(testFixture("parallel"), "1lock.json")}, - // 5, - // 1, - // }, - // {"cancel 2 locked builds - debug - parallel=true", - // []string{"-parallel=true", "-debug=true", filepath.Join(testFixture("parallel"), "2lock.json")}, - // 4, - // 1, - // }, - // {"cancel 1 locked build - debug - parallel=false", - // []string{"-parallel=false", "-debug=true", filepath.Join(testFixture("parallel"), "1lock.json")}, - // 5, - // 1, - // }, - // {"cancel 2 locked builds - debug - parallel=false", - // []string{"-parallel=false", "-debug=true", filepath.Join(testFixture("parallel"), "2lock.json")}, - // 4, - // 1, - // }, + {"cancel 1 locked build - debug - parallel=true", + []string{"-parallel=true", "-debug=true", filepath.Join(testFixture("parallel"), "1lock.json")}, + 0, + 1, + }, + {"cancel 2 locked builds - debug - parallel=true", + []string{"-parallel=true", "-debug=true", filepath.Join(testFixture("parallel"), "2lock.json")}, + 0, + 1, + }, + {"cancel 1 locked build - debug - parallel=false", + []string{"-parallel=false", "-debug=true", filepath.Join(testFixture("parallel"), "1lock.json")}, + 0, + 1, + }, + {"cancel 2 locked builds - debug - parallel=false", + []string{"-parallel=false", "-debug=true", filepath.Join(testFixture("parallel"), "2lock.json")}, + 0, + 1, + }, } for _, tt := range tests { @@ -64,7 +64,9 @@ func TestBuildCommand_RunContext_CtxCancel(t *testing.T) { defer close(codeC) codeC <- c.RunContext(ctx, tt.args) }() + t.Logf("waiting for passing tests if any") b.wg.Wait() // ran `tt.parallelPassingTests` times + t.Logf("cancelling context") cancelCtx() select {