Skip to content

Make MissingCoreLibTests a simple unit test #3356

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
Oct 20, 2017
Merged
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
31 changes: 10 additions & 21 deletions compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,21 @@ package dotty
package tools
package dotc

import org.junit.{AfterClass, Test}
import vulpix._
import org.junit.Test
import org.junit.Assert._

import scala.concurrent.duration._
import vulpix.TestConfiguration.mkClassPath

class MissingCoreLibTests extends ParallelTesting {
import MissingCoreLibTests._
import TestConfiguration._

// Test suite configuration --------------------------------------------------

def maxDuration = 30.seconds
def numberOfSlaves = 5
def safeMode = Properties.testsSafeMode
def isInteractive = SummaryReport.isInteractive
def testFilter = Properties.testsFilter
class MissingCoreLibTests {

@Test def missingDottyLib: Unit = {
val classPath = mkClassPath(Jars.dottyCompiler :: Jars.dottyInterfaces :: Jars.dottyExtras) // missing Jars.dottyLib
val options = noCheckOptions ++ checkOptions ++ yCheckOptions
compileFile("../tests/neg/nolib/Foo.scala", TestFlags(classPath, options)).checkExpectedErrors()
val source = "../tests/neg/nolib/Foo.scala"
val options = Array("-classpath", classPath, source)
val reporter = Main.process(options)
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not handling the case where the compiler crashes, vulpix did that. A try/catch and assertTrue(false, ex.stackTrace) a good enough replacement.

Copy link
Contributor Author

@allanrenucci allanrenucci Oct 20, 2017

Choose a reason for hiding this comment

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

My understanding is that if something in the test crashes, the test fails

Copy link
Contributor

Choose a reason for hiding this comment

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

Right

assertEquals(1, reporter.errorCount)
val errorMessage = reporter.allErrors.head.message
assertTrue(errorMessage.contains("Make sure the compiler core libraries are on the classpath"))
}

}

object MissingCoreLibTests {
implicit val summaryReport: SummaryReporting = new SummaryReport
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
}