Skip to content

Commit e3ce204

Browse files
committed
*,bazel: support dev test pkg/{...} expansion
Discovered these while trying to flesh out cockroachdb/dev#4. We're doing a few things in this commit: - Exclude the testdata dir under pkg/testutils from gazelle/bazel consideration - Fix a few incorrect package resolutions (they were pointing to testdata paths previously). Combining this with cockroachdb/dev#4, now we can use `go test` style "..." expansion in `dev`[*]: dev test pkg/util/... [*]: Though failing tests that are broken under Bazel. Release note: None
1 parent 988e457 commit e3ce204

File tree

17 files changed

+27
-198
lines changed

17 files changed

+27
-198
lines changed

BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
4545
# - The artifacts directory.
4646
# - All checked-in autogenerated files (they'll get autogenerated on the fly
4747
# through bazel).
48-
# - A testdata "repo" that looks like a go package, but isn't
48+
# - testdata packages that looks like go packages, but aren't
4949
# (testdata/src/example.com).
5050
# - A few auto-generated sql parser files.
5151
# - Stringer files auto-generated with "go:generate stringer".
@@ -68,6 +68,7 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
6868
# gazelle:exclude pkg/sql/lexbase/reserved_keywords.go
6969
# gazelle:exclude pkg/sql/opt/rule_name_string.go
7070
# gazelle:exclude pkg/cmd/prereqs/testdata
71+
# gazelle:exclude pkg/testutils/**/testdata/**
7172
# gazelle:exclude vendor
7273
# gazelle:exclude pkg/kv/kvclient/kvcoord/txnstate_string.go
7374
# gazelle:exclude pkg/kv/kvserver/refreshraftreason_string.go

DEPS.bzl

Lines changed: 15 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -234,27 +234,7 @@ def go_deps():
234234
sum = "h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo=",
235235
version = "v0.6.0",
236236
)
237-
go_repository(
238-
name = "com_github_bazelbuild_bazel_gazelle",
239-
build_file_proto_mode = "disable_global",
240-
importpath = "github.com/bazelbuild/bazel-gazelle",
241-
sum = "h1:buszGdD9d/Z691sxFDgOdcEUWli0ZT2tBXUxfbLMrb4=",
242-
version = "v0.21.1",
243-
)
244-
go_repository(
245-
name = "com_github_bazelbuild_buildtools",
246-
build_file_proto_mode = "disable_global",
247-
importpath = "github.com/bazelbuild/buildtools",
248-
sum = "h1:OfyUN/Msd8yqJww6deQ9vayJWw+Jrbe6Qp9giv51QQI=",
249-
version = "v0.0.0-20190731111112-f720930ceb60",
250-
)
251-
go_repository(
252-
name = "com_github_bazelbuild_rules_go",
253-
build_file_proto_mode = "disable_global",
254-
importpath = "github.com/bazelbuild/rules_go",
255-
sum = "h1:wzbawlkLtl2ze9w/312NHZ84c7kpUCtlkD8HgFY27sw=",
256-
version = "v0.0.0-20190719190356-6dae44dc5cab",
257-
)
237+
258238
go_repository(
259239
name = "com_github_benesch_cgosymbolizer",
260240
build_file_proto_mode = "disable_global",
@@ -269,27 +249,15 @@ def go_deps():
269249
sum = "h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=",
270250
version = "v1.0.1",
271251
)
272-
go_repository(
273-
name = "com_github_bgentry_speakeasy",
274-
build_file_proto_mode = "disable_global",
275-
importpath = "github.com/bgentry/speakeasy",
276-
sum = "h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=",
277-
version = "v0.1.0",
278-
)
252+
279253
go_repository(
280254
name = "com_github_biogo_store",
281255
build_file_proto_mode = "disable_global",
282256
importpath = "github.com/biogo/store",
283257
sum = "h1:tYoz1OeRpx3dJZlh9T4dQt4kAndcmpl+VNdzbSgFC/0=",
284258
version = "v0.0.0-20160505134755-913427a1d5e8",
285259
)
286-
go_repository(
287-
name = "com_github_bmatcuk_doublestar",
288-
build_file_proto_mode = "disable_global",
289-
importpath = "github.com/bmatcuk/doublestar",
290-
sum = "h1:oC24CykoSAB8zd7XgruHo33E0cHJf/WhQA/7BeXj+x0=",
291-
version = "v1.2.2",
292-
)
260+
293261
go_repository(
294262
name = "com_github_broady_gogeohash",
295263
build_file_proto_mode = "disable_global",
@@ -569,13 +537,6 @@ def go_deps():
569537
version = "v22.1.0",
570538
)
571539

572-
go_repository(
573-
name = "com_github_coreos_pkg",
574-
build_file_proto_mode = "disable_global",
575-
importpath = "github.com/coreos/pkg",
576-
sum = "h1:CAKfRE2YtTUIjjh1bkBtyYFaUT/WmOqsJjgtihT0vMI=",
577-
version = "v0.0.0-20160727233714-3ac0863d7acf",
578-
)
579540
go_repository(
580541
name = "com_github_cpuguy83_go_md2man",
581542
build_file_proto_mode = "disable_global",
@@ -597,13 +558,7 @@ def go_deps():
597558
sum = "h1:2L2f5t3kKnCLxnClDD/PrDfExFFa1wjESgxHG/B1ibo=",
598559
version = "v1.3.2",
599560
)
600-
go_repository(
601-
name = "com_github_datadog_zstd",
602-
build_file_proto_mode = "disable_global",
603-
importpath = "github.com/DataDog/zstd",
604-
sum = "h1:+IawcoXhCBylN7ccwdwf8LOH2jKq7NavGpEPanrlTzE=",
605-
version = "v1.4.4",
606-
)
561+
607562
go_repository(
608563
name = "com_github_dave_dst",
609564
build_file_proto_mode = "disable_global",
@@ -815,13 +770,7 @@ def go_deps():
815770
sum = "h1:DddqAaWDpywytcG8w/qoQ5sAN8X12d3Z3koB0C3Rxsc=",
816771
version = "v0.0.0-20160511215533-1f3b11f56072",
817772
)
818-
go_repository(
819-
name = "com_github_fatih_color",
820-
build_file_proto_mode = "disable_global",
821-
importpath = "github.com/fatih/color",
822-
sum = "h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=",
823-
version = "v1.7.0",
824-
)
773+
825774
go_repository(
826775
name = "com_github_fatih_structs",
827776
build_file_proto_mode = "disable_global",
@@ -1062,13 +1011,7 @@ def go_deps():
10621011
sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=",
10631012
version = "v0.0.0-20160126235308-23def4e6c14b",
10641013
)
1065-
go_repository(
1066-
name = "com_github_golang_groupcache",
1067-
build_file_proto_mode = "disable_global",
1068-
importpath = "github.com/golang/groupcache",
1069-
sum = "h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8=",
1070-
version = "v0.0.0-20160516000752-02826c3e7903",
1071-
)
1014+
10721015
go_repository(
10731016
name = "com_github_golang_lint",
10741017
build_file_proto_mode = "disable_global",
@@ -1224,20 +1167,7 @@ def go_deps():
12241167
sum = "h1:pQoHt7SOUiWSwN/W5FzibTQLx/1Xa3VMBRcZGtdb1wo=",
12251168
version = "v0.3.0",
12261169
)
1227-
go_repository(
1228-
name = "com_github_grpc_ecosystem_go_grpc_middleware",
1229-
build_file_proto_mode = "disable_global",
1230-
importpath = "github.com/grpc-ecosystem/go-grpc-middleware",
1231-
sum = "h1:z53tR0945TRRQO/fLEVPI6SMv7ZflF0TEaTAoU7tOzg=",
1232-
version = "v1.0.1-0.20190118093823-f849b5445de4",
1233-
)
1234-
go_repository(
1235-
name = "com_github_grpc_ecosystem_go_grpc_prometheus",
1236-
build_file_proto_mode = "disable_global",
1237-
importpath = "github.com/grpc-ecosystem/go-grpc-prometheus",
1238-
sum = "h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=",
1239-
version = "v1.2.0",
1240-
)
1170+
12411171
go_repository(
12421172
name = "com_github_grpc_ecosystem_grpc_gateway",
12431173
build_file_proto_mode = "disable_global",
@@ -1538,13 +1468,7 @@ def go_deps():
15381468
sum = "h1:mreN1m/5VJ/Zc3b4pzj9qU6D9SRQ6Vm+3KfI328t3S8=",
15391469
version = "v1.0.1-0.20190614124447-d475f43051e7",
15401470
)
1541-
go_repository(
1542-
name = "com_github_jonboulle_clockwork",
1543-
build_file_proto_mode = "disable_global",
1544-
importpath = "github.com/jonboulle/clockwork",
1545-
sum = "h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=",
1546-
version = "v0.1.0",
1547-
)
1471+
15481472
go_repository(
15491473
name = "com_github_jordanlewis_gcassert",
15501474
build_file_proto_mode = "disable_global",
@@ -2207,13 +2131,7 @@ def go_deps():
22072131
sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=",
22082132
version = "v0.9.1",
22092133
)
2210-
go_repository(
2211-
name = "com_github_pkg_profile",
2212-
build_file_proto_mode = "disable_global",
2213-
importpath = "github.com/pkg/profile",
2214-
sum = "h1:F++O52m40owAmADcojzM+9gyjmMOY/T4oYJkgFDH8RE=",
2215-
version = "v1.2.1",
2216-
)
2134+
22172135
go_repository(
22182136
name = "com_github_pmezard_go_difflib",
22192137
build_file_proto_mode = "disable_global",
@@ -2425,13 +2343,7 @@ def go_deps():
24252343
sum = "h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=",
24262344
version = "v1.6.4",
24272345
)
2428-
go_repository(
2429-
name = "com_github_soheilhy_cmux",
2430-
build_file_proto_mode = "disable_global",
2431-
importpath = "github.com/soheilhy/cmux",
2432-
sum = "h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=",
2433-
version = "v0.1.4",
2434-
)
2346+
24352347
go_repository(
24362348
name = "com_github_spf13_afero",
24372349
build_file_proto_mode = "disable_global",
@@ -2502,13 +2414,7 @@ def go_deps():
25022414
sum = "h1:I4DY8wLxJXCrMYzDM6lKCGc3IQwJX0PlTLsd3nQqI3c=",
25032415
version = "v0.0.0-20131203171324-aae784c392b8",
25042416
)
2505-
go_repository(
2506-
name = "com_github_tmc_grpc_websocket_proxy",
2507-
build_file_proto_mode = "disable_global",
2508-
importpath = "github.com/tmc/grpc-websocket-proxy",
2509-
sum = "h1:ndzgwNDnKIqyCvHTXaCqh9KlOWKvBry6nuXMJmonVsE=",
2510-
version = "v0.0.0-20170815181823-89b8d40f7ca8",
2511-
)
2417+
25122418
go_repository(
25132419
name = "com_github_tomihiltunen_geohash_golang",
25142420
build_file_proto_mode = "disable_global",
@@ -2558,13 +2464,7 @@ def go_deps():
25582464
sum = "h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=",
25592465
version = "v0.0.0-20181204163529-d75b2dcb6bc8",
25602466
)
2561-
go_repository(
2562-
name = "com_github_urfave_cli",
2563-
build_file_proto_mode = "disable_global",
2564-
importpath = "github.com/urfave/cli",
2565-
sum = "h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=",
2566-
version = "v1.20.0",
2567-
)
2467+
25682468
go_repository(
25692469
name = "com_github_urfave_negroni",
25702470
build_file_proto_mode = "disable_global",
@@ -2649,13 +2549,7 @@ def go_deps():
26492549
sum = "h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=",
26502550
version = "v1.2.0",
26512551
)
2652-
go_repository(
2653-
name = "com_github_xiang90_probing",
2654-
build_file_proto_mode = "disable_global",
2655-
importpath = "github.com/xiang90/probing",
2656-
sum = "h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=",
2657-
version = "v0.0.0-20190116061207-43a291ad63a2",
2658-
)
2552+
26592553
go_repository(
26602554
name = "com_github_xordataexchange_crypt",
26612555
build_file_proto_mode = "disable_global",
@@ -2740,13 +2634,7 @@ def go_deps():
27402634
sum = "h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=",
27412635
version = "v1.0.0-20200902074654-038fdea0a05b",
27422636
)
2743-
go_repository(
2744-
name = "in_gopkg_cheggaaa_pb_v1",
2745-
build_file_proto_mode = "disable_global",
2746-
importpath = "gopkg.in/cheggaaa/pb.v1",
2747-
sum = "h1:Ev7yu1/f6+d+b3pi5vPdRPc6nNtP1umSfcWiEfRqv6I=",
2748-
version = "v1.0.25",
2749-
)
2637+
27502638
go_repository(
27512639
name = "in_gopkg_errgo_v2",
27522640
build_file_proto_mode = "disable",
@@ -2861,20 +2749,7 @@ def go_deps():
28612749
sum = "h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=",
28622750
version = "v3.0.0-20200615113413-eeeca48fe776",
28632751
)
2864-
go_repository(
2865-
name = "io_etcd_go_bbolt",
2866-
build_file_proto_mode = "disable_global",
2867-
importpath = "go.etcd.io/bbolt",
2868-
sum = "h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=",
2869-
version = "v1.3.3",
2870-
)
2871-
go_repository(
2872-
name = "io_etcd_go_etcd",
2873-
build_file_proto_mode = "disable_global",
2874-
importpath = "go.etcd.io/etcd",
2875-
sum = "h1:V1RzkZJj9LqsJRy+TUBgpWSbZXITLB819lstuTFoZOY=",
2876-
version = "v3.3.25+incompatible",
2877-
)
2752+
28782753
go_repository(
28792754
name = "io_etcd_go_etcd_pkg_v3",
28802755
build_file_proto_mode = "disable",
@@ -2895,13 +2770,6 @@ def go_deps():
28952770
version = "v3.0.0-20210215124703-719f6ce06fbc",
28962771
)
28972772

2898-
go_repository(
2899-
name = "io_k8s_sigs_yaml",
2900-
build_file_proto_mode = "disable_global",
2901-
importpath = "sigs.k8s.io/yaml",
2902-
sum = "h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=",
2903-
version = "v1.1.0",
2904-
)
29052773
go_repository(
29062774
name = "io_opencensus_go",
29072775
build_file_proto_mode = "disable_global",

build/bazelutil/bazel-generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -exuo pipefail
44

5-
bazel run //:gazelle -- update-repos -from_file=go.mod -build_file_proto_mode=disable_global -to_macro=DEPS.bzl%go_deps
5+
bazel run //:gazelle -- update-repos -from_file=go.mod -build_file_proto_mode=disable_global -to_macro=DEPS.bzl%go_deps -prune=true
66
bazel run //:gazelle
77
bazel run //pkg/cmd/generate-test-suites --run_under="cd $PWD && " > pkg/BUILD.bazel

pkg/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ ALL_TESTS = [
240240
"//pkg/storage/metamorphic:metamorphic_test",
241241
"//pkg/storage:storage_test",
242242
"//pkg/testutils/keysutils:keysutils_test",
243-
"//pkg/testutils/lint/passes/fmtsafe/testdata/src/a:a_test",
244243
"//pkg/testutils/lint/passes/fmtsafe:fmtsafe_test",
245244
"//pkg/testutils/lint/passes/forbiddenmethod:descriptormarshal_test",
246245
"//pkg/testutils/lint/passes/forbiddenmethod:forbiddenmethod_test",

pkg/storage/cloudimpl/cloudimpltests/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ go_test(
3030
"//pkg/storage/cloud",
3131
"//pkg/storage/cloudimpl",
3232
"//pkg/testutils",
33-
"//pkg/testutils/lint/passes/fmtsafe/testdata/src/github.com/cockroachdb/errors",
3433
"//pkg/testutils/serverutils",
3534
"//pkg/testutils/skip",
3635
"//pkg/util/ctxgroup",

pkg/storage/cloudimpl/cloudimpltests/azure_storage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818

1919
"github.com/cockroachdb/cockroach/pkg/security"
2020
"github.com/cockroachdb/cockroach/pkg/storage/cloudimpl"
21-
"github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/fmtsafe/testdata/src/github.com/cockroachdb/errors"
2221
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
2322
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
23+
"github.com/cockroachdb/errors"
2424
"github.com/stretchr/testify/require"
2525
)
2626

pkg/testutils/lint/passes/fmtsafe/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ go_test(
2222
name = "fmtsafe_test",
2323
size = "small",
2424
srcs = ["fmtsafe_test.go"],
25+
data = glob(["testdata/**"]),
2526
tags = ["broken_in_bazel"],
2627
deps = [
2728
":fmtsafe",

pkg/testutils/lint/passes/fmtsafe/testdata/src/a/BUILD.bazel

Lines changed: 0 additions & 22 deletions
This file was deleted.

pkg/testutils/lint/passes/fmtsafe/testdata/src/github.com/cockroachdb/cockroach/pkg/util/log/BUILD.bazel

Lines changed: 0 additions & 8 deletions
This file was deleted.

pkg/testutils/lint/passes/fmtsafe/testdata/src/github.com/cockroachdb/errors/BUILD.bazel

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)