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

[fixed] scala test rules include scala_specs2_junit_test #101

Merged
merged 9 commits into from
Sep 22, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Warnings generated by the [WORKSPACE file](WORKSPACE). | [#81](https://github.com/JetBrains/bazel-bsp/pull/81)
- Semantic versioning parser - now it can parse every valid version. | [#93](https://github.com/JetBrains/bazel-bsp/pull/93)
- `exports` attribute propagation to the BSP | [#98](https://github.com/JetBrains/bazel-bsp/pull/98)
- Now all `scala_junit_test` based rules (including `scala_specs2_junit_test`) are included in the BSP tests, unfortunately without test classes. | [#101](https://github.com/JetBrains/bazel-bsp/pull/101)

## [1.0.0] - 23.08.2021
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,22 @@ private BazelBspTestScenarioStep scalaTestClasses() {
new ScalaTestClassesParams(
ImmutableList.of(
new BuildTargetIdentifier("//example:example"),
new BuildTargetIdentifier("//example:example-test")));
new BuildTargetIdentifier("//example:example-test"),
new BuildTargetIdentifier("//example:example-spec2-test")));

ScalaTestClassesItem exampleExampleTestTestClasses =
new ScalaTestClassesItem(
new BuildTargetIdentifier("//example:example-test"),
ImmutableList.of("example.ExampleTest"));

// TODO (https://github.com/JetBrains/bazel-bsp/issues/96)
ScalaTestClassesItem exampleExampleSpec2TestTestClasses =
new ScalaTestClassesItem(
new BuildTargetIdentifier("//example:example-spec2-test"), ImmutableList.of());

ScalaTestClassesResult expectedScalaTestClassesResult =
new ScalaTestClassesResult(ImmutableList.of(exampleExampleTestTestClasses));
new ScalaTestClassesResult(
ImmutableList.of(exampleExampleTestTestClasses, exampleExampleSpec2TestTestClasses));

return new BazelBspTestScenarioStep(
"Scala test classes",
Expand Down
4 changes: 4 additions & 0 deletions e2e/test-resources/sample-repo/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ http_archive(
url = "https://github.com/bazelbuild/rules_jvm_external/archive/2.8.zip",
)

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

specs2_junit_repositories()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
Expand Down
11 changes: 10 additions & 1 deletion e2e/test-resources/sample-repo/example/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary", "scala_test")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary", "scala_specs2_junit_test", "scala_test")

filegroup(
name = "resources",
Expand Down Expand Up @@ -31,3 +31,12 @@ scala_test(
visibility = ["//visibility:public"],
deps = ["//dep"],
)

scala_specs2_junit_test(
name = "example-spec2-test",
srcs = ["ExampleSpec2Test.scala"],
resources = [":resources"],
suffixes = ["Test"],
visibility = ["//visibility:public"],
deps = ["//dep"],
)
13 changes: 13 additions & 0 deletions e2e/test-resources/sample-repo/example/ExampleSpec2Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package example

import dep.Dep
import org.specs2.mutable._

class ExampleSpec2Test extends SpecificationWithJUnit {
"Test" should {
"be test" in {
Dep.list.head
"Test" must have size (4)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class ScalaBuildServerService {
private static final List<String> SCALA_LANGUAGES_IDS =
ImmutableList.of(Constants.SCALAC, Constants.JAVAC);

private static final String SCALA_TEST_RULE_CLASS_NAME = "scala_test";
private static final List<String> SCALA_TEST_RULE_CLASS_NAMES =
ImmutableList.of("scala_test", "scala_junit_test");

private final TargetsLanguageOptionsResolver<ScalacOptionsItem> targetsLanguageOptionsResolver;
private final TargetRulesResolver<ScalaMainClassesItem> targetsScalaMainClassesRulesResolver;
Expand Down Expand Up @@ -69,7 +70,7 @@ public ScalaBuildServerService(
}

private boolean isScalaTestRule(Build.Rule rule) {
return rule.getRuleClass().equals(SCALA_TEST_RULE_CLASS_NAME);
return SCALA_TEST_RULE_CLASS_NAMES.contains(rule.getRuleClass());
}

private ScalaTestClassesItem mapRuleToTestClassesItem(Build.Rule rule) {
Expand Down