Skip to content

Commit 2961971

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

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package bloop.bsp
22

3+
import java.io.File
34
import java.nio.file.Files
45
import java.nio.file.attribute.FileTime
56
import java.time.Instant
@@ -1423,4 +1424,39 @@ class BspCompileSpec(
14231424
}
14241425
}
14251426

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

0 commit comments

Comments
 (0)