Skip to content

Commit aa27753

Browse files
committed
Add test for --show-rendered-message flag.
1 parent 0cb4305 commit aa27753

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

frontend/src/test/scala/bloop/bsp/BspCompileSpec.scala

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,4 +1423,38 @@ class BspCompileSpec(
14231423
}
14241424
}
14251425

1426+
test("compile and return rendered message") {
1427+
TestUtil.withinWorkspace { workspace =>
1428+
val sources = List(
1429+
"""/main/scala/Foo.scala
1430+
|def foo(s: String): Int = s
1431+
""".stripMargin
1432+
)
1433+
1434+
val logger = new RecordingLogger(ansiCodesSupported = false)
1435+
val `A` = TestProject(workspace, "a", sources, scalaVersion = Some("3.3.7"))
1436+
val projects = List(`A`)
1437+
1438+
loadBspState(workspace, projects, logger) { state =>
1439+
val compiledState = state.compile(`A`, arguments = Some(List("--show-rendered-message")))
1440+
assertExitStatus(compiledState, ExitStatus.CompilationError)
1441+
assertNoDiff(
1442+
// Remove ANSI escape codes
1443+
compiledState.lastDiagnostics(`A`).replaceAll("\u001B\\[[;\\d]*m", ""),
1444+
s"""
1445+
|#1: task start 1
1446+
| -> Msg: Compiling a (1 Scala source)
1447+
| -> Data kind: compile-task
1448+
|#1: a/src/main/scala/Foo.scala
1449+
| -> List(Diagnostic(Range(Position(0,26),Position(0,27)),Some(Error),Some(_),Some(_),-- [E007] Type Mismatch Error: $workspace/a/src/main/scala/Foo.scala:1:26 1 |def foo(s: String): Int = s | ^ | Found: (s : String) | Required: Int | | longer explanation available when compiling with `-explain`,None,None,Some({"actions":[]})))
1450+
| -> reset = true
1451+
|#1: task finish 1
1452+
| -> errors 1, warnings 0
1453+
| -> Msg: Compiled 'a'
1454+
| -> Data kind: compile-report """.stripMargin
1455+
)
1456+
}
1457+
}
1458+
}
1459+
14261460
}

0 commit comments

Comments
 (0)