-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
70875: dev: refactor `setupPath` test in `dev` r=rail a=rickystewart We used to run this on every single test case in `dev`, which would require copy-pasting a bunch of boilerplate every time you add a test case. Instead refactor the `setupPath` test out on its own and test it just once. Release note: None Co-authored-by: Ricky Stewart <ricky@cockroachlabs.com>
- Loading branch information
Showing
15 changed files
with
66 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package main | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"log" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/cmd/dev/io/exec" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/dev/io/os" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/dev/recording" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func init() { | ||
isTesting = true | ||
} | ||
|
||
func TestSetupPath(t *testing.T) { | ||
rec := `getenv PATH | ||
---- | ||
/usr/local/opt/ccache/libexec:/usr/local/opt/make/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin | ||
which cc | ||
---- | ||
/usr/local/opt/ccache/libexec/cc | ||
readlink /usr/local/opt/ccache/libexec/cc | ||
---- | ||
../bin/ccache | ||
export PATH=/usr/local/opt/make/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin | ||
---- | ||
` | ||
r := recording.WithReplayFrom(strings.NewReader(rec), "TestSetupPath") | ||
var logger io.ReadWriter = bytes.NewBufferString("") | ||
var exopts []exec.Option | ||
exopts = append(exopts, exec.WithRecording(r)) | ||
exopts = append(exopts, exec.WithLogger(log.New(logger, "", 0))) | ||
var osopts []os.Option | ||
osopts = append(osopts, os.WithRecording(r)) | ||
osopts = append(osopts, os.WithLogger(log.New(logger, "", 0))) | ||
devExec := exec.New(exopts...) | ||
devOS := os.New(osopts...) | ||
dev := makeDevCmd() | ||
dev.exec = devExec | ||
dev.os = devOS | ||
|
||
require.NoError(t, setupPath(dev)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
dev bench pkg/util/... | ||
---- | ||
getenv PATH | ||
which cc | ||
readlink /usr/local/opt/ccache/libexec/cc | ||
export PATH=/usr/local/opt/make/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin | ||
git grep -l ^func Benchmark -- pkg/util/*_test.go | ||
bazel run --config=test --test_sharding_strategy=disabled //pkg/util:util_test -- -test.run=- -test.bench=. | ||
bazel run --config=test --test_sharding_strategy=disabled //pkg/util/uuid:uuid_test -- -test.run=- -test.bench=. | ||
|
||
dev bench pkg/sql/parser --filter=BenchmarkParse | ||
---- | ||
getenv PATH | ||
which cc | ||
readlink /usr/local/opt/ccache/libexec/cc | ||
export PATH=/usr/local/opt/make/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin | ||
bazel run --config=test --test_sharding_strategy=disabled //pkg/sql/parser:parser_test -- -test.run=- -test.bench=BenchmarkParse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
dev lint | ||
---- | ||
getenv PATH | ||
which cc | ||
readlink /usr/local/opt/ccache/libexec/cc | ||
export PATH=/usr/local/opt/make/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin | ||
bazel run --config=test //build/bazelutil:lint -- -test.v | ||
|
||
dev lint --short --timeout=5m | ||
---- | ||
getenv PATH | ||
which cc | ||
readlink /usr/local/opt/ccache/libexec/cc | ||
export PATH=/usr/local/opt/make/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin | ||
bazel run --config=test //build/bazelutil:lint -- -test.v -test.short -test.timeout 5m0s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.