Skip to content

Commit 324fcea

Browse files
committed
Add updateCheckFiles to override tests check files with output
Also updated `testFromTasty` checkfiles using it to remove first comment line which cannot be tested on Windows adn added missing EOLs.
1 parent 7ff971f commit 324fcea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+63
-127
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class CompilationTests extends ParallelTesting {
303303
}
304304

305305
object CompilationTests {
306-
implicit val summaryReport: SummaryReporting = new SummaryReport
306+
implicit val summaryReport: SummaryReporting = new SummaryReport(updateCheckFiles = false)
307307
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
308308

309309
def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] = {

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ class FromTastyTests extends ParallelTesting {
5151
}
5252

5353
object FromTastyTests {
54-
implicit val summaryReport: SummaryReporting = new SummaryReport
54+
implicit val summaryReport: SummaryReporting = new SummaryReport(updateCheckFiles = false)
5555
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
5656
}

compiler/test/dotty/tools/dotc/IdempotencyTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ class IdempotencyTests extends ParallelTesting {
7272
}
7373

7474
object IdempotencyTests {
75-
implicit val summaryReport: SummaryReporting = new SummaryReport
75+
implicit val summaryReport: SummaryReporting = new SummaryReport(updateCheckFiles = false)
7676
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
7777
}

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
505505
this
506506
}
507507

508+
protected def updateCheckFile(checkFile: JFile, lines: Seq[String]): Unit = {
509+
val outFile = dotty.tools.io.File(checkFile.toPath)
510+
outFile.writeAll(lines.mkString("", EOL, EOL))
511+
echo("Updated checkfile: " + checkFile.getPath)
512+
}
513+
508514
/** Returns all files in directory or the file if not a directory */
509515
private def flattenFiles(f: JFile): Array[JFile] =
510516
if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -537,28 +543,32 @@ trait ParallelTesting extends RunnerOrchestration { self =>
537543
val output = Source.fromFile(outDir.getParent + "_decompiled" + JFile.separator + outDir.getName
538544
+ JFile.separator + "decompiled.scala", "UTF-8").getLines().map {line =>
539545
stripTrailingWhitespaces.unapplySeq(line).map(_.head).getOrElse(line)
540-
}.toList
546+
}.filter(!_.startsWith(ignoredFilePathLine)).toList
541547

542-
val check: String = Source.fromFile(checkFile, "UTF-8").getLines().filter(!_.startsWith(ignoredFilePathLine))
548+
val check: String = Source.fromFile(checkFile, "UTF-8").getLines()
543549
.mkString(EOL)
544550

545-
if (output.filter(!_.startsWith(ignoredFilePathLine)).mkString(EOL) != check) {
551+
if (output.mkString(EOL) != check) {
546552
val outFile = dotty.tools.io.File(checkFile.toPath).addExtension(".out")
547-
outFile.writeAll(output.mkString(EOL))
548-
val msg =
549-
s"""Output differed for test $name, use the following command to see the diff:
550-
| > diff $checkFile $outFile
553+
if (summaryReport.updateCheckFiles) {
554+
updateCheckFile(checkFile, output)
555+
} else {
556+
outFile.writeAll(output.mkString("", EOL, ""))
557+
val msg =
558+
s"""Output differed for test $name, use the following command to see the diff:
559+
| > diff $checkFile $outFile
551560
""".stripMargin
552561

553-
echo(msg)
554-
addFailureInstruction(msg)
562+
echo(msg)
563+
addFailureInstruction(msg)
555564

556-
// Print build instructions to file and summary:
557-
val buildInstr = testSource.buildInstructions(0, rep.warningCount)
558-
addFailureInstruction(buildInstr)
565+
// Print build instructions to file and summary:
566+
val buildInstr = testSource.buildInstructions(0, rep.warningCount)
567+
addFailureInstruction(buildInstr)
559568

560-
// Fail target:
561-
failTestSource(testSource)
569+
// Fail target:
570+
failTestSource(testSource)
571+
}
562572
}
563573
case _ =>
564574
}
@@ -631,6 +641,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
631641

632642
// Fail target:
633643
failTestSource(testSource)
644+
645+
if (summaryReport.updateCheckFiles)
646+
updateCheckFile(checkFile.get, outputLines)
634647
}
635648
}
636649

@@ -766,7 +779,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
766779
}
767780
def checkFileTest(sourceName: String, checkFile: JFile, actual: List[String]) = {
768781
val expexted = Source.fromFile(checkFile, "UTF-8").getLines().toList
769-
diffMessage(sourceName, actual, expexted).foreach(fail)
782+
for (msg <- diffMessage(sourceName, actual, expexted)) {
783+
fail(msg)
784+
if (summaryReport.updateCheckFiles)
785+
updateCheckFile(checkFile, actual)
786+
}
770787
}
771788

772789
val (compilerCrashed, expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match {

compiler/test/dotty/tools/vulpix/SummaryReport.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ trait SummaryReporting {
4040

4141
/** Echoes contents of `it` to file *immediately* then flushes */
4242
def echoToLog(it: Iterator[String]): Unit
43+
44+
/** Echoes outputs of the test into the thier checkfiles */
45+
def updateCheckFiles: Boolean
4346
}
4447

4548
/** A summary report that doesn't do anything */
@@ -53,12 +56,13 @@ final class NoSummaryReport extends SummaryReporting {
5356
def echoSummary(): Unit = ()
5457
def echoToLog(msg: String): Unit = ()
5558
def echoToLog(it: Iterator[String]): Unit = ()
59+
def updateCheckFiles: Boolean = false
5660
}
5761

5862
/** A summary report that logs to both stdout and the `TestReporter.logWriter`
5963
* which outputs to a log file in `./testlogs/`
6064
*/
61-
final class SummaryReport extends SummaryReporting {
65+
final class SummaryReport(val updateCheckFiles: Boolean) extends SummaryReporting {
6266
import scala.collection.JavaConverters._
6367

6468
private val startingMessages = new java.util.concurrent.ConcurrentLinkedDeque[String]

compiler/test/dotty/tools/vulpix/VulpixMetaTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class VulpixMetaTests extends ParallelTesting {
2020
def isInteractive = false // Don't beautify output for interactive use.
2121
def testFilter = None // Run all the tests.
2222

23-
implicit val summaryReport: SummaryReporting = new SummaryReport
23+
implicit val summaryReport: SummaryReporting = new SummaryReport(updateCheckFiles = false)
2424
implicit def testGroup: TestGroup = TestGroup("VulpixMetaTests")
2525

2626
@Test def compilePos: Unit = compileFilesInDir("tests/vulpix-tests/meta/pos", defaultOptions).checkCompile()

tests/pos/classWithCompObj.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/** Decompiled from out/posTestFromTasty/pos/classWithCompObj/Foo.class */
21
class Foo()
3-
object Foo
2+
object Foo

tests/pos/conforms.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/conforms/Test.class */
21
object Test {
32
def f[A, B](x: A)(implicit e: scala.Predef.<:<[A, B]): B = e.apply(x)
4-
}
3+
}

tests/pos/i0306.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i0306/bar.class */
21
object bar {
32
class C[T <: scala.Seq[_ >: scala.Nothing <: scala.Any]]()
43
val x: scala.AnyRef = new bar.C[scala.collection.Seq[_ >: scala.Nothing <: scala.Any]]()

tests/pos/i1181.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i1181/Test.class */
21
object Test {
32
def foo[M[_$1]](x: M[scala.Int]): M[scala.Int] = x
43
type Alias[A] = scala.Tuple2[A, A]

tests/pos/i1444.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i1444/Test.class */
21
object Test {
32
class Cls(implicit x: Test.X)
43
class ClsImpl() extends Test.Cls()(Test.AnX)
@@ -8,4 +7,4 @@ object Test {
87
class Tr2Impl() extends Test.Tr2()(Test.AnX)
98
trait X() extends java.lang.Object
109
object AnX extends Test.X
11-
}
10+
}

tests/pos/i1570.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i1570/Test.class */
21
object Test {
32
inline def foo(n: scala.Int): scala.Int = Test.bar(n)
43
inline def bar(n: scala.Int): scala.Int = n

tests/pos/i2104b.decompiled

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i2104b/Cons.tasty */
21
trait Cons[+H, +T]() extends java.lang.Object
32
object Cons {
43
def apply[H, T](h: H, t: T): Cons[H, T] = scala.Predef.???
54
def unapply[H, T](t: Cons[H, T]): scala.Option[Pair[H, T]] = scala.Predef.???
65
}
7-
/** Decompiled from out/posTestFromTasty/pos/i2104b/Pair.tasty */
86
case class Pair[A, B](_1: A, _2: B) {
97
override def hashCode(): scala.Int = {
108
var acc: scala.Int = 2479866
@@ -32,10 +30,9 @@ case class Pair[A, B](_1: A, _2: B) {
3230
}
3331
}
3432
object Pair extends scala.AnyRef
35-
/** Decompiled from out/posTestFromTasty/pos/i2104b/Test.tasty */
3633
object Test {
3734
def main(args: scala.Array[scala.Predef.String]): scala.Unit = Cons.apply[scala.Option[scala.Int], scala.None.type](scala.Option.apply[scala.Int](1), scala.None) match {
3835
case Cons(scala.Some(i), scala.None) =>
3936
()
4037
}
41-
}
38+
}

tests/pos/i4526-2.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i4526-2/Foo.class */
21
class Foo(x: scala.Int, y: scala.Int)

tests/pos/i4526a.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i4526a/bar/Foo.class */
21
package bar {
32
class Foo() {
43
protected[bar] def foo(): scala.Int = 0

tests/pos/i4526b.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i4526b/Foo.class */
21
class Foo() {
32
def justdoit(f: scala.Either[scala.Int, scala.Predef.String]): scala.Predef.String = f match {
43
case scala.Left(i) =>

tests/pos/i4678.decompiled

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i4678/Foo.tasty */
21
class Foo() {
32
val x: scala.Int = (1: @annot1 @annot2 @annot3 @annot4 @annot5)
43
}
5-
/** Decompiled from out/posTestFromTasty/pos/i4678/annot1.tasty */
64
class annot1() extends scala.annotation.Annotation
7-
/** Decompiled from out/posTestFromTasty/pos/i4678/annot2.tasty */
85
class annot2() extends scala.annotation.Annotation
9-
/** Decompiled from out/posTestFromTasty/pos/i4678/annot3.tasty */
106
class annot3() extends scala.annotation.Annotation
11-
/** Decompiled from out/posTestFromTasty/pos/i4678/annot4.tasty */
127
class annot4() extends scala.annotation.Annotation
13-
/** Decompiled from out/posTestFromTasty/pos/i4678/annot5.tasty */
14-
class annot5() extends scala.annotation.Annotation
8+
class annot5() extends scala.annotation.Annotation

tests/pos/i566.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/i566/Test.class */
21
class Test() {
32
type T = scala.Predef.String
43
type U

tests/pos/lambda.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/lambda/foo/Foo.class */
21
package foo {
32
class Foo() {
43
((x: scala.Int) => 2)

tests/pos/methodTypes.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/methodTypes/Foo.class */
21
class Foo() {
32
val x: scala.Int = 1
43
def y: scala.Int = 2

tests/pos/selftypes.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/selftypes/selftypes.class */
21
object selftypes {
32
trait A() extends java.lang.Object { self: selftypes.AB =>
43
type AA = scala.List[this.BX]

tests/pos/simple-repeated-args.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simple-repeated-args/Foo.class */
21
class Foo() {
32
scala.List.apply[scala.Any](1, "2", '3')
43
scala.Array.apply(1)

tests/pos/simpleAnnot.decompiled

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleAnnot/Foo.tasty */
21
class Foo() {
32
@annot type A = scala.Int
43
@annot val a: scala.Int = scala.Predef.???
54
val b: scala.Int @annot = scala.Predef.???
65
def c(x: scala.Int): scala.Int = (x: @annot)
76
}
8-
/** Decompiled from out/posTestFromTasty/pos/simpleAnnot/annot.tasty */
9-
class annot() extends scala.annotation.Annotation
7+
class annot() extends scala.annotation.Annotation

tests/pos/simpleCaseClass-1.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleCaseClass-1/A.tasty */
21
case class A() {
32
override def hashCode(): scala.Int = 1914112431
43
override def equals(x$0: scala.Any): scala.Boolean = A.this.eq(x$0.asInstanceOf[java.lang.Object]).||(x$0 match {
@@ -16,4 +15,4 @@ case class A() {
1615
throw new java.lang.IndexOutOfBoundsException(n.toString())
1716
}
1817
}
19-
object A extends scala.Function0[A]
18+
object A extends scala.Function0[A]

tests/pos/simpleCaseClass-2.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleCaseClass-2/A.tasty */
21
case class A(x: scala.Int) {
32
override def hashCode(): scala.Int = {
43
var acc: scala.Int = 65
@@ -22,4 +21,4 @@ case class A(x: scala.Int) {
2221
throw new java.lang.IndexOutOfBoundsException(n.toString())
2322
}
2423
}
25-
object A extends scala.Function1[scala.Int, A]
24+
object A extends scala.Function1[scala.Int, A]

tests/pos/simpleCaseClass-3.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleCaseClass-3/A.tasty */
21
case class A[T](x: T) {
32
override def hashCode(): scala.Int = {
43
var acc: scala.Int = 65
@@ -22,4 +21,4 @@ case class A[T](x: T) {
2221
throw new java.lang.IndexOutOfBoundsException(n.toString())
2322
}
2423
}
25-
object A extends scala.AnyRef
24+
object A extends scala.AnyRef

tests/pos/simpleCaseObject.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleCaseObject/foo/Foo.tasty */
21
package foo {
32
case object Foo {
43
override def hashCode(): scala.Int = 1045991777
@@ -11,4 +10,4 @@ package foo {
1110
throw new java.lang.IndexOutOfBoundsException(n.toString())
1211
}
1312
}
14-
}
13+
}

tests/pos/simpleClass-2.decompiled

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleClass-2/foo/A.tasty */
21
package foo {
32
class A() extends foo.B
43
}
5-
/** Decompiled from out/posTestFromTasty/pos/simpleClass-2/foo/B.tasty */
64
package foo {
75
class B()
8-
}
6+
}

tests/pos/simpleClass-3.decompiled

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleClass-3/A.class */
21
class A() extends B with C
3-
/** Decompiled from out/posTestFromTasty/pos/simpleClass-3/B.class */
42
trait B() extends java.lang.Object
5-
/** Decompiled from out/posTestFromTasty/pos/simpleClass-3/C.class */
6-
trait C() extends java.lang.Object
3+
trait C() extends java.lang.Object

tests/pos/simpleClass.decompiled

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleClass/foo/A.tasty */
21
package foo {
32
class A()
43
}
5-
/** Decompiled from out/posTestFromTasty/pos/simpleClass/foo/B.tasty */
64
package foo {
75
class B() extends foo.A
8-
}
6+
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleConstructor/A.class */
21
class A(a: scala.Int, val b: scala.Int, var c: scala.Int)
3-
/** Decompiled from out/posTestFromTasty/pos/simpleConstructor/B.class */
42
class B(protected val x: scala.Int, protected[B] val y: scala.Int, private[B] val z: scala.Int)

tests/pos/simpleDoWhile.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleDoWhile/Foo.class */
21
class Foo() {
32
def foo: scala.Unit = {
43
var i: scala.Int = 1

tests/pos/simpleExtractors-1.decompiled

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleExtractors-1/Bar.class */
21
object Bar {
32
def unapply(arg: scala.Any): scala.Option[scala.Any] = scala.Some.apply[scala.Any](arg)
43
}
5-
/** Decompiled from out/posTestFromTasty/pos/simpleExtractors-1/BarSeq.class */
64
object BarSeq {
75
def unapplySeq(arg: scala.Any): scala.Option[scala.Seq[scala.Any]] = scala.Some.apply[collection.immutable.List[scala.Any]](scala.List.apply[scala.Any](arg))
86
}
9-
/** Decompiled from out/posTestFromTasty/pos/simpleExtractors-1/Baz.class */
107
object Baz {
118
def unapply[T](arg: T): scala.Option[T] = scala.Some.apply[T](arg)
129
}
13-
/** Decompiled from out/posTestFromTasty/pos/simpleExtractors-1/BazSeq.class */
1410
object BazSeq {
1511
def unapplySeq[T](arg: T): scala.Option[scala.Seq[T]] = scala.Some.apply[collection.immutable.List[T]](scala.List.apply[T](arg))
1612
}
17-
/** Decompiled from out/posTestFromTasty/pos/simpleExtractors-1/Foo.class */
1813
class Foo() {
1914
def bar(x: scala.Any): scala.Unit = x match {
2015
case Bar(a) =>

tests/pos/simpleExtractors-2.decompiled

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleExtractors-2/Foo.class */
21
class Foo() {
32
def bar(x: scala.Any): scala.Unit = x match {
43
case scala.Some(scala.Some(i: scala.Int)) =>

tests/pos/simpleInline.decompiled

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/** Decompiled from out/posTestFromTasty/pos/simpleInline/Foo.class */
21
class Foo() {
32
inline def foo: scala.Int = (9: scala.Int)
43
def bar: scala.Int = (9: scala.Int)
5-
}
4+
}

0 commit comments

Comments
 (0)