aboutsummaryrefslogtreecommitdiff
path: root/test/test/CompilerTest.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/test/CompilerTest.scala')
-rw-r--r--test/test/CompilerTest.scala18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala
index 678ef74b1..739bba46d 100644
--- a/test/test/CompilerTest.scala
+++ b/test/test/CompilerTest.scala
@@ -10,6 +10,7 @@ import scala.reflect.io.{ Path, Directory, File => SFile, AbstractFile }
import scala.tools.partest.nest.{ FileManager, NestUI }
import scala.annotation.tailrec
import java.io.{ RandomAccessFile, File => JFile }
+import dotty.tools.io.PlainFile
import org.junit.Test
@@ -89,7 +90,20 @@ abstract class CompilerTest {
if (!generatePartestFiles || !partestableFile(prefix, fileName, extension, args ++ defaultOptions)) {
if (runTest)
log(s"WARNING: run tests can only be run by partest, JUnit just verifies compilation: $prefix$fileName$extension")
- compileArgs((s"$filePath" :: args).toArray, expErrors)
+ if (args.contains("-rewrite")) {
+ val file = new PlainFile(filePath)
+ val data = file.toByteArray
+ val cs = data.map(_.toChar)
+ println(s"data = ${cs.mkString}")
+ compileArgs((filePath :: args).toArray, expErrors)
+ val plainArgs = args.filter(arg => arg != "-rewrite" && arg != "-language:Scala2")
+ println(s"plainArgs = $plainArgs")
+ compileFile(prefix, fileName, plainArgs, extension, runTest)
+ val out = file.output
+ out.write(data)
+ out.close()
+ }
+ else compileArgs((filePath :: args).toArray, expErrors)
} else {
val kind = testKind(prefix, runTest)
log(s"generating partest files for test file: $prefix$fileName$extension of kind $kind")
@@ -191,6 +205,8 @@ abstract class CompilerTest {
}
}
+
+
// ========== HELPERS =============
private def expectedErrors(filePaths: List[String]): List[ErrorsInFile] = if (filePaths.exists(isNegTest(_))) filePaths.map(getErrors(_)) else Nil