Skip to content

Commit 6351c6c

Browse files
felixmuldersmarter
authored andcommitted
Create dotty-lib.jar for run tests
1 parent 805884c commit 6351c6c

17 files changed

+268
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ classes/
3131

3232
# Partest
3333
dotty.jar
34+
dotty-lib.jar
3435
tests/partest-generated/
3536
tests/locks/
3637
/test-classes/

bin/common

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function build_all {
8686
printf "done\n"
8787

8888
printf "Building dotty-compiler..."
89-
MAIN_JAR=$(build_jar package "target/scala-$SCALA_BINARY_VERSION")
89+
MAIN_JAR=$(build_jar dotty-compiler/package "target/scala-$SCALA_BINARY_VERSION")
9090
printf "done\n"
9191

9292
printf "Building dotty library..."
@@ -131,7 +131,7 @@ function check_jar {
131131
}
132132

133133
check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
134-
check_jar "dotty" $MAIN_JAR "src" 'MAIN_JAR=$(build_jar package target/scala-$SCALA_BINARY_VERSION)'
134+
check_jar "dotty" $MAIN_JAR "src" 'MAIN_JAR=$(build_jar dotty-compiler/package target/scala-$SCALA_BINARY_VERSION)'
135135
check_jar "dotty-library" $DOTTY_LIB_JAR "library" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
136136
check_jar "dotty-tests" $TEST_JAR "test" 'TEST_JAR=$(build_jar test:package target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'
137137

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package dotty.runtime
22

3-
4-
/**
5-
* replaces the `scala.App` class which relies on `DelayedInit` functionality, not supported by Dotty.
6-
*/
3+
/** Replaces the `scala.App` class which relies on `DelayedInit` functionality,
4+
* not supported by Dotty.
5+
*/
76
class LegacyApp {
87
def main(args: Array[String]): Unit = ()
98
}

project/Build.scala

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ object DottyBuild extends Build {
137137
val args = Def.spaceDelimited("<arg>").parsed
138138
val jars = Seq((packageBin in Compile).value.getAbsolutePath) ++
139139
getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
140-
val dottyJars = "-dottyJars " + (jars.length + 2) + " dotty.jar dotty-lib.jar" + " " + jars.mkString(" ")
140+
val dottyJars = "-dottyJars " + (jars.length + 1) + " dotty-lib.jar" + " " + jars.mkString(" ")
141141
// Provide the jars required on the classpath of run tests
142142
runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" "))
143143
},
@@ -191,7 +191,7 @@ object DottyBuild extends Build {
191191
path = file.getAbsolutePath
192192
} yield "-Xbootclasspath/p:" + path
193193
// dotty itself needs to be in the bootclasspath
194-
val fullpath = ("-Xbootclasspath/p:" + "dotty.jar") :: ("-Xbootclasspath/a:" + bin) :: path.toList
194+
val fullpath = /*("-Xbootclasspath/p:" + "dotty.jar") ::*/ ("-Xbootclasspath/a:" + bin) :: path.toList
195195
// System.err.println("BOOTPATH: " + fullpath)
196196

197197
val travis_build = // propagate if this is a travis build
@@ -211,10 +211,33 @@ object DottyBuild extends Build {
211211
}
212212
).
213213
settings(
214-
addCommandAlias("partest", ";test:package;package;test:runMain dotc.build;lockPartestFile;test:test;runPartestRunner") ++
215-
addCommandAlias("partest-only", ";test:package;package;test:runMain dotc.build;lockPartestFile;test:test-only dotc.tests;runPartestRunner") ++
216-
addCommandAlias("partest-only-no-bootstrap", ";test:package;package; lockPartestFile;test:test-only dotc.tests;runPartestRunner") ++
217-
addCommandAlias("dottydoc", ";dottydoc/run")
214+
addCommandAlias(
215+
"partest",
216+
";test:package" +
217+
";dotty-compiler/package" +
218+
";dotty-library/package" +
219+
";test:runMain dotc.build" +
220+
";lockPartestFile" +
221+
";test:test" +
222+
";runPartestRunner"
223+
) ++
224+
addCommandAlias("partest-only",
225+
";test:package" +
226+
";dotty-compiler/package" +
227+
";dotty-library/package" +
228+
";test:runMain dotc.build" +
229+
";lockPartestFile" +
230+
";test:test-only dotc.tests" +
231+
";runPartestRunner"
232+
) ++
233+
addCommandAlias(
234+
"partest-only-no-bootstrap",
235+
";test:package" +
236+
";package" +
237+
";lockPartestFile" +
238+
";test:test-only dotc.tests" +
239+
";runPartestRunner"
240+
)
218241
).
219242
settings(publishing)
220243

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class JavaPlatform extends Platform {
1616
def classPath(implicit ctx: Context): ClassPath = {
1717
if (currentClassPath.isEmpty)
1818
currentClassPath = Some(new PathResolver().result)
19-
currentClassPath.get
19+
val cp = currentClassPath.get
20+
println(cp)
21+
cp
2022
}
2123

2224
// The given symbol is a method with the right name and signature to be a runnable java program.

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,23 @@ object PathResolver {
4646
def classPathEnv = envOrElse("CLASSPATH", "")
4747
def sourcePathEnv = envOrElse("SOURCEPATH", "")
4848

49-
def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath)
49+
def javaBootClassPath =
50+
propOrElse("sun.boot.class.path", searchForBootClasspath)
51+
.split(":")
52+
.filterNot { jar =>
53+
// This classpath gets propagated to the compiled resources and as
54+
// such needs to be purged of things that should not be on the
55+
// compiled programs' classpath:
56+
jar.contains("dotty-compiler") ||
57+
jar.contains("dotty-library") ||
58+
jar.contains("dotty-interfaces") ||
59+
// let's blacklist locally compiled classes:
60+
jar.contains("dotty/library/target") ||
61+
jar.contains("dotty/interfaces/target") ||
62+
jar.contains("dotty/target/scala-2.11")
63+
}
64+
.mkString(":")
65+
5066
def javaExtDirs = propOrEmpty("java.ext.dirs")
5167
def scalaHome = propOrEmpty("scala.home")
5268
def scalaExtDirs = propOrEmpty("scala.ext.dirs")
@@ -213,11 +229,11 @@ class PathResolver(implicit ctx: Context) {
213229
* - Otherwise, if CLASSPATH is set, it is that
214230
* - If neither of those, then "." is used.
215231
*/
216-
def userClassPath = (
232+
def userClassPath = {
217233
if (!settings.classpath.isDefault)
218234
settings.classpath.value
219235
else sys.env.getOrElse("CLASSPATH", ".")
220-
)
236+
}
221237

222238
import context._
223239

test/dotc/build.scala

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,25 @@ object build extends tests {
1616
}
1717
}
1818
if(deleteFolder) folder.delete()
19-
}
19+
}
2020

21-
def main(args: Array[String]): Unit = {
22-
println("------------ Building dotty ------------")
21+
def clearOutput() = {
2322
deleteFilesInFolder(new File(defaultOutputDir)) // clear previous output
2423
val keepFile = new File(defaultOutputDir + ".keep")
2524
keepFile.createNewFile()
26-
dotty // build output dir
27-
val p = Runtime.getRuntime.exec(Array("jar", "cf", "dotty.jar", "-C", "out", "."))
28-
p.waitFor()
25+
}
26+
27+
def main(args: Array[String]): Unit = {
28+
println("---------- Building bootstrapped dotty-lib ----------------------------------------------")
29+
clearOutput()
30+
dottyBootedLib
31+
val p1 = Runtime.getRuntime.exec(Array("jar", "cf", "dotty-lib.jar", "-C", "out", "."))
32+
p1.waitFor()
33+
34+
println("---------- Building bootstrapped dotty depending on dotty-lib compiled by dotty ----------")
35+
clearOutput()
36+
dottyDependsOnBootedLib
37+
val p2 = Runtime.getRuntime.exec(Array("jar", "cf", "dotty.jar", "-C", "out", "."))
38+
p2.waitFor()
2939
}
3040
}

test/dotc/tests.scala

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,26 @@ class tests extends CompilerTest {
1414
val defaultOutputDir = "./out/"
1515

1616
val noCheckOptions = List(
17-
// "-verbose",
18-
// "-Ylog:frontend",
19-
// "-Xprompt",
20-
// "-explaintypes",
21-
// "-Yshow-suppressed-errors",
22-
"-d", defaultOutputDir,
23-
"-pagewidth", "160")
24-
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-
}
17+
// "-verbose",
18+
// "-Ylog:frontend",
19+
// "-Xprompt",
20+
// "-explaintypes",
21+
// "-Yshow-suppressed-errors",
22+
"-d", defaultOutputDir,
23+
"-pagewidth", "80"
24+
)
25+
26+
implicit val defaultOptions = noCheckOptions ++ {
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+
} ++ List(
30+
"-Yno-deep-subtypes",
31+
"-Yno-double-bindings",
32+
"-Yforce-sbt-phases",
33+
"-color:never",
34+
"-classpath",
35+
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
36+
)
3037

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

@@ -58,6 +65,7 @@ class tests extends CompilerTest {
5865
val parsingDir = dotcDir + "parsing/"
5966
val dottyReplDir = dotcDir + "repl/"
6067
val typerDir = dotcDir + "typer/"
68+
val libDir = "./library/src/"
6169

6270
@Before def cleanup(): Unit = {
6371
// remove class files from stdlib and tests compilation
@@ -177,7 +185,31 @@ class tests extends CompilerTest {
177185
|./scala-scala/src/library/scala/collection/generic/GenSeqFactory.scala""".stripMargin)
178186
@Test def compileIndexedSeq = compileLine("./scala-scala/src/library/scala/collection/immutable/IndexedSeq.scala")
179187

180-
@Test def dotty = compileDir(dottyDir, ".", List("-deep", "-Ycheck-reentrant", "-strict"))(allowDeepSubtypes) // note the -deep argument
188+
// Not a junit test anymore since it is order dependent
189+
def dottyBootedLib = compileDir(
190+
libDir,
191+
".",
192+
List(
193+
"-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir +
194+
":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" //WAT???
195+
)
196+
)(allowDeepSubtypes) // note the -deep argument
197+
198+
// Not a junit test anymore since it is order dependent
199+
def dottyDependsOnBootedLib = compileDir(
200+
dottyDir,
201+
".",
202+
List(
203+
"-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir +
204+
":./dotty-lib.jar" +
205+
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" +
206+
// this needs to get compiled together with the compiler:
207+
//":./target/scala-2.11/src_managed/main/scalajs-ir-src/"
208+
// but falling back to:
209+
":/home/fixel/.ivy2/cache/org.scala-js/scalajs-ir_2.11/jars/scalajs-ir_2.11-0.6.8.jar"
210+
// for the time being.
211+
)
212+
)(allowDeepSubtypes) // note the -deep argument
181213

182214
@Test def dotc_ast = compileDir(dotcDir, "ast")
183215
@Test def dotc_config = compileDir(dotcDir, "config")
@@ -231,8 +263,8 @@ class tests extends CompilerTest {
231263
// Disabled because we get stale symbol errors on the SourceFile annotation, which is normal.
232264
// @Test def tasty_annotation_internal = compileDir(s"${dottyDir}annotation/", "internal", testPickling)
233265

234-
@Test def tasty_runtime = compileDir(s"$dottyDir", "runtime", testPickling)
235-
@Test def tasty_runtime_vc = compileDir(s"${dottyDir}runtime/", "vc", testPickling)
266+
@Test def tasty_runtime = compileDir(s"${libDir}dotty/", "runtime", testPickling)
267+
@Test def tasty_runtime_vc = compileDir(s"${libDir}dotty/runtime/", "vc", testPickling)
236268

237269
@Test def tasty_tools = compileDir(dottyDir, "tools", testPickling)
238270

0 commit comments

Comments
 (0)