bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
360 stars 273 forks source link

Replace relative paths to ../ with external/ #1500

Closed prebeta closed 1 year ago

prebeta commented 1 year ago

Description

Java throws an IllegalArgumentException when argument paths are not normalized. This error happens when running tests in external repositories i.e @external_scala_repo//path/to/target because short_path returns ../path/to/target instead of external/path/to/target.

Motivation

This fixes cases where we want to run tests in external repositories. The stack trace of this type of error looks like:

Exception in thread "main" java.lang.IllegalArgumentException: path is not normalized: "__main__/../path/to/target/tests.jar"
    at com.google.devtools.build.runfiles.Util.checkArgument(Util.java:45)
    at com.google.devtools.build.runfiles.Runfiles.rlocation(Runfiles.java:134)
    at io.bazel.rulesscala.scala_test.Runner.rlocateRunpathValue(Runner.java:95)
    at io.bazel.rulesscala.scala_test.Runner.extendFromFileArgs(Runner.java:59)
    at io.bazel.rulesscala.scala_test.Runner.extendArgs(Runner.java:37)
    at io.bazel.rulesscala.scala_test.Runner.main(Runner.java:33)
simuons commented 1 year ago

Hi, @prebeta,

thanks for pr. Could you add a test case for this?

prebeta commented 1 year ago

Hi, @prebeta,

thanks for pr. Could you add a test case for this?

Sounds good! I reused strip_resource_external_workspace and renamed it to example_external_workspace so we don't need to add another local_repository in the WORKSPACE file.