-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5743: Add check files to neg tests #5852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,23 +616,12 @@ trait ParallelTesting extends RunnerOrchestration { self => | |
else runMain(testSource.runClassPath) match { | ||
case Success(_) if !checkFile.isDefined || !checkFile.get.exists => // success! | ||
case Success(output) => { | ||
val outputLines = output.linesIterator.toArray :+ DiffUtil.EOF | ||
val checkLines: Array[String] = Source.fromFile(checkFile.get, "UTF-8").getLines().toArray :+ DiffUtil.EOF | ||
val outputLines = output.linesIterator.toSeq | ||
val checkLines: Seq[String] = Source.fromFile(checkFile.get, "UTF-8").getLines().toSeq | ||
val sourceTitle = testSource.title | ||
|
||
def linesMatch = | ||
outputLines | ||
.zip(checkLines) | ||
.forall { case (x, y) => x == y } | ||
diffMessage(sourceTitle, outputLines, checkLines).foreach { msg => | ||
|
||
if (outputLines.length != checkLines.length || !linesMatch) { | ||
// Print diff to files and summary: | ||
val diff = DiffUtil.mkColoredLineDiff(checkLines, outputLines) | ||
|
||
val msg = | ||
s"""|Output from '$sourceTitle' did not match check file. | ||
|Diff (expected on the left, actual right): | ||
|""".stripMargin + diff + "\n" | ||
echo(msg) | ||
addFailureInstruction(msg) | ||
|
||
|
@@ -765,13 +754,34 @@ trait ParallelTesting extends RunnerOrchestration { self => | |
} | ||
} | ||
|
||
def fail(msg: String): Unit = { | ||
echo(msg) | ||
failTestSource(testSource) | ||
} | ||
|
||
def reporterOutputLines(reporters: List[TestReporter]): List[String] = { | ||
reporters.flatMap(_.allErrors).sortBy(_.pos.source.toString).flatMap { error => | ||
(error.pos.span.toString + " in " + error.pos.source.file.name) :: error.getMessage().lines.toList | ||
} | ||
} | ||
def checkFileTest(sourceName: String, checkFile: JFile, actual: List[String]) = { | ||
val expexted = Source.fromFile(checkFile, "UTF-8").getLines().toList | ||
diffMessage(sourceName, actual, expexted).foreach(fail) | ||
} | ||
|
||
val (compilerCrashed, expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match { | ||
case testSource @ JointCompilationSource(_, files, flags, outDir, fromTasty, decompilation) => | ||
val sourceFiles = testSource.sourceFiles | ||
val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(sourceFiles) | ||
val reporter = compile(sourceFiles, flags, true, outDir) | ||
val actualErrors = reporter.errorCount | ||
|
||
files.foreach { file => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is the way it works for |
||
if (!file.isDirectory) { | ||
val checkFile = new JFile(file.getAbsolutePath.replaceFirst("\\.scala$", ".check")) | ||
if (checkFile.exists) | ||
checkFileTest(testSource.title, checkFile, reporterOutputLines(reporter :: Nil)) | ||
} | ||
} | ||
if (reporter.compilerCrashed || actualErrors > 0) | ||
logReporterContents(reporter) | ||
|
||
|
@@ -788,14 +798,14 @@ trait ParallelTesting extends RunnerOrchestration { self => | |
if (actualErrors > 0) | ||
reporters.foreach(logReporterContents) | ||
|
||
val checkFile = new JFile(dir.getAbsolutePath + ".check") | ||
if (checkFile.exists) | ||
checkFileTest(testSource.title, checkFile, reporterOutputLines(reporters)) | ||
|
||
(compilerCrashed, expectedErrors, actualErrors, () => getMissingExpectedErrors(errorMap, errors), errorMap) | ||
} | ||
} | ||
|
||
def fail(msg: String): Unit = { | ||
echo(msg) | ||
failTestSource(testSource) | ||
} | ||
|
||
if (compilerCrashed) | ||
fail(s"Compiler crashed when compiling: ${testSource.title}") | ||
|
@@ -839,6 +849,22 @@ trait ParallelTesting extends RunnerOrchestration { self => | |
} | ||
} | ||
|
||
def diffMessage(sourceTitle: String, outputLines: Seq[String], checkLines: Seq[String]): Option[String] = { | ||
def linesMatch = | ||
(outputLines, checkLines).zipped.forall(_ == _) | ||
|
||
if (outputLines.length != checkLines.length || !linesMatch) { | ||
// Print diff to files and summary: | ||
val diff = DiffUtil.mkColoredLineDiff(checkLines :+ DiffUtil.EOF, outputLines :+ DiffUtil.EOF) | ||
|
||
Some( | ||
s"""|Output from '$sourceTitle' did not match check file. | ||
|Diff (expected on the left, actual right): | ||
|""".stripMargin + diff + "\n") | ||
} else None | ||
|
||
} | ||
|
||
/** The `CompilationTest` is the main interface to `ParallelTesting`, it | ||
* can be instantiated via one of the following methods: | ||
* | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[181..202] in classOf.scala | ||
Test.C{I = String} is not a class type | ||
[116..117] in classOf.scala | ||
T is not a class type | ||
[72..73] in classOf.scala | ||
T is not a class type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[199..207] in i4382.scala | ||
unreducible application of higher-kinded type App.HkAbs to wildcard arguments | ||
[149..155] in i4382.scala | ||
unreducible application of higher-kinded type App.HkU to wildcard arguments | ||
[97..103] in i4382.scala | ||
unreducible application of higher-kinded type App.HkL to wildcard arguments | ||
[46..51] in i4382.scala | ||
unreducible application of higher-kinded type App.Id to wildcard arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<267..267> in i5311.scala | ||
Found: s.T[Int] => s.T[Int] | ||
Required: m.Foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[123..124] in kinds2.scala | ||
missing type parameter(s) for C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[12..15] in A.scala | ||
Not found: foo | ||
[12..15] in B.scala | ||
Not found: bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class A { | ||
foo() // error | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class B { | ||
bar() // error | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[48..51..58] in Test_2.scala | ||
foo cannot be called with false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[48..51..58] in Test_2.scala | ||
foo cannot be called with false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<230..230> in subtyping.scala | ||
Cannot prove that a.T <:< a.U.. | ||
I found: | ||
|
||
$conforms[Nothing] | ||
|
||
But method $conforms in object Predef does not match type a.T <:< a.U. | ||
<106..106> in subtyping.scala | ||
Cannot prove that B#X <:< A#X.. | ||
I found: | ||
|
||
$conforms[Nothing] | ||
|
||
But method $conforms in object Predef does not match type B#X <:< A#X. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
t6663.scala:16: error: type mismatch; | ||
found : String | ||
required: Int | ||
var v = new C(42).foo[String].get :Int | ||
^ | ||
one error found | ||
[473..495..498] in t6663.scala | ||
Found: String | ||
Required: Int |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[68..69] in kinds1.scala | ||
Type argument Test.C has not the same kind as its bound |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.