From 7340d15c85ed2412a29e08001d343df7aa53d0df Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 6 Jan 2020 15:06:10 -0500 Subject: [PATCH] cmd/go: convert TestImportCycle to the script framework This test already calls tg.Parallel Part of converting all tests to script framework to improve test parallelism. Updates #36320 Updates #17751 Change-Id: I4cdb2464cd3e51f1369558c238925f036ce8d828 Reviewed-on: https://go-review.googlesource.com/c/go/+/213426 Run-TryBot: Michael Matloob Reviewed-by: Jay Conrod --- src/cmd/go/go_test.go | 19 ------------------- .../importcycle/src/selfimport/selfimport.go | 3 --- .../go/testdata/script/build_import_cycle.txt | 10 ++++++++++ 3 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 src/cmd/go/testdata/importcycle/src/selfimport/selfimport.go create mode 100644 src/cmd/go/testdata/script/build_import_cycle.txt diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 76566f3c3a8..014af70e830 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1072,25 +1072,6 @@ func TestImportCommentConflict(t *testing.T) { tg.grepStderr("found import comments", "go build did not mention comment conflict") } -func TestImportCycle(t *testing.T) { - tg := testgo(t) - defer tg.cleanup() - tg.parallel() - tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/importcycle")) - tg.runFail("build", "selfimport") - - count := tg.grepCountBoth("import cycle not allowed") - if count == 0 { - t.Fatal("go build did not mention cyclical import") - } - if count > 1 { - t.Fatal("go build mentioned import cycle more than once") - } - - // Don't hang forever. - tg.run("list", "-e", "-json", "selfimport") -} - // cmd/go: custom import path checking should not apply to Go packages without import comment. func TestIssue10952(t *testing.T) { testenv.MustHaveExternalNetwork(t) diff --git a/src/cmd/go/testdata/importcycle/src/selfimport/selfimport.go b/src/cmd/go/testdata/importcycle/src/selfimport/selfimport.go deleted file mode 100644 index dc63c4b9f29..00000000000 --- a/src/cmd/go/testdata/importcycle/src/selfimport/selfimport.go +++ /dev/null @@ -1,3 +0,0 @@ -package selfimport - -import "selfimport" diff --git a/src/cmd/go/testdata/script/build_import_cycle.txt b/src/cmd/go/testdata/script/build_import_cycle.txt new file mode 100644 index 00000000000..0154305c275 --- /dev/null +++ b/src/cmd/go/testdata/script/build_import_cycle.txt @@ -0,0 +1,10 @@ +! go build selfimport +stderr -count=1 'import cycle not allowed' + +go list -e -f '{{.Error}}' selfimport # Don't hang forever +stdout -count=1 'import cycle not allowed' + +-- selfimport/selfimport.go -- +package selfimport + +import "selfimport"