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

Toolchainize all testing toolchains #1653

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config(enable_compiler_dependency_tracking = True)

load("//scala:scala.bzl", "scala_toolchains")
load("//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(fetch_sources = True)
scala_toolchains(
fetch_sources = True,
testing = True,
)

register_toolchains(
"//testing:testing_toolchain",
"//scala:unused_dependency_checker_error_toolchain",
"//test/proto:scalapb_toolchain",
"@io_bazel_rules_scala_toolchains//...:all",
Expand Down Expand Up @@ -69,14 +71,6 @@ load("//scala_proto:scala_proto.bzl", "scala_proto_repositories")

scala_proto_repositories()

load("//scalatest:scalatest.bzl", "scalatest_repositories")

scalatest_repositories()

load("//specs2:specs2_junit.bzl", "specs2_junit_repositories")

specs2_junit_repositories()

load("//scala/scalafmt:scalafmt_repositories.bzl", "scalafmt_default_config", "scalafmt_repositories")

scalafmt_default_config()
Expand Down
22 changes: 17 additions & 5 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ Test framework dependencies are configured via testing toolchain. For convenienc
`setup_scala_testing_toolchain` can be used to define such toolchains.

```starlark
load("@io_bazel_rules_scala//scala:scala.bzl", "setup_scala_testing_toolchain")
load(
"@io_bazel_rules_scala//testing:testing.bzl",
"setup_scala_testing_toolchain",
)
```

Attributes
Expand All @@ -53,7 +56,10 @@ Examples (assumes maven deps are managed with rules_jvm_external):

```starlark
# BUILD
load("@io_bazel_rules_scala//scala:scala.bzl", "setup_scala_testing_toolchain")
load(
"@io_bazel_rules_scala//testing:testing.bzl",
"setup_scala_testing_toolchain",
)

setup_scala_testing_toolchain(
name = "scalatest_toolchain",
Expand All @@ -77,7 +83,10 @@ register_toolchains('//:scalatest_toolchain')
#### JUnit 4
```starlark
# BUILD
load("@io_bazel_rules_scala//scala:scala.bzl", "setup_scala_testing_toolchain")
load(
"@io_bazel_rules_scala//testing:testing.bzl",
"setup_scala_testing_toolchain",
)

setup_scala_testing_toolchain(
name = "junit_toolchain",
Expand All @@ -98,7 +107,10 @@ For Specs2 rules to work, `junit_classpath`, `specs2_junit_classpath` and `specs
be configured.
```starlark
# BUILD
load("@io_bazel_rules_scala//scala:scala.bzl", "setup_scala_testing_toolchain")
load(
"@io_bazel_rules_scala//testing:testing.bzl",
"setup_scala_testing_toolchain",
)

setup_scala_testing_toolchain(
name = "specs2_toolchain",
Expand All @@ -122,4 +134,4 @@ Register the toolchain
```starlark
# WORKSPACE
register_toolchains('//:specs2_toolchain')
```
```
2 changes: 1 addition & 1 deletion dt_patches/test_dt_patches/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ load("@compiler_sources//:extensions.bzl", "import_compiler_source_repos")

import_compiler_source_repos()

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(
fetch_sources = True,
Expand Down
2 changes: 1 addition & 1 deletion dt_patches/test_dt_patches_user_srcjar/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ srcjars_by_version = {
},
}

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(
fetch_sources = True,
Expand Down
10 changes: 2 additions & 8 deletions examples/crossbuild/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ scala_config(
],
)

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains()
scala_toolchains(scalatest = True)

register_toolchains("@io_bazel_rules_scala_toolchains//...:all")

Expand All @@ -59,9 +59,3 @@ rules_proto_toolchains()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "scalatest_toolchain")

scalatest_repositories()

scalatest_toolchain()
2 changes: 1 addition & 1 deletion examples/scala3/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config(scala_version = "3.6.2")

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(fetch_sources = True)

Expand Down
2 changes: 1 addition & 1 deletion examples/semanticdb/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config(scala_version = "2.13.15")

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(fetch_sources = True)

Expand Down
11 changes: 6 additions & 5 deletions examples/testing/multi_frameworks_toolchain/BUILD
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
load("@io_bazel_rules_scala//scala:scala.bzl", "setup_scala_testing_toolchain")
load("@io_bazel_rules_scala//scala:scala_cross_version.bzl", "version_suffix")
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION")
load(
"@io_bazel_rules_scala//testing:testing.bzl",
"setup_scala_testing_toolchain",
)

setup_scala_testing_toolchain(
name = "testing_toolchain",
junit_classpath = [
"@io_bazel_rules_scala_junit_junit",
"@io_bazel_rules_scala_org_hamcrest_hamcrest_core",
],
scalatest_classpath = [dep + version_suffix(SCALA_VERSION) for dep in [
scalatest_classpath = [
"@io_bazel_rules_scala_scalactic",
"@io_bazel_rules_scala_scalatest",
"@io_bazel_rules_scala_scalatest_compatible",
Expand All @@ -21,7 +22,7 @@ setup_scala_testing_toolchain(
"@io_bazel_rules_scala_scalatest_matchers_core",
"@io_bazel_rules_scala_scalatest_mustmatchers",
"@io_bazel_rules_scala_scalatest_shouldmatchers",
]],
],
specs2_classpath = [
"@io_bazel_rules_scala_org_specs2_specs2_common",
"@io_bazel_rules_scala_org_specs2_specs2_core",
Expand Down
17 changes: 5 additions & 12 deletions examples/testing/multi_frameworks_toolchain/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config()

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(fetch_sources = True)
scala_toolchains(
fetch_sources = True,
testing = True,
)

register_toolchains(
":testing_toolchain",
Expand All @@ -55,13 +58,3 @@ rules_proto_toolchains()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories")
load("@io_bazel_rules_scala//testing:junit.bzl", "junit_repositories")
load("@io_bazel_rules_scala//testing:specs2_junit.bzl", "specs2_junit_repositories")

scalatest_repositories()

junit_repositories()

specs2_junit_repositories()
13 changes: 5 additions & 8 deletions examples/testing/scalatest_repositories/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config()

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(fetch_sources = True)
scala_toolchains(
fetch_sources = True,
scalatest = True,
)

register_toolchains("@io_bazel_rules_scala_toolchains//...:all")

Expand All @@ -52,9 +55,3 @@ rules_proto_toolchains()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "scalatest_toolchain")

scalatest_repositories()

scalatest_toolchain()
13 changes: 5 additions & 8 deletions examples/testing/specs2_junit_repositories/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config()

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_toolchains")
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_toolchains")

scala_toolchains(fetch_sources = True)
scala_toolchains(
fetch_sources = True,
specs2 = True,
)

register_toolchains("@io_bazel_rules_scala_toolchains//...:all")

Expand All @@ -52,9 +55,3 @@ rules_proto_toolchains()
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@io_bazel_rules_scala//testing:specs2_junit.bzl", "specs2_junit_repositories", "specs2_junit_toolchain")

specs2_junit_repositories()

specs2_junit_toolchain()
11 changes: 7 additions & 4 deletions junit/junit.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ load(
)
load("//third_party/repositories:repositories.bzl", "repositories")

def junit_artifact_ids():
return [
"io_bazel_rules_scala_junit_junit",
"io_bazel_rules_scala_org_hamcrest_hamcrest_core",
]

def junit_repositories(
maven_servers = _default_maven_server_urls(),
fetch_sources = True):
repositories(
for_artifact_ids = [
"io_bazel_rules_scala_junit_junit",
"io_bazel_rules_scala_org_hamcrest_hamcrest_core",
],
for_artifact_ids = junit_artifact_ids(),
fetch_sources = fetch_sources,
maven_servers = maven_servers,
)
66 changes: 0 additions & 66 deletions scala/private/macros/toolchains.bzl

This file was deleted.

Loading