From 60fc5242023ac6bb4cc1c4fd311ae0011dcf7bc6 Mon Sep 17 00:00:00 2001 From: Liam Gillies Date: Tue, 22 Aug 2023 16:53:17 -0400 Subject: [PATCH] dev: warn when trying to `dev test` a bazel tested target Running `dev test` on these integration tests will always fail, so this PR adds a warning when running the command on those files. Fixes: #107813 Release note: None --- pkg/cmd/dev/test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/cmd/dev/test.go b/pkg/cmd/dev/test.go index f11e62629d53..a4d38ffb9b71 100644 --- a/pkg/cmd/dev/test.go +++ b/pkg/cmd/dev/test.go @@ -257,6 +257,26 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { testTargets = append(testTargets, target) } + // List of bazel integration tests that will fail when running `dev test pkg/...` + var integrationTests = map[string][2]string{ + "pkg/acceptance": {"acceptance_test", "`dev acceptance`"}, + "pkg/compose": {"compose_test", "`dev compose`"}, + "pkg/compose/compare/compare": {"compare_test", "`dev compose`"}, + "pkg/testutils/docker": {"docker_test", "N/A: docker_test has no dev command corresponding to it"}, + "pkg/testutils/lint": {"lint_test", "`dev lint`"}, + } + + for _, target := range testTargets { + testTarget := strings.Split(target, ":") + arr, ok := integrationTests[testTarget[0]] + if ok { + // If the test targets all tests in the package or the individual test, warn the user + if testTarget[1] == "all" || testTarget[1] == arr[0] { + return fmt.Errorf("%s:%s will fail since it is an integration test.\n To run this test, run %s", testTarget[0], arr[0], arr[1]) + } + } + } + args = append(args, testTargets...) if ignoreCache { args = append(args, "--nocache_test_results")