Skip to content

Commit

Permalink
Remove testing parameter from scala_toolchains
Browse files Browse the repository at this point in the history
Removed in favor of using the existing `scalatest`, `junit`, and
`specs2` parameters at @simuons's suggestion in:

- bazelbuild#1482 (comment)

Also updated the `scala_toolchains()` docstring slightly and added `doc`
parameters to the `attrs` for `_scala_toolchains_repo()`.
  • Loading branch information
mbland committed Feb 26, 2025
1 parent b06363e commit c789cb0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 30 deletions.
4 changes: 3 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ load("//scala:toolchains.bzl", "scala_register_toolchains", "scala_toolchains")
scala_toolchains(
fetch_sources = True,
jmh = True,
junit = True,
scala_proto = True,
scalafmt = True,
testing = True,
scalatest = True,
specs2 = True,
twitter_scrooge = True,
)

Expand Down
4 changes: 3 additions & 1 deletion examples/testing/multi_frameworks_toolchain/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ load(

scala_toolchains(
fetch_sources = True,
testing = True,
junit = True,
scalatest = True,
specs2 = True,
)

register_toolchains(":testing_toolchain")
Expand Down
12 changes: 2 additions & 10 deletions scala/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def scala_toolchains(
scalatest = False,
junit = False,
specs2 = False,
testing = False,
scalafmt = False,
scalafmt_default_config_path = ".scalafmt.conf",
scala_proto = False,
Expand Down Expand Up @@ -78,19 +77,17 @@ def scala_toolchains(
compiler srcjar metadata dictionaries containing:
- exactly one "label", "url", or "urls" key
- optional "integrity" or "sha256" keys
scalatest: whether to instantiate the Scalatest toolchain
scalatest: whether to instantiate the ScalaTest toolchain
junit: whether to instantiate the JUnit toolchain
specs2: whether to instantiate the Specs2 JUnit toolchain
testing: whether to instantiate the Scalatest, JUnit, and Specs2 JUnit
toolchains combined
scalafmt: whether to instantiate the Scalafmt toolchain
scalafmt_default_config_path: the relative path to the default Scalafmt
config file within the repository
scala_proto: whether to instantiate the scala_proto toolchain
scala_proto_enable_all_options: whether to instantiate the scala_proto
toolchain with all options enabled; `scala_proto` must also be
`True` for this to take effect
jmh: whether to instantiate the jmh toolchain
jmh: whether to instantiate the Java Microbenchmarks Harness toolchain
twitter_scrooge: whether to instantiate the twitter_scrooge toolchain
twitter_scrooge_deps: dictionary of string to Label containing overrides
for twitter_scrooge toolchain dependency providers with keys:
Expand All @@ -114,10 +111,6 @@ def scala_toolchains(
scalafmt_conf_target = "//:" + scalafmt_default_config_path
scalafmt_config(name = "scalafmt_default", path = scalafmt_conf_target)

if testing:
scalatest = True
junit = True
specs2 = True
if specs2:
junit = True

Expand Down Expand Up @@ -185,7 +178,6 @@ def scala_toolchains(
scalatest = scalatest,
junit = junit,
specs2 = specs2,
testing = testing,
scalafmt = scalafmt,
scala_proto = scala_proto,
scala_proto_enable_all_options = scala_proto_enable_all_options,
Expand Down
52 changes: 34 additions & 18 deletions scala/toolchains_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
def _generate_testing_toolchain_build_file_args(repo_attr):
framework_deps = {}

if repo_attr.testing:
framework_deps = {
"scalatest": "SCALATEST_DEPS",
"junit": "JUNIT_DEPS",
"specs2": "SPECS2_DEPS",
"specs2_junit": "SPECS2_JUNIT_DEPS",
}
if repo_attr.scalatest:
framework_deps["scalatest"] = "SCALATEST_DEPS"
if repo_attr.specs2:
Expand Down Expand Up @@ -92,18 +85,41 @@ _scala_toolchains_repo = repository_rule(
implementation = _scala_toolchains_repo_impl,
doc = "Creates a repo containing Scala toolchain packages",
attrs = {
"scala": attr.bool(default = True),
"scalatest": attr.bool(),
"junit": attr.bool(),
"specs2": attr.bool(),
"testing": attr.bool(),
"scalafmt": attr.bool(),
"scala_proto": attr.bool(),
"scala_proto_enable_all_options": attr.bool(),
"jmh": attr.bool(),
"twitter_scrooge": attr.bool(),
"scala": attr.bool(
doc = "Instantiate the Scala compiler toolchain",
default = True,
),
"scalatest": attr.bool(doc = "Instantiate the ScalaTest toolchain"),
"junit": attr.bool(doc = "Instantiate the JUnit toolchain"),
"specs2": attr.bool(doc = "Instantiate the Specs2 toolchain"),
"scalafmt": attr.bool(doc = "Instantiate the Scalafmt toolchain"),
"scala_proto": attr.bool(
doc = "Instantiate the scala_proto toolchain",
),
"scala_proto_enable_all_options": attr.bool(
doc = (
"Enable all scala_proto_options; " +
"scala_proto must also be True for this to take effect"
),
),
"jmh": attr.bool(
doc = "Instantiate the Java Microbenchmarks Harness toolchain",
),
"twitter_scrooge": attr.bool(
doc = "Instantiate the twitter_scrooge toolchain",
),
# attr.string_keyed_label_dict isn't available in Bazel 6
"twitter_scrooge_deps": attr.string_dict(),
"twitter_scrooge_deps": attr.string_dict(
doc = (
"overrides for twitter_scrooge toolchain dependency " +
"providers with keys:\n" +
" libthrift\n" +
" scrooge_core\n" +
" scrooge_generator\n" +
" util_core\n" +
" util_logging"
),
),
},
)

Expand Down

0 comments on commit c789cb0

Please sign in to comment.