Skip to content

test: Migrate external_repo tests to bazel - #298

Open
furtib wants to merge 2 commits into
Ericsson:mainfrom
furtib:test_into_bazel_003
Open

furtib wants to merge 2 commits into
Ericsson:mainfrom
furtib:test_into_bazel_003

Conversation

@furtib

@furtib furtib commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Why:
We want all tests to be run with bazel test //...

What:

  • Migrate external_repository tests to Bazel (This introduces a performance penalty; each external test takes over a minute to run)

Addresses:
#210

@furtib
furtib requested a review from Szelethus August 19, 2026 09:51
@furtib furtib self-assigned this Aug 19, 2026
@furtib furtib added the test ☑️ Adding or refactoring tests label Aug 19, 2026
@Szelethus

Copy link
Copy Markdown
Collaborator

This introduces a performance penalty; each external test takes over a minute to run

I mean that sounds like a big deal.

@furtib

furtib commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Running pytest on the original test takes 55s.
In the Bazel-migrated version, the longest job takes 78s; thanks to parallelization, this is the time for the whole test suite.

@furtib furtib changed the title Migrate external_repo tests to bazel chore: Migrate external_repo tests to bazel Aug 26, 2026
@furtib furtib changed the title chore: Migrate external_repo tests to bazel refactor: Migrate external_repo tests to bazel Aug 26, 2026
@furtib furtib changed the title refactor: Migrate external_repo tests to bazel test: Migrate external_repo tests to bazel Aug 27, 2026
@furtib
furtib force-pushed the test_into_bazel_003 branch from f1af3ed to db5885e Compare September 23, 2026 13:47
@furtib

furtib commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

After rebase, it seems like it doesn't affect CI runtime.

@furtib
furtib force-pushed the test_into_bazel_003 branch from db5885e to a97bd92 Compare September 23, 2026 16:12

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of terrible how much boilerplate is needed to migrate this to bazel. And its especially a shame how much code we are seemingly duplicating from other tests. Is this absolutely necessary?

Comment on lines +157 to +162
parser.add_argument(
"--srcs",
nargs="*",
default=[],
help="Source files to copy into the workspace root",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote the logic to not use temporary folders; now this is true.

Comment on lines +141 to +146
parser.add_argument(
"--expected_exit_code",
type=int,
default=0,
help="Expected exit code from the bazel command",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.


external_test(
name = "compile_commands_isystem_test",
action = "build",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How integral is this to this test?

Comment on lines +124 to +129
parser.add_argument(
"--action",
required=True,
choices=["build", "test"],
help="Bazel action to run",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically used, but I'm sure there is a point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's much better for extensibility if we, for whatever reason, want to extend this test.

# Write empty WORKSPACE
write_file(
os.path.join(tmpdir, "WORKSPACE"),
"# This file is mandatory for old Bazel versions\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, thats not the real explanation. We only support bazel 7 and up where its not a requirement, nor is it the default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this, but a bit of correction.
Before Bazel 7.1.0, we still need WORKSPACE files for it to work. (But since the main WORKSPACE file was deleted in #270, I guess we don't support Bazel 7.0.0-7.0.2)

action,
target,
"--experimental_cc_implementation_deps",
"--enable_bzlmod",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are testing here with bzlmod and workspace coexisting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed these flags; these were necessary for Bazel 6 and below.

Comment on lines +282 to +289
def cleanup(tmpdir):
"""Shut down bazel server to release file locks."""
subprocess.run(
["bazel", "shutdown"],
cwd=tmpdir,
capture_output=True,
check=False,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a common issue you are experiencing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to speed up the time it takes for a test by about 15s.

@Szelethus

Copy link
Copy Markdown
Collaborator

After rebase, it seems like it doesn't affect CI runtime.

So you mentioned in person this is likely due to bazelisk re-downloading bazel for each target?

@furtib
furtib requested a review from Szelethus October 1, 2026 12:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test ☑️ Adding or refactoring tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants