Skip to content

Commit bbc46b4

Browse files
felixmuldersmarter
authored andcommitted
Add dotty-library to classpath in dottydoc tests
1 parent 6351c6c commit bbc46b4

12 files changed

+111
-80
lines changed

dottydoc/test/BaseTest.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ trait DottyTest {
2121
ctx.setSetting(ctx.settings.YkeepComments, true)
2222
ctx.setSetting(ctx.settings.YnoInline, true)
2323
ctx.setProperty(ContextDoc, new ContextDottydoc)
24+
ctx.setSetting(
25+
ctx.settings.classpath,
26+
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
27+
)
2428
base.initialize()(ctx)
2529
ctx
2630
}

project/Build.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,28 +212,30 @@ object DottyBuild extends Build {
212212
).
213213
settings(
214214
addCommandAlias(
215-
"partest",
216-
";test:package" +
215+
"packageAll",
216+
";dotty-interfaces/package" +
217217
";dotty-compiler/package" +
218218
";dotty-library/package" +
219+
";test:package"
220+
) ++
221+
addCommandAlias(
222+
"partest",
223+
";packageAll" +
219224
";test:runMain dotc.build" +
220225
";lockPartestFile" +
221226
";test:test" +
222227
";runPartestRunner"
223228
) ++
224229
addCommandAlias("partest-only",
225-
";test:package" +
226-
";dotty-compiler/package" +
227-
";dotty-library/package" +
230+
";packageAll" +
228231
";test:runMain dotc.build" +
229232
";lockPartestFile" +
230233
";test:test-only dotc.tests" +
231234
";runPartestRunner"
232235
) ++
233236
addCommandAlias(
234237
"partest-only-no-bootstrap",
235-
";test:package" +
236-
";package" +
238+
";packageAll" +
237239
";lockPartestFile" +
238240
";test:test-only dotc.tests" +
239241
";runPartestRunner"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class JavaPlatform extends Platform {
1717
if (currentClassPath.isEmpty)
1818
currentClassPath = Some(new PathResolver().result)
1919
val cp = currentClassPath.get
20-
println(cp)
20+
//println(cp)
2121
cp
2222
}
2323

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

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object PathResolver {
2020
// security exceptions.
2121
import AccessControl._
2222

23-
def firstNonEmpty(xs: String*) = xs find (_ != "") getOrElse ""
23+
def firstNonEmpty(xs: String*) = xs find (_ != "") getOrElse ""
2424

2525
/** Map all classpath elements to absolute paths and reconstruct the classpath.
2626
*/
@@ -50,16 +50,12 @@ object PathResolver {
5050
propOrElse("sun.boot.class.path", searchForBootClasspath)
5151
.split(":")
5252
.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") ||
5953
// 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")
54+
jar.contains("/dotty/library/target/classes") ||
55+
jar.contains("/dotty/library/target/scala-2.11/classes") ||
56+
jar.contains("/dotty/interfaces/target/classes") ||
57+
jar.contains("/dotty/target/scala-2.11/classes") ||
58+
jar.contains("/dotty/target/classes")
6359
}
6460
.mkString(":")
6561

@@ -71,20 +67,14 @@ object PathResolver {
7167
def javaUserClassPath = propOrElse("java.class.path", "")
7268
def useJavaClassPath = propOrFalse("scala.usejavacp")
7369

74-
override def toString = """
70+
override def toString = s"""
7571
|object Environment {
76-
| scalaHome = %s (useJavaClassPath = %s)
77-
| javaBootClassPath = <%d chars>
78-
| javaExtDirs = %s
79-
| javaUserClassPath = %s
80-
| scalaExtDirs = %s
81-
|}""".trim.stripMargin.format(
82-
scalaHome, useJavaClassPath,
83-
javaBootClassPath.length,
84-
ppcp(javaExtDirs),
85-
ppcp(javaUserClassPath),
86-
ppcp(scalaExtDirs)
87-
)
72+
| scalaHome = $scalaHome (useJavaClassPath = $useJavaClassPath)
73+
| javaBootClassPath = <${javaBootClassPath.length} chars>
74+
| javaExtDirs = ${ppcp(javaExtDirs)}
75+
| javaUserClassPath = ${ppcp(javaUserClassPath)}
76+
| scalaExtDirs = ${ppcp(scalaExtDirs)}
77+
|}""".trim.stripMargin
8878
}
8979

9080
/** Default values based on those in Environment as interpreted according
@@ -259,7 +249,7 @@ class PathResolver(implicit ctx: Context) {
259249
| javaBootClassPath = %s
260250
| javaExtDirs = %s
261251
| javaUserClassPath = %s
262-
| useJavaClassPath = %s
252+
| useJavaClassPath = %s
263253
| scalaBootClassPath = %s
264254
| scalaExtDirs = %s
265255
| userClassPath = %s
@@ -276,7 +266,8 @@ class PathResolver(implicit ctx: Context) {
276266
def containers = Calculated.containers
277267

278268
lazy val result: JavaClassPath = {
279-
val cp = new JavaClassPath(containers.toIndexedSeq, context)
269+
val (dottyJars, others) = containers.partition(_.name.contains("dotty"))
270+
val cp = new JavaClassPath((dottyJars ++ others).toIndexedSeq, context)
280271
if (settings.Ylogcp.value) {
281272
Console.println("Classpath built from " + settings.toConciseString(ctx.sstate))
282273
Console.println("Defaults: " + PathResolver.Defaults)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ScalaSettings extends Settings.SettingGroup {
4242
val usejavacp = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.")
4343
val verbose = BooleanSetting("-verbose", "Output messages about what the compiler is doing.")
4444
val version = BooleanSetting("-version", "Print product version and exit.")
45-
val pageWidth = IntSetting("-pagewidth", "Set page width", 120)
45+
val pageWidth = IntSetting("-pagewidth", "Set page width", 80)
4646

4747
val jvmargs = PrefixSetting("-J<flag>", "-J", "Pass <flag> directly to the runtime system.")
4848
val defines = PrefixSetting("-Dproperty=value", "-D", "Pass -Dproperty=value directly to the runtime system.")

test/dotc/tests.scala

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,25 @@ class tests extends CompilerTest {
1919
// "-Xprompt",
2020
// "-explaintypes",
2121
// "-Yshow-suppressed-errors",
22-
"-d", defaultOutputDir,
23-
"-pagewidth", "80"
22+
"-pagewidth", "120",
23+
"-d", defaultOutputDir
2424
)
2525

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(
26+
val classPath = List(
3027
"-Yno-deep-subtypes",
3128
"-Yno-double-bindings",
3229
"-Yforce-sbt-phases",
3330
"-color:never",
3431
"-classpath",
35-
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
32+
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" +
33+
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
3634
)
3735

36+
implicit val defaultOptions = noCheckOptions ++ {
37+
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
38+
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
39+
} ++ classPath
40+
3841
val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler", "-Yprintpos")
3942

4043
val twice = List("#runs", "2")
@@ -191,7 +194,9 @@ class tests extends CompilerTest {
191194
".",
192195
List(
193196
"-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir +
194-
":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" //WAT???
197+
":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" +
198+
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" +
199+
":./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
195200
)
196201
)(allowDeepSubtypes) // note the -deep argument
197202

@@ -214,7 +219,7 @@ class tests extends CompilerTest {
214219
@Test def dotc_ast = compileDir(dotcDir, "ast")
215220
@Test def dotc_config = compileDir(dotcDir, "config")
216221
@Test def dotc_core = compileDir(dotcDir, "core")(allowDeepSubtypes)// twice omitted to make tests run faster
217-
@Test def dotc_core_nocheck = compileDir(dotcDir, "core")(noCheckOptions)
222+
@Test def dotc_core_nocheck = compileDir(dotcDir, "core")(noCheckOptions ++ classPath)
218223

219224
// This directory doesn't exist anymore
220225
// @Test def dotc_core_pickling = compileDir(coreDir, "pickling")(allowDeepSubtypes)// twice omitted to make tests run faster

test/test/CompilerTest.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ abstract class CompilerTest {
133133
}
134134
}
135135

136-
private def compileWithJavac(fs: Array[String], args: Array[String]): Unit = {
136+
private def compileWithJavac(
137+
fs: Array[String],
138+
args: Array[String]
139+
)(implicit defaultOptions: List[String]): Boolean = {
137140
val scalaLib = findJarFromRuntime("scala-library")
138141
val fullArgs = Array(
139142
"javac",
140143
"-classpath",
141144
s".:$scalaLib"
142-
) ++ args ++ fs ++ Array("-d", defaultOutputDir)
145+
) ++ args ++ defaultOptions.dropWhile("-d" != _).take(2) ++ fs
143146

144-
Runtime.getRuntime.exec(fullArgs).waitFor()
147+
Runtime.getRuntime.exec(fullArgs).waitFor() == 0
145148
}
146149

147150
/** Compiles the code files in the given directory together. If args starts
@@ -169,7 +172,7 @@ abstract class CompilerTest {
169172
log(s"WARNING: run tests can only be run by partest, JUnit just verifies compilation: $prefix$dirName")
170173
val (filePaths, javaFilePaths, normArgs, expErrors) = computeFilePathsAndExpErrors
171174
compileWithJavac(javaFilePaths, Array.empty) // javac needs to run first on dotty-library
172-
compileArgs(filePaths ++ normArgs, expErrors)
175+
compileArgs(javaFilePaths ++ filePaths ++ normArgs, expErrors)
173176
} else {
174177
val (sourceDir, flags, deep) = args match {
175178
case "-deep" :: args1 => (flattenDir(prefix, dirName), args1 ++ defaultOptions, "deep")

test/test/OtherEntryPointsTest.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@ import scala.collection.mutable.ListBuffer
1717
* @see [[InterfaceEntryPointTest]]
1818
*/
1919
class OtherEntryPointsTest {
20-
@Test def runCompiler = {
21-
val sources = List("./tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath())
22-
val args = sources ++ List("-d", "./out/")
20+
private val sources =
21+
List("./tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath())
22+
private val dottyInterfaces =
23+
new java.io.File("./interfaces/dotty-interfaces-0.1-SNAPSHOT.jar").getPath
24+
private val dottyLibrary =
25+
new java.io.File("./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar").getPath
26+
private val args =
27+
sources ++
28+
List("-d", "./out/") ++
29+
List("-classpath", dottyInterfaces + ":" + dottyLibrary)
2330

31+
@Test def runCompiler = {
2432
val reporter = new CustomReporter
2533
val callback = new CustomCompilerCallback
2634

@@ -32,9 +40,6 @@ class OtherEntryPointsTest {
3240
}
3341

3442
@Test def runCompilerWithContext = {
35-
val sources = List("./tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath())
36-
val args = sources ++ List("-d", "./out/")
37-
3843
val reporter = new CustomReporter
3944
val callback = new CustomCompilerCallback
4045
val context = (new ContextBase).initialCtx.fresh

test/test/ShowClassTests.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ import dotty.tools.dotc.core.Decorators._
1111
import org.junit.Test
1212

1313
class ShowClassTests extends DottyTest {
14+
ctx = {
15+
val base = new ContextBase
16+
import base.settings._
17+
val ctx = base.initialCtx.fresh
18+
ctx.setSetting(ctx.settings.encoding, "UTF8")
19+
ctx.setSetting(
20+
ctx.settings.classpath,
21+
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" +
22+
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
23+
)
24+
base.initialize()(ctx)
25+
ctx
26+
}
1427

1528
def debug_println(msg: => Any) = {
1629
if (sys.props.isDefinedAt("test.ShowClassTests.verbose"))

test/test/TestREPL.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ class TestREPL(script: String) extends REPL {
2020
override lazy val config = new REPL.Config {
2121
override val output = new NewLinePrintWriter(out)
2222

23-
override def context(ctx: Context) =
24-
ctx.fresh.setSetting(ctx.settings.color, "never")
23+
override def context(ctx: Context) = {
24+
val fresh = ctx.fresh
25+
fresh.setSetting(ctx.settings.color, "never")
26+
fresh.setSetting(
27+
ctx.settings.classpath,
28+
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
29+
)
30+
fresh.initialize()(fresh)
31+
fresh
32+
}
2533

2634
override def input(in: Interpreter)(implicit ctx: Context) = new InteractiveReader {
2735
val lines = script.lines.buffered

tests/repl/errmsgs.check

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
scala> class Inv[T](x: T)
22
defined class Inv
33
scala> val x: List[String] = List(1)
4-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
4+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
55
4 |val x: List[String] = List(1)
66
| ^
77
| found: Int(1)
88
| required: String
99
|
1010
scala> val y: List[List[String]] = List(List(1))
11-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
11+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
1212
4 |val y: List[List[String]] = List(List(1))
1313
| ^
1414
| found: Int(1)
1515
| required: String
1616
|
1717
scala> val z: (List[String], List[Int]) = (List(1), List("a"))
18-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
18+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
1919
4 |val z: (List[String], List[Int]) = (List(1), List("a"))
2020
| ^
2121
| found: Int(1)
2222
| required: String
2323
|
24-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
24+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
2525
4 |val z: (List[String], List[Int]) = (List(1), List("a"))
2626
| ^^^
2727
| found: String("a")
2828
| required: Int
2929
|
3030
scala> val a: Inv[String] = new Inv(new Inv(1))
31-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
31+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
3232
5 |val a: Inv[String] = new Inv(new Inv(1))
3333
| ^^^^^
34-
| found: Inv[T]
35-
| required: String
36-
|
37-
| where: T is a type variable with constraint >: Int(1)
34+
| found: Inv[T]
35+
| required: String
36+
|
37+
| where: T is a type variable with constraint >: Int(1)
3838
scala> val b: Inv[String] = new Inv(1)
39-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
39+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
4040
5 |val b: Inv[String] = new Inv(1)
4141
| ^
4242
| found: Int(1)
@@ -57,25 +57,25 @@ scala> abstract class C {
5757
}
5858
}
5959
}
60-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
60+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
6161
9 | var y: T = x
6262
| ^
63-
| found: C.this.T(C.this.x)
64-
| required: T'
65-
|
66-
| where: T is a type in class C
67-
| T' is a type in the initalizer of value s which is an alias of String
68-
-- [E007] Type Mismatch Error: <console> -------------------------------------------------------------------------------
63+
|found: C.this.T(C.this.x)
64+
|required: T'
65+
|
66+
|where: T is a type in class C
67+
| T' is a type in the initalizer of value s which is an alias of String
68+
-- [E007] Type Mismatch Error: <console> ---------------------------------------
6969
13 | val z: T = y
7070
| ^
71-
| found: T(y)
72-
| required: T'
73-
|
74-
| where: T is a type in the initalizer of value s which is an alias of String
75-
| T' is a type in method f which is an alias of Int
71+
|found: T(y)
72+
|required: T'
73+
|
74+
|where: T is a type in the initalizer of value s which is an alias of String
75+
| T' is a type in method f which is an alias of Int
7676
scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
77-
-- [E008] Member Not Found Error: <console> ----------------------------------------------------------------------------
77+
-- [E008] Member Not Found Error: <console> ------------------------------------
7878
4 |class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
7979
| ^^^^^^^^
80-
| value `barr` is not a member of Foo(foo) - did you mean `foo.bar`?
80+
| value `barr` is not a member of Foo(foo) - did you mean `foo.bar`?
8181
scala> :quit

0 commit comments

Comments
 (0)