Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] normalize paths to enable running external tests #1598

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

joeljeske
Copy link
Contributor

Description

Normalize file paths before passing them to runfiles.rlocation() within the test runner.

Before this change, you could not execute a bazel test target that is not in the primary workspace, it would error with

For example running bazel run @my_external_repo//my/path/to:test

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.google.testing.coverage.JacocoCoverageRunner.main(JacocoCoverageRunner.java:592)
Caused by: java.lang.IllegalArgumentException: path is not normalized: "my_workspace/../my_external_repo/my/path/to/test/test.args"
	at com.google.devtools.build.runfiles.Util.checkArgument(Util.java:45)
	at com.google.devtools.build.runfiles.Runfiles.rlocation(Runfiles.java:337)
	at io.bazel.rulesscala.scala_test.Runner.extendFromFileArgs(Runner.java:51)
	at io.bazel.rulesscala.scala_test.Runner.extendArgs(Runner.java:37)
	at io.bazel.rulesscala.scala_test.Runner.main(Runner.java:33)
	... 5 more

Motivation

We should be able to run tests from external repos

Copy link
Collaborator

@liucijus liucijus left a comment

Choose a reason for hiding this comment

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

Thanks, @joeljeske!

@simuons simuons merged commit ac4181c into bazelbuild:master Aug 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants