From eb63ea0ddc712cb78849ed2d1b142465e83e6c3a Mon Sep 17 00:00:00 2001 From: Aish Date: Tue, 19 Dec 2023 01:30:14 -0800 Subject: [PATCH] Fix diagnostic outputs for Scala 2.12.13 (#1532) --- .gitignore | 1 + .../scalac/deps_tracking_reporter/BUILD | 6 +- .../DepsTrackingReporter.java | 329 ++++++++++++++++++ .../DepsTrackingReporter.java | 0 test/diagnostics_reporter/BUILD | 6 +- .../DiagnosticsReporterTest.java | 14 +- .../VerifyDiagnosticsOutput.java | 31 +- .../DiagnosticsReporterTest.java | 66 ---- test/shell/test_diagnostics_reporter.sh | 7 + .../diagnostics_reporter/BUILD | 14 + test_version.sh | 12 +- test_version/test_reporter/BUILD | 14 + 12 files changed, 395 insertions(+), 105 deletions(-) create mode 100644 src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/after_2_12_13_and_before_2_13_12/DepsTrackingReporter.java rename src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/{before_2_13_12 => before_2_12_13}/DepsTrackingReporter.java (100%) rename test/diagnostics_reporter/{after_2_13_12 => }/DiagnosticsReporterTest.java (81%) delete mode 100644 test/diagnostics_reporter/before_2_13_12/DiagnosticsReporterTest.java diff --git a/.gitignore b/.gitignore index c526de90c..bc05c9305 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ hash2 .metals .vscode unformatted-*.backup.scala +.scala-build \ No newline at end of file diff --git a/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/BUILD b/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/BUILD index 87c33e88c..9a9b4a40d 100644 --- a/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/BUILD +++ b/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/BUILD @@ -3,8 +3,10 @@ load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION", "SCALA_ filegroup( name = "deps_tracking_reporter", srcs = [ - "before_2_13_12/DepsTrackingReporter.java", - ] if SCALA_MAJOR_VERSION.startswith("2.11") or SCALA_MAJOR_VERSION.startswith("2.12") or (SCALA_MAJOR_VERSION.startswith("2.13") and int(SCALA_MINOR_VERSION) < 12) else [ + "before_2_12_13/DepsTrackingReporter.java", + ] if (SCALA_MAJOR_VERSION == "2.11") or ((SCALA_MAJOR_VERSION == "2.12") and int(SCALA_MINOR_VERSION) < 13) else [ + "after_2_12_13_and_before_2_13_12/DepsTrackingReporter.java", + ] if ((SCALA_MAJOR_VERSION == "2.12") and int(SCALA_MINOR_VERSION) >= 13) or ((SCALA_MAJOR_VERSION == "2.13") and int(SCALA_MINOR_VERSION) < 12) else [ "after_2_13_12/DepsTrackingReporter.java", ], visibility = ["//visibility:public"], diff --git a/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/after_2_12_13_and_before_2_13_12/DepsTrackingReporter.java b/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/after_2_12_13_and_before_2_13_12/DepsTrackingReporter.java new file mode 100644 index 000000000..4283f46f2 --- /dev/null +++ b/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/after_2_12_13_and_before_2_13_12/DepsTrackingReporter.java @@ -0,0 +1,329 @@ +package io.bazel.rulesscala.scalac.reporter; + +import io.bazel.rulesscala.deps.proto.ScalaDeps; +import io.bazel.rulesscala.deps.proto.ScalaDeps.Dependency; +import io.bazel.rulesscala.deps.proto.ScalaDeps.Dependency.Kind; +import io.bazel.rulesscala.scalac.compileoptions.CompileOptions; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import scala.collection.immutable.List$; +import scala.reflect.internal.util.NoPosition$; +import scala.reflect.internal.util.Position; +import scala.tools.nsc.Settings; +import scala.tools.nsc.reporters.ConsoleReporter; +import scala.tools.nsc.reporters.Reporter; +import scala.tools.nsc.reporters.FilteringReporter; + +import javax.print.attribute.standard.Severity; + +public class DepsTrackingReporter extends ConsoleReporter { + + private static final String HJAR_JAR_SUFFIX = "-hjar.jar"; + private static final String IJAR_JAR_SUFFIX = "-ijar.jar"; + private final Set usedJars = new HashSet<>(); + + private final Map jarToTarget = new HashMap<>(); + private final Map indirectJarToTarget = new HashMap<>(); + + private final Set ignoredTargets; + private final Set directTargets; + + private final CompileOptions ops; + public final Reporter delegateReporter; + private Set astUsedJars = new HashSet<>(); + + public DepsTrackingReporter(Settings settings, CompileOptions ops, Reporter delegate) { + super(settings); + this.ops = ops; + this.delegateReporter = delegate; + + if (ops.directJars.length == ops.directTargets.length) { + for (int i = 0; i < ops.directJars.length; i++) { + jarToTarget.put(ops.directJars[i], ops.directTargets[i]); + } + } else { + throw new IllegalArgumentException( + "mismatched size: directJars " + ops.directJars.length + " vs directTargets" + + ops.directTargets.length); + } + + if (ops.indirectJars.length == ops.indirectTargets.length) { + for (int i = 0; i < ops.indirectJars.length; i++) { + indirectJarToTarget.put(ops.indirectJars[i], ops.indirectTargets[i]); + } + } else { + throw new IllegalArgumentException( + "mismatched size: indirectJars " + ops.directJars.length + " vs indirectTargets " + + ops.directTargets.length); + } + + ignoredTargets = Arrays.stream(ops.unusedDepsIgnoredTargets).collect(Collectors.toSet()); + directTargets = Arrays.stream(ops.directTargets).collect(Collectors.toSet()); + } + + private boolean isDependencyTrackingOn() { + return "ast-plus".equals(ops.dependencyTrackingMethod) + && (!"off".equals(ops.strictDepsMode) || !"off".equals(ops.unusedDependencyCheckerMode)); + } + + @Override + public void info0(Position pos, String msg, Severity severity, boolean force) { + doReport(pos, msg, severity); + } + + @Override + public void doReport(Position pos, String msg, Severity severity) { + if (msg.startsWith("DT:")) { + if (isDependencyTrackingOn()) { + parseOpenedJar(msg); + } + } else { + if (delegateReporter != null) { + if (delegateReporter instanceof FilteringReporter) { + ((FilteringReporter) delegateReporter).doReport(pos, msg, severity); + } else { + delegateReporter.info0(pos, msg, severity, false); + } + } else { + super.doReport(pos, msg, severity); + } + } + } + + private void parseOpenedJar(String msg) { + String jar = msg.split(":")[1]; + + //normalize path separators (scalac passes os-specific path separators.) + jar = jar.replace("\\", "/"); + + // track only jars from dependency targets + // this should exclude things like rt.jar which come from JDK + if (jarToTarget.containsKey(jar) || indirectJarToTarget.containsKey(jar)) { + usedJars.add(jar); + } + } + + public void prepareReport() throws IOException { + Set usedTargets = new HashSet<>(); + Set usedDeps = new HashSet<>(); + + for (String jar : usedJars) { + String target = jarToTarget.get(jar); + + if (target == null) { + target = indirectJarToTarget.get(jar); + } + + if (target.startsWith("Unknown")) { + target = jarLabel(jar); + } + + if (target == null) { + // probably a bug if we get here + continue; + } + + Dependency dep = buildDependency( + jar, + target, + astUsedJars.contains(jar) ? Kind.EXPLICIT : Kind.IMPLICIT, + ignoredTargets.contains(target) + ); + + usedTargets.add(target); + usedDeps.add(dep); + } + + Set unusedDeps = new HashSet<>(); + for (int i = 0; i < ops.directTargets.length; i++) { + String directTarget = ops.directTargets[i]; + if (usedTargets.contains(directTarget)) { + continue; + } + + unusedDeps.add( + buildDependency( + ops.directJars[i], + directTarget, + Kind.UNUSED, + ignoredTargets.contains(directTarget) || "off".equals(ops.unusedDependencyCheckerMode) + ) + ); + } + + writeSdepsFile(usedDeps, unusedDeps); + + Reporter reporter = this.delegateReporter != null ? this.delegateReporter : this; + reportDeps(usedDeps, unusedDeps, reporter); + } + + private Dependency buildDependency(String jar, String target, Kind kind, boolean ignored) { + ScalaDeps.Dependency.Builder dependecyBuilder = ScalaDeps.Dependency.newBuilder(); + + dependecyBuilder.setKind(kind); + dependecyBuilder.setLabel(target); + dependecyBuilder.setIjarPath(jar); + dependecyBuilder.setPath(guessFullJarPath(jar)); + dependecyBuilder.setIgnored(ignored); + + return dependecyBuilder.build(); + } + + private void writeSdepsFile(Collection usedDeps, Collection unusedDeps) + throws IOException { + + ScalaDeps.Dependencies.Builder builder = ScalaDeps.Dependencies.newBuilder(); + builder.setRuleLabel(ops.currentTarget); + builder.setDependencyTrackingMethod(ops.dependencyTrackingMethod); + builder.addAllDependency(usedDeps); + builder.addAllDependency(unusedDeps); + + try (OutputStream outputStream = new BufferedOutputStream( + Files.newOutputStream(Paths.get(ops.scalaDepsFile)))) { + outputStream.write(builder.build().toByteArray()); + } + } + + private void reportDeps(Collection usedDeps, Collection unusedDeps, + Reporter reporter) { + if (ops.dependencyTrackingMethod.equals("ast-plus")) { + + if (!ops.strictDepsMode.equals("off")) { + boolean isWarning = ops.strictDepsMode.equals("warn"); + StringBuilder strictDepsReport = new StringBuilder("Missing strict dependencies:\n"); + StringBuilder compilerDepsReport = new StringBuilder("Missing compiler dependencies:\n"); + int strictDepsCount = 0; + int compilerDepsCount = 0; + for (Dependency dep : usedDeps) { + String depReport = addDepMessage(dep); + if (dep.getIgnored()) { + continue; + } + + if (directTargets.contains(dep.getLabel())) { + continue; + } + + if (dep.getKind() == Kind.EXPLICIT) { + strictDepsCount++; + strictDepsReport + .append(isWarning ? "warning: " : "error: ") + .append(depReport); + } else { + compilerDepsCount++; + compilerDepsReport + .append(isWarning ? "warning: " : "error: ") + .append(depReport); + } + } + + if (strictDepsCount > 0) { + if (ops.strictDepsMode.equals("warn")) { + reporter.warning(NoPosition$.MODULE$, strictDepsReport.toString()); + } else { + reporter.error(NoPosition$.MODULE$, strictDepsReport.toString()); + } + } + + if (!ops.compilerDepsMode.equals("off") && compilerDepsCount > 0) { + if (ops.compilerDepsMode.equals("warn")) { + reporter.warning(NoPosition$.MODULE$, compilerDepsReport.toString()); + } else { + reporter.error(NoPosition$.MODULE$, compilerDepsReport.toString()); + } + } + } + + if (!ops.unusedDependencyCheckerMode.equals("off")) { + boolean isWarning = ops.unusedDependencyCheckerMode.equals("warn"); + StringBuilder unusedDepsReport = new StringBuilder("Unused dependencies:\n"); + int count = 0; + for (Dependency dep : unusedDeps) { + if (dep.getIgnored()) { + continue; + } + count++; + unusedDepsReport + .append(isWarning ? "warning: " : "error: ") + .append(removeDepMessage(dep)); + } + if (count > 0) { + if (isWarning) { + reporter.warning(NoPosition$.MODULE$, unusedDepsReport.toString()); + } else if (ops.unusedDependencyCheckerMode.equals("error")) { + reporter.error(NoPosition$.MODULE$, unusedDepsReport.toString()); + } + } + } + } + } + + private String addDepMessage(Dependency dep) { + String target = dep.getLabel(); + String jar = dep.getPath(); + + String message = "Target '" + target + "' (via jar: ' " + jar + " ') " + + "is being used by " + ops.currentTarget + + " but is is not specified as a dependency, please add it to the deps.\n" + + "You can use the following buildozer command:\n"; + String command = "buildozer 'add deps " + target + "' " + ops.currentTarget + "\n"; + return message + command; + } + + private String removeDepMessage(Dependency dep) { + String target = dep.getLabel(); + String jar = dep.getPath(); + + String message = "Target '" + target + "' (via jar: ' " + jar + " ') " + + "is specified as a dependency to " + ops.currentTarget + + " but isn't used, please remove it from the deps.\n" + + "You can use the following buildozer command:\n"; + String command = "buildozer 'remove deps " + target + "' " + ops.currentTarget + "\n"; + + return message + command; + } + + private String guessFullJarPath(String jar) { + if (jar.endsWith(IJAR_JAR_SUFFIX)) { + return stripIjarSuffix(jar, IJAR_JAR_SUFFIX); + } else if (jar.endsWith(HJAR_JAR_SUFFIX)) { + return stripIjarSuffix(jar, HJAR_JAR_SUFFIX); + } else { + return jar; + } + } + + private static String stripIjarSuffix(String jar, String suffix) { + return jar.substring(0, jar.length() - suffix.length()) + ".jar"; + } + + private String jarLabel(String path) throws IOException { + try (JarFile jar = new JarFile(path)) { + return jar.getManifest().getMainAttributes().getValue("Target-Label"); + } + } + + public void registerAstUsedJars(Set jars) { + astUsedJars = jars; + } + + public void writeDiagnostics(String diagnosticsFile) throws IOException { + if (delegateReporter == null) { + return; + } + + ProtoReporter protoReporter = (ProtoReporter) delegateReporter; + protoReporter.writeTo(Paths.get(diagnosticsFile)); + } +} diff --git a/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/before_2_13_12/DepsTrackingReporter.java b/src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/before_2_12_13/DepsTrackingReporter.java similarity index 100% rename from src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/before_2_13_12/DepsTrackingReporter.java rename to src/java/io/bazel/rulesscala/scalac/deps_tracking_reporter/before_2_12_13/DepsTrackingReporter.java diff --git a/test/diagnostics_reporter/BUILD b/test/diagnostics_reporter/BUILD index 09b1df76a..db3bf7e05 100644 --- a/test/diagnostics_reporter/BUILD +++ b/test/diagnostics_reporter/BUILD @@ -1,13 +1,9 @@ load("@rules_java//java:defs.bzl", "java_binary") -load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION", "SCALA_MINOR_VERSION") java_binary( name = "diagnostics_reporter_test", srcs = [ - "before_2_13_12/DiagnosticsReporterTest.java", - "VerifyDiagnosticsOutput.java", - ] if SCALA_MAJOR_VERSION.startswith("2.11") or SCALA_MAJOR_VERSION.startswith("2.12") or (SCALA_MAJOR_VERSION.startswith("2.13") and int(SCALA_MINOR_VERSION) < 12) else [ - "after_2_13_12/DiagnosticsReporterTest.java", + "DiagnosticsReporterTest.java", "VerifyDiagnosticsOutput.java", ], main_class = "diagnostics_reporter.DiagnosticsReporterTest", diff --git a/test/diagnostics_reporter/after_2_13_12/DiagnosticsReporterTest.java b/test/diagnostics_reporter/DiagnosticsReporterTest.java similarity index 81% rename from test/diagnostics_reporter/after_2_13_12/DiagnosticsReporterTest.java rename to test/diagnostics_reporter/DiagnosticsReporterTest.java index fd9e07c67..e7adcf5df 100644 --- a/test/diagnostics_reporter/after_2_13_12/DiagnosticsReporterTest.java +++ b/test/diagnostics_reporter/DiagnosticsReporterTest.java @@ -15,35 +15,35 @@ public class DiagnosticsReporterTest { "error_file", new diagnostics_reporter.VerifyDiagnosticsOutput[] { new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 5, 2, 6, 0) + Diagnostics.Severity.ERROR, "\')\' expected but \'}\' found.") }); put( "two_errors_file", new diagnostics_reporter.VerifyDiagnosticsOutput[] { new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 4, 4, 4, 10), + Diagnostics.Severity.ERROR, "not found: value printn"), new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 5, 4, 5, 9) + Diagnostics.Severity.ERROR, "not found: value prinf") }); put( "warning_file", new diagnostics_reporter.VerifyDiagnosticsOutput[] { new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.WARNING, 0, 0, 0, 26) + Diagnostics.Severity.WARNING, "Unused import") }); put( "error_and_warning_file", new diagnostics_reporter.VerifyDiagnosticsOutput[] { new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.WARNING, 0, 0, 0, 26), + Diagnostics.Severity.WARNING, "Unused import"), new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 4, 4, 4, 10) + Diagnostics.Severity.ERROR, "not found: value printn") }); put( "info_file", new diagnostics_reporter.VerifyDiagnosticsOutput[] { new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.INFORMATION, -1, -1, 0, 0) + Diagnostics.Severity.INFORMATION, "[running phase parser on InfoFile.scala]") }); } }; diff --git a/test/diagnostics_reporter/VerifyDiagnosticsOutput.java b/test/diagnostics_reporter/VerifyDiagnosticsOutput.java index c5591ed76..9ac2b43f1 100644 --- a/test/diagnostics_reporter/VerifyDiagnosticsOutput.java +++ b/test/diagnostics_reporter/VerifyDiagnosticsOutput.java @@ -11,18 +11,12 @@ class VerifyDiagnosticsOutput { private final Diagnostics.Severity severity; - private final int startLine; - private final int startChar; - private final int endLine; - private final int endChar; + private final String message; VerifyDiagnosticsOutput( - Diagnostics.Severity severity, int startLine, int startChar, int endLine, int endChar) { + Diagnostics.Severity severity, String message) { this.severity = severity; - this.startLine = startLine; - this.startChar = startChar; - this.endLine = endLine; - this.endChar = endChar; + this.message = message; } public static List getDiagnostics(String path) throws IOException { @@ -37,23 +31,14 @@ public void testOutput(List diagnostics) throws NoSuchEl if (diagnostics.stream() .noneMatch( diagnosticInfo -> - diagnosticInfo.getRange().getStart().getLine() == startLine - && diagnosticInfo.getRange().getStart().getCharacter() == startChar - && diagnosticInfo.getRange().getEnd().getLine() == endLine - && diagnosticInfo.getRange().getEnd().getCharacter() == endChar + diagnosticInfo.getMessage().equals(message) && diagnosticInfo.getSeverity().equals(severity))) throw new NoSuchElementException( - "No diagnostics with severity" + "No diagnostics with severity: " + severity - + ", starting line" - + startLine - + " and character" - + startChar - + ", ending line " - + endLine - + " and character " - + endChar - + ", diagnostics found for the target: " + + " and message: " + + message + + ", found amongst diagnostics: " + Arrays.toString(diagnostics.toArray())); } } diff --git a/test/diagnostics_reporter/before_2_13_12/DiagnosticsReporterTest.java b/test/diagnostics_reporter/before_2_13_12/DiagnosticsReporterTest.java deleted file mode 100644 index 24f479689..000000000 --- a/test/diagnostics_reporter/before_2_13_12/DiagnosticsReporterTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package diagnostics_reporter; - -import io.bazel.rules_scala.diagnostics.Diagnostics; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DiagnosticsReporterTest { - @SuppressWarnings("DoubleBraceInitialization") - private static final Map tests = - new HashMap() { - { - put( - "error_file", - new diagnostics_reporter.VerifyDiagnosticsOutput[] { - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 5, 2, 6, 0) - }); - put( - "two_errors_file", - new diagnostics_reporter.VerifyDiagnosticsOutput[] { - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 4, 4, 5, 0), - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 5, 4, 6, 0) - }); - put( - "warning_file", - new diagnostics_reporter.VerifyDiagnosticsOutput[] { - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.WARNING, 0, 0, 0, 7) - }); - put( - "error_and_warning_file", - new diagnostics_reporter.VerifyDiagnosticsOutput[] { - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.WARNING, 0, 0, 0, 7), - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.ERROR, 4, 4, 5, 0) - }); - put( - "info_file", - new diagnostics_reporter.VerifyDiagnosticsOutput[] { - new diagnostics_reporter.VerifyDiagnosticsOutput( - Diagnostics.Severity.INFORMATION, -1, -1, 0, 0) - }); - } - }; - - public static void main(String[] args) throws IOException { - if (args.length != 1) throw new IllegalArgumentException("Args: "); - - String diagnosticsOutput = args[0]; - for (Map.Entry entry : tests.entrySet()) { - String test = entry.getKey(); - VerifyDiagnosticsOutput[] expectedDiagnosticsOutputs = entry.getValue(); - List diagnostics = - VerifyDiagnosticsOutput.getDiagnostics( - diagnosticsOutput + "/" + test + ".diagnosticsproto"); - for (VerifyDiagnosticsOutput expectedDiagnostic : expectedDiagnosticsOutputs) { - expectedDiagnostic.testOutput(diagnostics); - } - } - } -} diff --git a/test/shell/test_diagnostics_reporter.sh b/test/shell/test_diagnostics_reporter.sh index e56366d07..2ceac5445 100755 --- a/test/shell/test_diagnostics_reporter.sh +++ b/test/shell/test_diagnostics_reporter.sh @@ -11,4 +11,11 @@ test_diagnostics_reporter() { bazel run //test/diagnostics_reporter:diagnostics_reporter_test "$diagnostics_output" } +test_diagnostics_reporter_with_semanticdb() { + bazel build --build_event_publish_all_actions -k --extra_toolchains="//test_expect_failure/diagnostics_reporter:diagnostics_reporter_and_semanticdb_toolchain" //test_expect_failure/diagnostics_reporter:all || true + diagnostics_output="$(bazel info bazel-bin)/test_expect_failure/diagnostics_reporter" + bazel run //test/diagnostics_reporter:diagnostics_reporter_test "$diagnostics_output" +} + $runner test_diagnostics_reporter +$runner test_diagnostics_reporter_with_semanticdb \ No newline at end of file diff --git a/test_expect_failure/diagnostics_reporter/BUILD b/test_expect_failure/diagnostics_reporter/BUILD index 2b7ac1ad1..a555a84bc 100644 --- a/test_expect_failure/diagnostics_reporter/BUILD +++ b/test_expect_failure/diagnostics_reporter/BUILD @@ -14,6 +14,20 @@ toolchain( visibility = ["//visibility:public"], ) +scala_toolchain( + name = "diagnostics_reporter_and_semanticdb_toolchain_impl", + enable_diagnostics_report = True, + enable_semanticdb = True, + visibility = ["//visibility:public"], +) + +toolchain( + name = "diagnostics_reporter_and_semanticdb_toolchain", + toolchain = "diagnostics_reporter_and_semanticdb_toolchain_impl", + toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", + visibility = ["//visibility:public"], +) + scala_library( name = "error_file", srcs = ["ErrorFile.scala"], diff --git a/test_version.sh b/test_version.sh index e47ab3c7a..7b9c6b807 100755 --- a/test_version.sh +++ b/test_version.sh @@ -9,6 +9,7 @@ scala_2_13_version="2.13.12" SCALA_VERSION_DEFAULT=$scala_2_11_version diagnostics_reporter_toolchain="//:diagnostics_reporter_toolchain" +diagnostics_reporter_and_semanticdb_toolchain="//:diagnostics_reporter_and_semanticdb_toolchain" no_diagnostics_reporter_toolchain="//:no_diagnostics_reporter_toolchain" compilation_should_fail() { @@ -121,5 +122,12 @@ TEST_TIMEOUT=15 $runner test_reporter "${scala_2_11_version}" "${diagnostics_rep TEST_TIMEOUT=15 $runner test_reporter "${scala_2_12_version}" "${diagnostics_reporter_toolchain}" TEST_TIMEOUT=15 $runner test_reporter "${scala_2_13_version}" "${diagnostics_reporter_toolchain}" -TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_12_version}" "//test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain" -TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_13_version}" "//test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain" +TEST_TIMEOUT=15 $runner test_reporter "${scala_2_11_version}" "${diagnostics_reporter_and_semanticdb_toolchain}" +TEST_TIMEOUT=15 $runner test_reporter "${scala_2_12_version}" "${diagnostics_reporter_and_semanticdb_toolchain}" +TEST_TIMEOUT=15 $runner test_reporter "${scala_2_13_version}" "${diagnostics_reporter_and_semanticdb_toolchain}" + +TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_12_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain +TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_13_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_toolchain + +TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_12_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_and_semanticdb_toolchain +TEST_TIMEOUT=15 $runner test_diagnostic_proto_files "${scala_2_13_version}" //test_expect_failure/diagnostics_reporter:diagnostics_reporter_and_semanticdb_toolchain diff --git a/test_version/test_reporter/BUILD b/test_version/test_reporter/BUILD index b69d11ee8..17fd2016c 100644 --- a/test_version/test_reporter/BUILD +++ b/test_version/test_reporter/BUILD @@ -14,6 +14,20 @@ toolchain( visibility = ["//visibility:public"], ) +scala_toolchain( + name = "diagnostics_reporter_and_semanticdb_toolchain_impl", + enable_diagnostics_report = True, + enable_semanticdb = True, + visibility = ["//visibility:public"], +) + +toolchain( + name = "diagnostics_reporter_and_semanticdb_toolchain", + toolchain = "diagnostics_reporter_and_semanticdb_toolchain_impl", + toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", + visibility = ["//visibility:public"], +) + scala_toolchain( name = "no_diagnostics_reporter_toolchain_impl", visibility = ["//visibility:public"],