Skip to content

Commit eb6cdbb

Browse files
committed
Fix GradleBuildToolSuite after ANSI tweaks
Previously, the tests assumed that the output from Gradle/Maven went straight to `System.{out,error}`. Now, the output goes through Moped and it gets captured for testing purposes.
1 parent 5d53c0c commit eb6cdbb

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class BaseBuildToolSuite extends MopedSuite(LsifJava.app) {
3737
original: String,
3838
expectedSemanticdbFiles: Int = 0,
3939
extraArguments: List[String] = Nil,
40-
expectedError: String = "",
40+
expectedError: Option[String => Unit] = None,
4141
expectedPackages: String = "",
4242
initCommand: => List[String] = Nil
4343
): Unit = {
@@ -59,11 +59,12 @@ abstract class BaseBuildToolSuite extends MopedSuite(LsifJava.app) {
5959
if (extraArguments.contains("--verbose")) {
6060
println(app.capturedOutput)
6161
}
62-
if (expectedError.nonEmpty) {
63-
assert(clue(exit) != 0, clues(app.capturedOutput))
64-
assertNoDiff(app.capturedOutput, expectedError)
65-
} else {
66-
assertEquals(exit, 0, clues(app.capturedOutput))
62+
expectedError match {
63+
case Some(fn) =>
64+
assert(clue(exit) != 0, clues(app.capturedOutput))
65+
fn(app.capturedOutput)
66+
case None =>
67+
assertEquals(exit, 0, clues(app.capturedOutput))
6768
}
6869
val semanticdbFiles =
6970
if (!Files.isDirectory(targetroot))

tests/buildTools/src/test/scala/tests/GradleBuildToolSuite.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ class GradleBuildToolSuite extends BaseBuildToolSuite {
103103
|/src/main/java/Example.java
104104
|public class Example {}
105105
|""".stripMargin,
106-
expectedError =
107-
"""|info: /workingDirectory/gradlew --init-script /cache/java-toolchains.gradle lsifDetectJavaToolchains
108-
|error: lsif-java does not support Gradle 6.7 when used together with Java toolchains. To fix this problem, upgrade to Gradle version 6.8 or newer and try again.
109-
|""".stripMargin,
106+
expectedError = Some { error =>
107+
assert(
108+
clue(error).contains(
109+
"""error: lsif-java does not support Gradle 6.7 when used together with Java toolchains. To fix this problem, upgrade to Gradle version 6.8 or newer and try again."""
110+
)
111+
)
112+
},
110113
initCommand = gradleVersion("6.7")
111114
)
112115

0 commit comments

Comments
 (0)