1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
package dotty
package tools
package dotc
import org.junit.Test
import java.io.{ File => JFile }
class CompilationTests extends ParallelTesting {
import CompilationTests.{ defaultOutputDir, defaultOptions, picklingOptions }
// Positive tests ------------------------------------------------------------
@Test def compilePos =
compileFilesInDir("../tests/pos", defaultOptions).pos
// Negative tests ------------------------------------------------------------
@Test def compileNeg =
compileShallowFilesInDir("../tests/neg", defaultOptions).neg
// Run tests -----------------------------------------------------------------
@Test def runArraycopy =
compileFile("../tests/run/arraycopy.scala", defaultOptions).run
@Test def runAll =
compileFilesInDir("../tests/run", defaultOptions).run
// Pickling Tests ------------------------------------------------------------
@Test def testPickling =
compileFilesInDir("../tests/pickling", picklingOptions).pos
@Test def testPicklingAst =
compileFilesInDir("../compiler/src/dotty/tools/dotc/ast", picklingOptions).pos
@Test def testPicklingInf =
compileFile("../tests/pos/pickleinf.scala", picklingOptions).pos
}
object CompilationTests {
implicit val defaultOutputDir: String = "../out/"
private val noCheckOptions = Array(
"-pagewidth", "80"
)
private val checkOptions = Array(
"-Yno-deep-subtypes",
"-Yno-double-bindings",
"-Yforce-sbt-phases"
)
private val classPath = {
val paths = Jars.dottyTestDeps map { p =>
val file = new JFile(p)
assert(
file.exists,
s"""|File "$p" couldn't be found. Run `packageAll` from build tool before
|testing.
|
|If running without sbt, test paths need to be setup environment variables:
|
| - DOTTY_LIBRARY
| - DOTTY_COMPILER
| - DOTTY_INTERFACES
| - DOTTY_EXTRAS
|
|Where these all contain locations, except extras which is a colon
|separated list of jars.
|
|When compiling with eclipse, you need the sbt-interfaces jar, put
|it in extras."""
)
file.getAbsolutePath
} mkString (":")
Array("-classpath", paths)
}
private val yCheckOptions = Array("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
val defaultOptions = noCheckOptions ++ checkOptions ++ yCheckOptions ++ classPath
val allowDeepSubtypes = defaultOptions diff Array("-Yno-deep-subtypes")
val allowDoubleBindings = defaultOptions diff Array("-Yno-double-bindings")
val picklingOptions = defaultOptions ++ Array(
"-Xprint-types",
"-Ytest-pickler",
"-Ystop-after:pickler",
"-Yprintpos"
)
}
|