Skip to content

Commit dac5b93

Browse files
authored
Merge pull request scala#1427 from dotty-staging/fix-i1274
fix scala#1274: test for dotty bootstrap based on tasty
2 parents a90a784 + 92ebb46 commit dac5b93

File tree

4 files changed

+46
-16
lines changed

4 files changed

+46
-16
lines changed

src/dotty/tools/dotc/config/PathResolver.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class PathResolver(implicit ctx: Context) {
180180
case "extdirs" => settings.extdirs.value
181181
case "classpath" | "cp" => settings.classpath.value
182182
case "sourcepath" => settings.sourcepath.value
183+
case "priorityclasspath" => settings.priorityclasspath.value
183184
}
184185

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

222224
// Assemble the elements!
225+
// priority class path takes precedence
223226
def basis = List[Traversable[ClassPath]](
227+
classesInExpandedPath(priorityClassPath), // 0. The priority class path (for testing).
224228
classesInPath(javaBootClassPath), // 1. The Java bootstrap class path.
225229
contentsOfDirsInPath(javaExtDirs), // 2. The Java extension class path.
226230
classesInExpandedPath(javaUserClassPath), // 3. The Java application class path.
@@ -235,6 +239,7 @@ class PathResolver(implicit ctx: Context) {
235239
override def toString = """
236240
|object Calculated {
237241
| scalaHome = %s
242+
| priorityClassPath = %s
238243
| javaBootClassPath = %s
239244
| javaExtDirs = %s
240245
| javaUserClassPath = %s
@@ -244,7 +249,7 @@ class PathResolver(implicit ctx: Context) {
244249
| userClassPath = %s
245250
| sourcePath = %s
246251
|}""".trim.stripMargin.format(
247-
scalaHome,
252+
scalaHome, ppcp(priorityClassPath),
248253
ppcp(javaBootClassPath), ppcp(javaExtDirs), ppcp(javaUserClassPath),
249254
useJavaClassPath,
250255
ppcp(scalaBootClassPath), ppcp(scalaExtDirs), ppcp(userClassPath),

src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class ScalaSettings extends Settings.SettingGroup {
1515
val javabootclasspath = PathSetting("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath)
1616
val javaextdirs = PathSetting("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs)
1717
val sourcepath = PathSetting("-sourcepath", "Specify location(s) of source files.", "") // Defaults.scalaSourcePath
18+
val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
19+
val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
20+
val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
21+
val priorityclasspath = PathSetting("-priorityclasspath", "class path that takes precedence over all other paths (or testing only)", "")
1822

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

49-
val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
50-
val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
51-
val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
5253
val nospecialization = BooleanSetting("-no-specialization", "Ignore @specialize annotations.")
5354
val language = MultiStringSetting("-language", "feature", "Enable one or more language features.")
5455
val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax")

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object Contexts {
132132
def compilationUnit: CompilationUnit = _compilationUnit
133133

134134
/** The current tree */
135-
private[this] var _tree: Tree[_ >: Untyped] = _
135+
private[this] var _tree: Tree[_ >: Untyped]= _
136136
protected def tree_=(tree: Tree[_ >: Untyped]) = _tree = tree
137137
def tree: Tree[_ >: Untyped] = _tree
138138

test/dotc/tests.scala

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
package dotc
22

33
import test._
4-
import dotty.partest._
5-
import org.junit.Test
6-
import org.junit.experimental.categories._
4+
import org.junit.{Before, Test}
75

6+
import scala.reflect.io.Directory
87
import scala.io.Source
98

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

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

14+
val defaultOutputDir = "./out/"
15+
1516
val noCheckOptions = List(
1617
// "-verbose",
1718
// "-Ylog:frontend",
1819
// "-Xprompt",
1920
// "-explaintypes",
2021
// "-Yshow-suppressed-errors",
22+
"-d", defaultOutputDir,
2123
"-pagewidth", "160")
2224

23-
val defaultOutputDir = "./out/"
24-
25-
implicit val defaultOptions = noCheckOptions ++ List(
26-
"-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never",
27-
"-d", defaultOutputDir) ++ {
28-
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
29-
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
30-
}
25+
implicit val defaultOptions = noCheckOptions ++
26+
List("-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never") ++ {
27+
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
28+
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
29+
}
3130

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

@@ -60,6 +59,12 @@ class tests extends CompilerTest {
6059
val dottyReplDir = dotcDir + "repl/"
6160
val typerDir = dotcDir + "typer/"
6261

62+
@Before def cleanup(): Unit = {
63+
// remove class files from stdlib and tests compilation
64+
Directory(defaultOutputDir + "scala").deleteRecursively()
65+
Directory(defaultOutputDir + "java").deleteRecursively()
66+
}
67+
6368
@Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
6469
// This directory doesn't exist anymore
6570
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
@@ -301,4 +306,23 @@ class tests extends CompilerTest {
301306
@Test def tasty_dotc_util = compileDir(dotcDir, "util", testPickling)
302307
@Test def tasty_tools_io = compileDir(toolsDir, "io", testPickling)
303308
@Test def tasty_tests = compileDir(testsDir, "tasty", testPickling)
309+
310+
@Test def tasty_bootstrap = {
311+
val opt = List("-priorityclasspath", defaultOutputDir, "-Ylog-classpath")
312+
// first compile dotty
313+
compileDir(dottyDir, ".", List("-deep", "-Ycheck-reentrant", "-strict"))(allowDeepSubtypes)
314+
315+
compileDir(dottyDir, "tools", opt)
316+
compileDir(toolsDir, "dotc", opt)
317+
compileDir(dotcDir, "ast", opt)
318+
compileDir(dotcDir, "config", opt)
319+
compileDir(dotcDir, "parsing", opt)
320+
compileDir(dotcDir, "printing", opt)
321+
compileDir(dotcDir, "repl", opt)
322+
compileDir(dotcDir, "reporting", opt)
323+
compileDir(dotcDir, "rewrite", opt)
324+
compileDir(dotcDir, "transform", opt)
325+
compileDir(dotcDir, "typer", opt)
326+
compileDir(dotcDir, "util", opt)
327+
}
304328
}

0 commit comments

Comments
 (0)