Skip to content

Commit

Permalink
Extract versioned _JUNIT_DEPS in test/BUILD
Browse files Browse the repository at this point in the history
Eliminates reliance on the default `@io_bazel_rules_scala_junit_junit`
artifact repository.
  • Loading branch information
mbland committed Dec 2, 2024
1 parent 3d2c94d commit c4fa6c2
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load(
"//scala:scala.bzl",
"scala_binary",
Expand All @@ -13,10 +11,18 @@ load(
"scala_test",
"scala_test_suite",
)
load("//scala:scala_cross_version.bzl", "repositories")
load(":check_statsfile.bzl", "check_statsfile")
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_python//python:defs.bzl", "py_binary")

package(default_testonly = 1)

_JUNIT_DEPS = repositories(SCALA_VERSION, [
"@io_bazel_rules_scala_junit_junit",
])

# The examples below show how to combine Scala and Java rules.
# ScalaBinary is the Scala equivalent of JavaBinary.

Expand Down Expand Up @@ -491,7 +497,6 @@ scala_junit_test(
"//test/src/main/resources/java_sources:CompiledWithJava11",
"//test/src/main/resources/java_sources:CompiledWithJava8",
],
deps = ["@io_bazel_rules_scala_junit_junit"],
)

# Generate a file containing the rootpaths of a Scala binary.
Expand Down Expand Up @@ -612,7 +617,7 @@ scala_library(
scala_library(
name = "customJunitRunner",
srcs = ["src/main/scala/scalarules/test/junit/JunitCustomRunner.java"],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

# make sure making a fat jar strips signatures
Expand Down Expand Up @@ -698,7 +703,7 @@ check_statsfile("ScalaLibBinary")
scala_library(
name = "JunitSeparateTarget",
srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitSeparateTargetTest.scala"],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_junit_test(
Expand All @@ -712,7 +717,7 @@ scala_junit_test(
java_library(
name = "JunitJavaSeparateTarget",
srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java"],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_junit_test(
Expand All @@ -726,14 +731,14 @@ scala_junit_test(
scala_library(
name = "TargetWithTestThatShouldNotRun",
srcs = ["src/main/scala/scalarules/test/junit/separate_target/FailingTest.scala"],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_library(
name = "JunitSeparateTargetWithDependencyOnTest",
srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitSeparateTargetTest.scala"],
runtime_deps = [":TargetWithTestThatShouldNotRun"],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_junit_test(
Expand All @@ -748,7 +753,7 @@ java_library(
name = "JunitSeparateJavaTargetWithDependencyOnTest",
srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java"],
runtime_deps = [":TargetWithTestThatShouldNotRun"],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_junit_test(
Expand All @@ -765,7 +770,7 @@ scala_library(
"src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java",
"src/main/scala/scalarules/test/junit/separate_target/SomeScalaClass.scala",
],
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_junit_test(
Expand All @@ -783,7 +788,7 @@ scala_library(
],
# make sure java compilation toolchain matches runtime toolchain ie --target
java_compile_toolchain = "@bazel_tools//tools/jdk:toolchain_java11",
deps = ["@io_bazel_rules_scala_junit_junit"],
deps = _JUNIT_DEPS,
)

scala_junit_test(
Expand All @@ -800,7 +805,6 @@ scala_junit_test(
size = "small",
srcs = ["src/main/scala/scalarules/test/junit/JunitNoTestEnvironmentTest.scala"],
suffixes = ["Test"],
deps = ["@io_bazel_rules_scala_junit_junit"],
)

scala_junit_test(
Expand All @@ -811,7 +815,6 @@ scala_junit_test(
"my_env_var": "my_value",
},
suffixes = ["Test"],
deps = ["@io_bazel_rules_scala_junit_junit"],
)

py_binary(
Expand Down

0 comments on commit c4fa6c2

Please sign in to comment.