Skip to content

Fix #3581: Reorganise neg tests #3612

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 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class tests extends CompilerTest {

@Test def negVarargsT1625 = compileFiles(negDir + "varargsInMethodsT1625/")

val negCustomArgs = negDir + "customArgs/"
val negCustomArgs = testsDir + "neg-custom-args/"

@Test def neg_typers() = compileFile(negCustomArgs, "typers")(allowDoubleBindings)
@Test def neg_overrideClass = compileFile(negCustomArgs, "overrideClass", scala2mode)
Expand All @@ -198,7 +198,7 @@ class tests extends CompilerTest {
@Test def neg_valueclasses_pavlov = compileFile(negCustomArgs, "valueclasses-pavlov")(allowDoubleBindings)
@Test def neg_trailingUnderscore = compileFile(negCustomArgs, "trailingUnderscore", args = "-strict" :: Nil)

val negTailcallDir = negDir + "tailcall/"
val negTailcallDir = testsDir + "neg-tailcall/"
@Test def neg_tailcall_t1672b = compileFile(negTailcallDir, "t1672b")
@Test def neg_tailcall_t3275 = compileFile(negTailcallDir, "t3275")
@Test def neg_tailcall_t6574 = compileFile(negTailcallDir, "t6574")
Expand Down
55 changes: 27 additions & 28 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CompilationTests extends ParallelTesting {
compileDir("../tests/pos/i1137-1", defaultOptions and "-Yemit-tasty") +
compileFile(
// succeeds despite -Xfatal-warnings because of -nowarn
"../tests/neg/customArgs/xfatalWarnings.scala",
"../tests/neg-custom-args/xfatalWarnings.scala",
defaultOptions.and("-nowarn", "-Xfatal-warnings")
)
}.checkCompile()
Expand Down Expand Up @@ -165,30 +165,25 @@ class CompilationTests extends ParallelTesting {

@Test def compileNeg: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNeg")
compileShallowFilesInDir("../tests/neg", defaultOptions) +
compileShallowFilesInDir("../tests/neg/no-optimise", defaultOptions) +
compileFile("../tests/neg/customArgs/typers.scala", allowDoubleBindings) +
compileFile("../tests/neg/customArgs/overrideClass.scala", scala2Mode) +
compileFile("../tests/neg/customArgs/autoTuplingTest.scala", defaultOptions.and("-language:noAutoTupling")) +
compileFile("../tests/neg/customArgs/i1050.scala", defaultOptions.and("-strict")) +
compileFile("../tests/neg/customArgs/i1240.scala", allowDoubleBindings) +
compileFile("../tests/neg/customArgs/i2002.scala", allowDoubleBindings) +
compileFile("../tests/neg/customArgs/nopredef.scala", defaultOptions.and("-Yno-predef")) +
compileFile("../tests/neg/customArgs/noimports.scala", defaultOptions.and("-Yno-imports")) +
compileFile("../tests/neg/customArgs/noimports2.scala", defaultOptions.and("-Yno-imports")) +
compileFile("../tests/neg/customArgs/overloadsOnAbstractTypes.scala", allowDoubleBindings) +
compileFile("../tests/neg/customArgs/xfatalWarnings.scala", defaultOptions.and("-Xfatal-warnings")) +
compileFile("../tests/neg/customArgs/pureStatement.scala", defaultOptions.and("-Xfatal-warnings")) +
compileFile("../tests/neg/customArgs/phantom-overload.scala", allowDoubleBindings) +
compileFile("../tests/neg/customArgs/phantom-overload-2.scala", allowDoubleBindings) +
compileFile("../tests/neg/tailcall/t1672b.scala", defaultOptions) +
compileFile("../tests/neg/tailcall/t3275.scala", defaultOptions) +
compileFile("../tests/neg/tailcall/t6574.scala", defaultOptions) +
compileFile("../tests/neg/tailcall/tailrec.scala", defaultOptions) +
compileFile("../tests/neg/tailcall/tailrec-2.scala", defaultOptions) +
compileFile("../tests/neg/tailcall/tailrec-3.scala", defaultOptions) +
compileFile("../tests/neg/i3246.scala", scala2Mode) +
compileDir("../tests/neg/typedIdents", defaultOptions)
compileFilesInDir("../tests/neg", defaultOptions) +
compileFilesInDir("../tests/neg-tailcall", defaultOptions) +
compileFilesInDir("../tests/neg-no-optimise", defaultOptions) +
compileFile("../tests/neg-custom-args/i3246.scala", scala2Mode) +
compileFile("../tests/neg-custom-args/typers.scala", allowDoubleBindings) +
compileFile("../tests/neg-custom-args/overrideClass.scala", scala2Mode) +
compileFile("../tests/neg-custom-args/autoTuplingTest.scala", defaultOptions.and("-language:noAutoTupling")) +
compileFile("../tests/neg-custom-args/i1050.scala", defaultOptions.and("-strict")) +
compileFile("../tests/neg-custom-args/i1240.scala", allowDoubleBindings) +
compileFile("../tests/neg-custom-args/i2002.scala", allowDoubleBindings) +
compileFile("../tests/neg-custom-args/nopredef.scala", defaultOptions.and("-Yno-predef")) +
compileFile("../tests/neg-custom-args/noimports.scala", defaultOptions.and("-Yno-imports")) +
compileFile("../tests/neg-custom-args/noimports2.scala", defaultOptions.and("-Yno-imports")) +
compileFile("../tests/neg-custom-args/overloadsOnAbstractTypes.scala", allowDoubleBindings) +
compileFile("../tests/neg-custom-args/xfatalWarnings.scala", defaultOptions.and("-Xfatal-warnings")) +
compileFile("../tests/neg-custom-args/pureStatement.scala", defaultOptions.and("-Xfatal-warnings")) +
compileFile("../tests/neg-custom-args/phantom-overload.scala", allowDoubleBindings) +
compileFile("../tests/neg-custom-args/phantom-overload-2.scala", allowDoubleBindings) +
compileFile("../tests/neg-custom-args/structural.scala", defaultOptions.and("-Xfatal-warnings"))
}.checkExpectedErrors()

// Run tests -----------------------------------------------------------------
Expand Down Expand Up @@ -311,7 +306,7 @@ class CompilationTests extends ParallelTesting {
implicit val testGroup: TestGroup = TestGroup("optimised/testOptimised")
compileFilesInDir("../tests/pos", defaultOptimised).checkCompile()
compileFilesInDir("../tests/run", defaultOptimised).checkRuns()
compileShallowFilesInDir("../tests/neg", defaultOptimised).checkExpectedErrors()
compileFilesInDir("../tests/neg", defaultOptimised).checkExpectedErrors()
}

private val (compilerSources, backendSources, backendJvmSources) = {
Expand Down Expand Up @@ -340,10 +335,14 @@ object CompilationTests {
implicit val summaryReport: SummaryReporting = new SummaryReport
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()

def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] =
paths.iterator().asScala
def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] = {
val sources = paths.iterator().asScala
.filter(path =>
(path.toString.endsWith(".scala") || path.toString.endsWith(".java"))
&& !excludedFiles.contains(path.getFileName.toString))
.map(_.toString).toList

paths.close()
sources
}
}
3 changes: 2 additions & 1 deletion compiler/test/dotty/tools/dotc/CompilerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ abstract class CompilerTest {

private def expectedErrors(filePath: String): List[ErrorsInFile] = expectedErrors(List(filePath))

private def isNegTest(testPath: String) = testPath.contains("/neg/")
private def isNegTest(testPath: String) =
testPath.contains("/neg/") || testPath.contains("/neg-custom-args/") || testPath.contains("/neg-tailcall/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testPath.startsWith("/neg") ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the full path is given here. Something like ../tests/neg/Foo.scala. I wouldn't bother to do something smarter since this is for the legacy tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.


private def compileArgs(args: Array[String], expectedErrorsPerFile: List[ErrorsInFile])
(implicit defaultOptions: List[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MissingCoreLibTests {

@Test def missingDottyLib: Unit = {
val classPath = mkClassPath(Jars.dottyCompiler :: Jars.dottyInterfaces :: Jars.dottyExtras) // missing Jars.dottyLib
val source = "../tests/neg/nolib/Foo.scala"
val source = "../tests/pos/Foo.scala"
val options = Array("-classpath", classPath, source)
val reporter = Main.process(options)
assertEquals(1, reporter.errorCount)
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/SettingsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SettingsTests {

@Test def jarOutput: Unit = {
val classPath = mkClassPath(Jars.dottyTestDeps)
val source = "../tests/neg/nolib/Foo.scala"
val source = "../tests/pos/Foo.scala"
val out = Paths.get("../out/jaredFoo.jar").normalize
if (Files.exists(out)) Files.delete(out)
val options = Array("-classpath", classPath, "-d", out.toString, source)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import scala.reflect.Selectable.reflectiveSelectable

package p1 {

object test123 {
Expand Down Expand Up @@ -36,20 +38,21 @@ object RClose {
}

package p3 {

object Test {
def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t)
def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t) // error: polymorphic refinement method map without matching type in parent Object is no longer allowed

def main(args: Array[String]): Unit = {
idMap(Some(5))
idMap(Responder.constant(5))
idMap(Some(5)) // error: type mismatch: found Some[Int], required Object{map: [U](f: Any => U): Any}
idMap(Responder.constant(5)) // error: type mismatch: found Responder[Int], required Object{map: [U](f: Any => U): Any}
}
}
}
package p4 {

trait A { self: Any { def p: Any } =>
def f(b: => Unit): Unit = {}
f { p } // error: cannot access member 'p' from structural type
f { p } // OK
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended?

}
}

Expand All @@ -64,7 +67,7 @@ object Test {
package p6 {

class Refinements {
val y: C { val x: T; type T } // was adeprecated warning: illegal forward reference in refinement; now illegal
val y: { val x: T; type T } // error: deprecated warning: illegal forward reference in refinement; now illegal
}

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions tests/neg/nolib/Foo.scala

This file was deleted.

1 change: 1 addition & 0 deletions tests/pos/Foo.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Foo