File tree 2 files changed +23
-2
lines changed
compiler/test/dotty/tools
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class PatmatExhaustivityTest {
45
45
val baseFilePath = path.toString.stripSuffix(" .scala" )
46
46
val checkFilePath = baseFilePath + " .check"
47
47
48
- FileDiff .checkAndDump (path.toString, actualLines, checkFilePath)
48
+ FileDiff .checkAndDumpOrUpdate (path.toString, actualLines, checkFilePath)
49
49
}
50
50
51
51
/** A single test with multiple files grouped in a folder */
@@ -57,13 +57,17 @@ class PatmatExhaustivityTest {
57
57
val actualLines = compile(files)
58
58
val checkFilePath = s " ${path}${File .separator}expected.check "
59
59
60
- FileDiff .checkAndDump (path.toString, actualLines, checkFilePath)
60
+ FileDiff .checkAndDumpOrUpdate (path.toString, actualLines, checkFilePath)
61
61
}
62
62
63
63
@ Test
64
64
def patmatExhaustivity : Unit = {
65
65
val res = Directory (testsDir).list.toList
66
66
.filter(f => f.extension == " scala" || f.isDirectory)
67
+ .filter { f =>
68
+ val path = if f.isDirectory then f.path + " /" else f.path
69
+ path.contains(Properties .testsFilter.getOrElse(" " ))
70
+ }
67
71
.map(f => if f.isDirectory then compileDir(f.jpath) else compileFile(f.jpath))
68
72
69
73
val failed = res.filter(! _)
Original file line number Diff line number Diff line change @@ -63,4 +63,21 @@ object FileDiff {
63
63
}
64
64
}
65
65
66
+ def checkAndDumpOrUpdate (sourceTitle : String , actualLines : Seq [String ], checkFilePath : String ): Boolean = {
67
+ val outFilePath = checkFilePath + " .out"
68
+ FileDiff .check(sourceTitle, actualLines, checkFilePath) match {
69
+ case Some (msg) if dotty.Properties .testsUpdateCheckfile =>
70
+ FileDiff .dump(checkFilePath, actualLines)
71
+ println(" Updated checkfile: " + checkFilePath)
72
+ false
73
+ case Some (msg) =>
74
+ FileDiff .dump(outFilePath, actualLines)
75
+ println(msg)
76
+ println(FileDiff .diffMessage(checkFilePath, outFilePath))
77
+ false
78
+ case _ =>
79
+ Files .deleteIfExists(Paths .get(outFilePath))
80
+ true
81
+ }
82
+ }
66
83
}
You can’t perform that action at this time.
0 commit comments