Skip to content

Commit 833cb42

Browse files
authored
move integration tests from their own modules into examples (#1513)
The tests are slightly better tests in their own modules, but bazelci doesn't really have a great way to handle them other than matrix ops on the working_directory, which causes us to need to generate twice as many jobs. I need to free up some headroom in order to add bazel 8 tests, so this is a necessary compromise.
1 parent 7e48622 commit 833cb42

30 files changed

Lines changed: 96 additions & 1035 deletions

.bazelci/config.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ matrix:
2727
Main: ''
2828
Examples: examples
2929

30-
mini:
31-
Flags: test/standard_cxx_flags_test
32-
DetectRoot: test/detect_root_test
33-
3430
exclude:
3531
# bazel 9 no longer supports workspaces
3632
- bazel_version: 9.x
@@ -73,17 +69,6 @@ tasks:
7369

7470
test_flags: *primary_flags
7571

76-
mini:
77-
<<: *default_task
78-
name: '{mini}/{bazel_version}/{bzlmod}'
79-
working_directory: ${{ mini }}
80-
81-
build_flags: &mini_flags
82-
- --config=ci
83-
- ${{ bzlmod }}
84-
85-
test_flags: *mini_flags
86-
8772
docs:
8873
name: Docs
8974
platform: ubuntu2404

.bazelignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
docs
22
examples
3-
test/standard_cxx_flags_test
4-
test/detect_root_test

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,4 @@ bazelci.py
8585
/bazel-*
8686
/docs/bazel-*
8787
/examples/bazel-*
88-
/test/detect_root_test/bazel-*
89-
/test/standard_cxx_flags_test/bazel-*
9088
.ijwb/

examples/MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ bazel_dep(name = "rules_python", version = "1.9.0")
2727
bazel_dep(name = "rules_cc", version = "0.2.13")
2828
bazel_dep(name = "rules_shell", version = "0.6.1")
2929
bazel_dep(name = "rules_perl", version = "1.0.0")
30+
bazel_dep(name = "with_cfg.bzl", version = "0.14.6")
3031

3132
perl = use_extension("@rules_perl//perl:extensions.bzl", "perl_repositories")
3233
use_repo(
@@ -139,3 +140,19 @@ use_repo(
139140

140141
bazel_dep(name = "bazel_skylib", version = "1.9.0")
141142
bazel_dep(name = "bazel_lib", version = "3.2.0")
143+
144+
# Support the integration tests
145+
146+
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
147+
148+
new_local_repository(
149+
name = "rules_foreign_cc_detect_root_test_repo",
150+
build_file_content = """\
151+
filegroup(
152+
name = "srcs",
153+
srcs = glob(["**/**"]),
154+
visibility = ["//visibility:public"],
155+
)
156+
""",
157+
path = "integration_tests/detect_root_test/dir1",
158+
)

examples/MODULE.bazel.lock

Lines changed: 25 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/WORKSPACE.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
workspace(name = "rules_foreign_cc_examples")
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
load("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
45

56
local_repository(
67
name = "rules_foreign_cc",
@@ -15,6 +16,15 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps")
1516

1617
bazel_features_deps()
1718

19+
http_archive(
20+
name = "with_cfg.bzl",
21+
integrity = "sha256-h4UuEzw3VaVkL+EFQ+4g7acA2uFNMNE9rJbiLqUQbQc=",
22+
strip_prefix = "with_cfg.bzl-0.14.6",
23+
urls = [
24+
"https://github.com/fmeum/with_cfg.bzl/releases/download/v0.14.6/with_cfg.bzl-v0.14.6.tar.gz",
25+
],
26+
)
27+
1828
load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo")
1929

2030
compatibility_proxy_repo()
@@ -190,3 +200,15 @@ load(
190200
)
191201

192202
rust_example_crate_repositories()
203+
204+
new_local_repository(
205+
name = "rules_foreign_cc_detect_root_test_repo",
206+
build_file_content = """\
207+
filegroup(
208+
name = "srcs",
209+
srcs = glob(["**/**"]),
210+
visibility = ["//visibility:public"],
211+
)
212+
""",
213+
path = "integration_tests/detect_root_test/dir1",
214+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Integration Tests
2+
3+
Integration tests live in the example module instead of the main one because:
4+
- We want to run them from a seperate module so they're stronger as tests, but...
5+
- We very rapidly run into max task limits in bazelci if we matrix-generate working_directory tests.
6+
7+
So this is a compromise between testing and CI limits. There are certain types of test that can't be written this way
8+
(anything testing the extensions...) but that's a problem for another day.

test/detect_root_test/BUILD.bazel renamed to examples/integration_tests/detect_root_test/BUILD.bazel

File renamed without changes.

test/detect_root_test/detect_root_test_rule.bzl renamed to examples/integration_tests/detect_root_test/detect_root_test_rule.bzl

File renamed without changes.

test/detect_root_test/dir1/srcs/input.txt renamed to examples/integration_tests/detect_root_test/dir1/srcs/input.txt

File renamed without changes.

0 commit comments

Comments
 (0)