Skip to content

Commit

Permalink
Pass command line options to ReplTest constructor (with default)
Browse files Browse the repository at this point in the history
This permits constructing tests that depend on particular command
line options such as `-Xprint:typer`
  • Loading branch information
griggt committed Feb 9, 2021
1 parent ef48716 commit bfd72c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions compiler/test/dotty/tools/repl/ReplTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,8 @@ import dotty.tools.dotc.reporting.MessageRendering
import org.junit.{After, Before}
import org.junit.Assert._


class ReplTest(withStaging: Boolean = false, out: ByteArrayOutputStream = new ByteArrayOutputStream) extends ReplDriver(
Array(
"-classpath",
if (withStaging)
TestConfiguration.withStagingClasspath
else
TestConfiguration.basicClasspath,
"-color:never",
"-Yerased-terms",
),
new PrintStream(out, true, StandardCharsets.UTF_8.name)
) with MessageRendering {
class ReplTest(options: Array[String] = ReplTest.defaultOptions, out: ByteArrayOutputStream = new ByteArrayOutputStream)
extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.name)) with MessageRendering {
/** Get the stored output from `out`, resetting the buffer */
def storedOutput(): String = {
val output = stripColor(out.toString(StandardCharsets.UTF_8.name))
Expand Down Expand Up @@ -103,3 +92,8 @@ class ReplTest(withStaging: Boolean = false, out: ByteArrayOutputStream = new By
end if
}
}

object ReplTest:
val commonOptions = Array("-color:never", "-Yerased-terms")
val defaultOptions = commonOptions ++ Array("-classpath", TestConfiguration.basicClasspath)
lazy val withStagingOptions = commonOptions ++ Array("-classpath", TestConfiguration.withStagingClasspath)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.junit.Test
import org.junit.experimental.categories.Category

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

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

0 comments on commit bfd72c2

Please sign in to comment.