From e7bc3b3ad66813e6a7a00cc5422576675d0e6b3b Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Mon, 6 Jun 2022 11:26:31 -0500 Subject: [PATCH] dev: allow `--rewrite` when testing many targets with `/...` Closes #82053. Release note: None --- pkg/cmd/dev/test.go | 5 ++++- pkg/cmd/dev/testdata/datadriven/test | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/dev/test.go b/pkg/cmd/dev/test.go index 9059cf577038..f846f07d7ef0 100644 --- a/pkg/cmd/dev/test.go +++ b/pkg/cmd/dev/test.go @@ -156,7 +156,7 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error { } var target string - if strings.Contains(pkg, ":") { + if strings.Contains(pkg, ":") || strings.HasSuffix(pkg, "/...") { // For parity with bazel, we allow specifying named build targets. target = pkg } else { @@ -336,6 +336,9 @@ func (d *dev) getStressArgs(stressCmdArg string, timeout time.Duration) []string func getDirectoryFromTarget(target string) string { target = strings.TrimPrefix(target, "//") + if strings.HasSuffix(target, "/...") { + return strings.TrimSuffix(target, "/...") + } colon := strings.LastIndex(target, ":") if colon < 0 { return target diff --git a/pkg/cmd/dev/testdata/datadriven/test b/pkg/cmd/dev/testdata/datadriven/test index 4e620998e0bd..d6b85f800507 100644 --- a/pkg/cmd/dev/testdata/datadriven/test +++ b/pkg/cmd/dev/testdata/datadriven/test @@ -6,7 +6,7 @@ bazel test pkg/util/tracing:all --test_env=GOTRACEBACK=all --test_output errors exec dev test pkg/util/tracing/... ---- -bazel test pkg/util/tracing/...:all --test_env=GOTRACEBACK=all --test_output errors +bazel test pkg/util/tracing/... --test_env=GOTRACEBACK=all --test_output errors exec dev test pkg/util/tracing -f TestStartChild* @@ -114,7 +114,7 @@ bazel test //pkg:all_tests --test_env=GOTRACEBACK=all --test_output errors exec dev test pkg/spanconfig/... pkg/ccl/spanconfigccl/... ---- -bazel test pkg/spanconfig/...:all pkg/ccl/spanconfigccl/...:all --test_env=GOTRACEBACK=all --test_output errors +bazel test pkg/spanconfig/... pkg/ccl/spanconfigccl/... --test_env=GOTRACEBACK=all --test_output errors exec dev test pkg/sql/schemachanger --rewrite -v @@ -127,3 +127,9 @@ dev test pkg/sql/opt/xform --rewrite ---- bazel info workspace --color=no bazel test pkg/sql/opt/xform:all --nocache_test_results --test_env=GOTRACEBACK=all --test_env=COCKROACH_WORKSPACE=crdb-checkout --test_arg -rewrite --sandbox_writable_path=crdb-checkout/pkg/sql/opt/xform --sandbox_writable_path=crdb-checkout/pkg/sql/opt/testutils/opttester/testfixtures --test_sharding_strategy=disabled --test_output errors + +exec +dev test pkg/sql/... --rewrite +---- +bazel info workspace --color=no +bazel test pkg/sql/... --nocache_test_results --test_env=GOTRACEBACK=all --test_env=COCKROACH_WORKSPACE=crdb-checkout --test_arg -rewrite --sandbox_writable_path=crdb-checkout/pkg/sql --test_sharding_strategy=disabled --test_output errors