Skip to content

Commit

Permalink
dev: fix --rewrite for logictestccl
Browse files Browse the repository at this point in the history
Fixes #76513. The ccl logictest target shares the testdata directory
with the base logictest target. Since dev's --rewrite only makes an
allowance for the testdata/ directory under the package being tested,
this didn't work. This PR accommodates the one test target where
testdata/ is being used from elsewhere.

Release justification: non-production code change
Release note: None
  • Loading branch information
irfansharif committed Mar 11, 2022
1 parent 1477693 commit c1f2877
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=21
DEV_VERSION=22

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/dev/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const (
// DataDriven divvies up these files as subtests, so individual "files" are
// runnable through:
//
// dev test pkg/cmd/dev -f TestDataDrivenDriven/<fname> [--rewrite]
// OR go test ./pkg/cmd/dev -run TestDataDrivenDriven/<fname> [-rewrite]
// dev test pkg/cmd/dev -f TestDataDriven/<fname> [--rewrite]
// OR go test ./pkg/cmd/dev -run TestDataDriven/<fname> [-rewrite]
//
// NB: See commentary on TestRecorderDriven to see how they compare.
// TestDataDriven is well suited for exercising flows that don't depend on
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/dev/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ func (d *dev) test(cmd *cobra.Command, commandLine []string) error {
for _, testTarget := range testTargets {
dir := getDirectoryFromTarget(testTarget)
args = append(args, fmt.Sprintf("--sandbox_writable_path=%s", filepath.Join(workspace, dir)))
if strings.Contains(testTarget, "pkg/ccl/logictestccl") {
// The ccl logictest target shares the testdata directory with the base
// logictest target -- make an allowance explicitly for that.
args = append(args, fmt.Sprintf("--sandbox_writable_path=%s",
filepath.Join(workspace, "pkg/sql/logictest")))
}
}
}
if timeout > 0 && !stress {
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/dev/testdata/datadriven/test
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ dev test pkg/kv/kvserver -f TestStoreRangeSplitMergeGeneration --test-args '-tes
----
bazel info workspace --color=no
bazel test pkg/kv/kvserver:all --test_env=GOTRACEBACK=all --test_filter=TestStoreRangeSplitMergeGeneration --test_sharding_strategy=disabled --test_arg -test.outputdir=crdb-checkout --sandbox_writable_path=crdb-checkout --test_arg -test.memprofile=mem.out --test_output errors

exec
dev test pkg/ccl/logictestccl -f=TestTenantLogic/3node-tenant/system -v --rewrite
----
bazel info workspace --color=no
bazel test pkg/ccl/logictestccl:all --test_env=GOTRACEBACK=all --test_env=COCKROACH_WORKSPACE=crdb-checkout --test_arg -rewrite --sandbox_writable_path=crdb-checkout/pkg/ccl/logictestccl --sandbox_writable_path=crdb-checkout/pkg/sql/logictest --test_filter=TestTenantLogic/3node-tenant/system --test_sharding_strategy=disabled --test_arg -test.v --test_output all
6 changes: 6 additions & 0 deletions pkg/cmd/dev/testdata/datadriven/testlogic
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ exec
dev testlogic base --files=auto_span_config_reconciliation --stress --timeout 1m --cpus 8
----
bazel test --test_env=GOTRACEBACK=all --local_cpu_resources=8 --test_arg -show-sql --test_sharding_strategy=disabled --test_timeout=120 --run_under '@com_github_cockroachdb_stress//:stress -bazel -shardable-artifacts '"'"'XML_OUTPUT_FILE=dev merge-test-xmls'"'"' -maxtime=1m0s -p=8' //pkg/sql/logictest:logictest_test --test_filter 'TestLogic//^auto_span_config_reconciliation$/' --test_output streamed

exec
dev testlogic ccl --rewrite --show-logs -v --files distsql_automatic_stats --config 3node-tenant
----
bazel info workspace --color=no
bazel test --test_env=GOTRACEBACK=all --test_arg -test.v --test_arg -show-logs --test_arg -show-sql --test_arg -config --test_arg 3node-tenant --test_env=COCKROACH_WORKSPACE=crdb-checkout --test_arg -rewrite --sandbox_writable_path=crdb-checkout/pkg/ccl/logictestccl --sandbox_writable_path=crdb-checkout/pkg/sql/logictest //pkg/ccl/logictestccl:logictestccl_test --test_filter 'Test(CCL|Tenant)Logic/^3node-tenant$/^distsql_automatic_stats$/' --test_output all
6 changes: 6 additions & 0 deletions pkg/cmd/dev/testlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ func (d *dev) testlogic(cmd *cobra.Command, commandLine []string) error {

dir := getDirectoryFromTarget(testTarget)
args = append(args, fmt.Sprintf("--sandbox_writable_path=%s", filepath.Join(workspace, dir)))
if choice == "ccl" {
// The ccl logictest target shares the testdata directory with the base
// logictest target -- make an allowance explicitly for that.
args = append(args, fmt.Sprintf("--sandbox_writable_path=%s",
filepath.Join(workspace, "pkg/sql/logictest")))
}
}
if timeout > 0 && !stress {
args = append(args, fmt.Sprintf("--test_timeout=%d", int(timeout.Seconds())))
Expand Down

0 comments on commit c1f2877

Please sign in to comment.