Skip to content

fix #1274: test for dotty bootstrap based on tasty #1427

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 13, 2016
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
7 changes: 6 additions & 1 deletion src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class PathResolver(implicit ctx: Context) {
case "extdirs" => settings.extdirs.value
case "classpath" | "cp" => settings.classpath.value
case "sourcepath" => settings.sourcepath.value
case "priorityclasspath" => settings.priorityclasspath.value
}

/** Calculated values based on any given command line options, falling back on
Expand All @@ -193,6 +194,7 @@ class PathResolver(implicit ctx: Context) {
def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else ""
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
def priorityClassPath = cmdLineOrElse("prioritypath", "")
/** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as:
* [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect
* [scaladoc] case class ReificationException(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
Expand Down Expand Up @@ -220,7 +222,9 @@ class PathResolver(implicit ctx: Context) {
import context._

// Assemble the elements!
// priority class path takes precedence
def basis = List[Traversable[ClassPath]](
classesInExpandedPath(priorityClassPath), // 0. The priority class path (for testing).
classesInPath(javaBootClassPath), // 1. The Java bootstrap class path.
contentsOfDirsInPath(javaExtDirs), // 2. The Java extension class path.
classesInExpandedPath(javaUserClassPath), // 3. The Java application class path.
Expand All @@ -235,6 +239,7 @@ class PathResolver(implicit ctx: Context) {
override def toString = """
|object Calculated {
| scalaHome = %s
| priorityClassPath = %s
| javaBootClassPath = %s
| javaExtDirs = %s
| javaUserClassPath = %s
Expand All @@ -244,7 +249,7 @@ class PathResolver(implicit ctx: Context) {
| userClassPath = %s
| sourcePath = %s
|}""".trim.stripMargin.format(
scalaHome,
scalaHome, ppcp(priorityClassPath),
ppcp(javaBootClassPath), ppcp(javaExtDirs), ppcp(javaUserClassPath),
useJavaClassPath,
ppcp(scalaBootClassPath), ppcp(scalaExtDirs), ppcp(userClassPath),
Expand Down
7 changes: 4 additions & 3 deletions src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class ScalaSettings extends Settings.SettingGroup {
val javabootclasspath = PathSetting("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath)
val javaextdirs = PathSetting("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs)
val sourcepath = PathSetting("-sourcepath", "Specify location(s) of source files.", "") // Defaults.scalaSourcePath
val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
val priorityclasspath = PathSetting("-priorityclasspath", "class path that takes precedence over all other paths (or testing only)", "")

/** Other settings.
*/
Expand Down Expand Up @@ -46,9 +50,6 @@ class ScalaSettings extends Settings.SettingGroup {
val nobootcp = BooleanSetting("-nobootcp", "Do not use the boot classpath for the scala jars.")
val strict = BooleanSetting("-strict", "Use strict type rules, which means some formerly legal code does not typecheck anymore.")

val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
val nospecialization = BooleanSetting("-no-specialization", "Ignore @specialize annotations.")
val language = MultiStringSetting("-language", "feature", "Enable one or more language features.")
val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax")
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ object Contexts {
def compilationUnit: CompilationUnit = _compilationUnit

/** The current tree */
private[this] var _tree: Tree[_ >: Untyped] = _
private[this] var _tree: Tree[_ >: Untyped]= _
protected def tree_=(tree: Tree[_ >: Untyped]) = _tree = tree
def tree: Tree[_ >: Untyped] = _tree

Expand Down
46 changes: 35 additions & 11 deletions test/dotc/tests.scala
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
package dotc

import test._
import dotty.partest._
import org.junit.Test
import org.junit.experimental.categories._
import org.junit.{Before, Test}

import scala.reflect.io.Directory
import scala.io.Source

// tests that match regex '(pos|dotc|run|java|compileStdLib)\.*' would be executed as benchmarks.
class tests extends CompilerTest {

def isRunByJenkins: Boolean = sys.props.isDefinedAt("dotty.jenkins.build")

val defaultOutputDir = "./out/"

val noCheckOptions = List(
// "-verbose",
// "-Ylog:frontend",
// "-Xprompt",
// "-explaintypes",
// "-Yshow-suppressed-errors",
"-d", defaultOutputDir,
"-pagewidth", "160")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I moved the -d option to noCheckOptions, so that the dotc_core_nocheck test case also generates class files under ./out/, instead of the current directory.


val defaultOutputDir = "./out/"

implicit val defaultOptions = noCheckOptions ++ List(
"-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never",
"-d", defaultOutputDir) ++ {
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
}
implicit val defaultOptions = noCheckOptions ++
List("-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never") ++ {
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
}

val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler")

Expand Down Expand Up @@ -60,6 +59,12 @@ class tests extends CompilerTest {
val dottyReplDir = dotcDir + "repl/"
val typerDir = dotcDir + "typer/"

@Before def cleanup(): Unit = {
// remove class files from stdlib and tests compilation
Directory(defaultOutputDir + "scala").deleteRecursively()
Directory(defaultOutputDir + "java").deleteRecursively()
}

@Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
// This directory doesn't exist anymore
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
Expand Down Expand Up @@ -301,4 +306,23 @@ class tests extends CompilerTest {
@Test def tasty_dotc_util = compileDir(dotcDir, "util", testPickling)
@Test def tasty_tools_io = compileDir(toolsDir, "io", testPickling)
@Test def tasty_tests = compileDir(testsDir, "tasty", testPickling)

@Test def tasty_bootstrap = {
val opt = List("-priorityclasspath", defaultOutputDir, "-Ylog-classpath")
// first compile dotty
compileDir(dottyDir, ".", List("-deep", "-Ycheck-reentrant", "-strict"))(allowDeepSubtypes)

compileDir(dottyDir, "tools", opt)
compileDir(toolsDir, "dotc", opt)
compileDir(dotcDir, "ast", opt)
compileDir(dotcDir, "config", opt)
compileDir(dotcDir, "parsing", opt)
compileDir(dotcDir, "printing", opt)
compileDir(dotcDir, "repl", opt)
compileDir(dotcDir, "reporting", opt)
compileDir(dotcDir, "rewrite", opt)
compileDir(dotcDir, "transform", opt)
compileDir(dotcDir, "typer", opt)
compileDir(dotcDir, "util", opt)
}
}