Skip to content

Commit bfd72c2

Browse files
committed
Pass command line options to ReplTest constructor (with default)
This permits constructing tests that depend on particular command line options such as `-Xprint:typer`
1 parent ef48716 commit bfd72c2

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

compiler/test/dotty/tools/repl/ReplTest.scala

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,8 @@ import dotty.tools.dotc.reporting.MessageRendering
1616
import org.junit.{After, Before}
1717
import org.junit.Assert._
1818

19-
20-
class ReplTest(withStaging: Boolean = false, out: ByteArrayOutputStream = new ByteArrayOutputStream) extends ReplDriver(
21-
Array(
22-
"-classpath",
23-
if (withStaging)
24-
TestConfiguration.withStagingClasspath
25-
else
26-
TestConfiguration.basicClasspath,
27-
"-color:never",
28-
"-Yerased-terms",
29-
),
30-
new PrintStream(out, true, StandardCharsets.UTF_8.name)
31-
) with MessageRendering {
19+
class ReplTest(options: Array[String] = ReplTest.defaultOptions, out: ByteArrayOutputStream = new ByteArrayOutputStream)
20+
extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.name)) with MessageRendering {
3221
/** Get the stored output from `out`, resetting the buffer */
3322
def storedOutput(): String = {
3423
val output = stripColor(out.toString(StandardCharsets.UTF_8.name))
@@ -103,3 +92,8 @@ class ReplTest(withStaging: Boolean = false, out: ByteArrayOutputStream = new By
10392
end if
10493
}
10594
}
95+
96+
object ReplTest:
97+
val commonOptions = Array("-color:never", "-Yerased-terms")
98+
val defaultOptions = commonOptions ++ Array("-classpath", TestConfiguration.basicClasspath)
99+
lazy val withStagingOptions = commonOptions ++ Array("-classpath", TestConfiguration.withStagingClasspath)

staging/test/scala/quoted/staging/repl/StagingScriptedReplTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.junit.Test
88
import org.junit.experimental.categories.Category
99

1010
/** Runs all tests contained in `staging/test-resources/repl-staging` */
11-
class StagingScriptedReplTests extends ReplTest(withStaging = true) {
11+
class StagingScriptedReplTests extends ReplTest(ReplTest.withStagingOptions) {
1212

1313
@Category(Array(classOf[BootstrappedOnlyTests]))
1414
@Test def replStagingTests = scripts("/repl-staging").foreach(testFile)

0 commit comments

Comments
 (0)