Skip to content

Commit 49e537e

Browse files
committed
Merge pull request #558 from dotty-staging/run-tests
Add run tests to pending.
2 parents 595f245 + f904062 commit 49e537e

File tree

3,387 files changed

+93299
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,387 files changed

+93299
-27
lines changed

project/Build.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ object DottyBuild extends Build {
7474
partestLockFile.createNewFile
7575
partestLockFile.deleteOnExit
7676
},
77-
runPartestRunner <<= Def.taskDyn {
77+
runPartestRunner <<= Def.inputTaskDyn {
78+
// Magic! This is both an input task and a dynamic task. Apparently
79+
// command line arguments get passed to the last task in an aliased
80+
// sequence (see partest alias below), so this works.
81+
val args = Def.spaceDelimited("<arg>").parsed
7882
val jars = Seq((packageBin in Compile).value.getAbsolutePath) ++
7983
getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
8084
val dottyJars = "-dottyJars " + jars.length + " " + jars.mkString(" ")
8185
// Provide the jars required on the classpath of run tests
82-
runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars)
86+
runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" "))
8387
},
8488

8589
// Adjust classpath for running dotty
@@ -170,7 +174,7 @@ object DottyBuild extends Build {
170174
lazy val partestLockFile = new File("." + File.separator + "tests" + File.separator + "locks" + File.separator + s"partest-$pid.lock")
171175
def pid = java.lang.Long.parseLong(java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@")(0))
172176

173-
lazy val runPartestRunner = TaskKey[Unit]("runPartestRunner", "Runs partest")
177+
lazy val runPartestRunner = InputKey[Unit]("runPartestRunner", "Runs partest")
174178

175179
lazy val partestDeps = SettingKey[Seq[ModuleID]]("partestDeps", "Finds jars for partest dependencies")
176180
def getJarPaths(modules: Seq[ModuleID], ivyHome: Option[File]): Seq[String] = ivyHome match {

src/dotty/runtime/LegacyApp.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dotty.runtime
2+
3+
4+
/**
5+
* replaces the `scala.App` class which relies on `DelayedInit` functionality, not supported by Dotty.
6+
*/
7+
class LegacyApp {
8+
def main(args: Array[String]): Unit = ()
9+
}

test/dotc/tests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ class tests extends CompilerTest {
137137
@Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2)
138138
@Test def neg_instantiateAbstract = compileFile(negDir, "instantiateAbstract", xerrors = 8)
139139
@Test def neg_selfInheritance = compileFile(negDir, "selfInheritance", xerrors = 5)
140+
140141

141-
@Test def run_hello = runFile(runDir, "hello")
142-
@Test def run_lazyVals = runFile(runDir, "lazyVals")
142+
@Test def run_all = runFiles(runDir)
143143

144144

145145
@Test def dotty = compileDir(dottyDir, "tools", "-deep" :: allowDeepSubtypes ++ twice) // note the -deep argument

test/dotty/partest/DPConsoleRunner.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ object DPConsoleRunner {
2323
// extra jars for run tests are passed with -dottyJars <count> <jar1> <jar2> ...
2424
val jarFinder = """-dottyJars (\d*) (.*)""".r
2525
val (jarList, otherArgs) = args.toList.partition(jarFinder.findFirstIn(_).isDefined)
26-
val extraJars = jarList match {
26+
val (extraJars, moreArgs) = jarList match {
2727
case Nil => sys.error("Error: DPConsoleRunner needs \"-dottyJars <jarCount> <jars>*\".")
2828
case jarFinder(nr, jarString) :: Nil =>
2929
val jars = jarString.split(" ").toList
30-
if (jars.length.toString != nr)
31-
sys.error("Error: DPConsoleRunner found wrong number of dottyJars: " + jars + ", expected: " + nr + ". Make sure the path doesn't contain any spaces.")
32-
else jars
30+
val count = nr.toInt
31+
if (jars.length < count)
32+
sys.error("Error: DPConsoleRunner found wrong number of dottyJars: " + jars + ", expected: " + nr)
33+
else (jars.take(count), jars.drop(count))
3334
case list => sys.error("Error: DPConsoleRunner found several -dottyJars options: " + list)
3435
}
35-
new DPConsoleRunner(otherArgs mkString (" "), extraJars).runPartest
36+
new DPConsoleRunner((otherArgs ::: moreArgs) mkString (" "), extraJars).runPartest
3637
}
3738
}
3839

3940
// console runner has a suite runner which creates a test runner for each test
4041
class DPConsoleRunner(args: String, extraJars: List[String]) extends ConsoleRunner(args) {
42+
println("ConsoleRunner options: " + args)
43+
4144
override val suiteRunner = new DPSuiteRunner (
4245
testSourcePath = optSourcePath getOrElse DPConfig.testRoot,
4346
fileManager = new DottyFileManager(extraJars),

test/test/CompilerTest.scala

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ abstract class CompilerTest extends DottyTest {
8282
* @param extension the file extension, .scala by default
8383
* @param defaultOptions more arguments to the compiler
8484
*/
85-
def compileFile(prefix: String, fileName: String, args: List[String] = Nil, xerrors: Int = 0,
85+
def compileFile(prefix: String, fileName: String, args: List[String] = Nil, xerrors: Int = 0,
8686
extension: String = ".scala", runTest: Boolean = false)
8787
(implicit defaultOptions: List[String]): Unit = {
8888
if (!generatePartestFiles || !partestableFile(prefix, fileName, extension, args ++ defaultOptions, xerrors)) {
@@ -102,7 +102,8 @@ abstract class CompilerTest extends DottyTest {
102102
}
103103
}
104104
}
105-
def runFile(prefix: String, fileName: String, args: List[String] = Nil, xerrors: Int = 0,
105+
106+
def runFile(prefix: String, fileName: String, args: List[String] = Nil, xerrors: Int = 0,
106107
extension: String = ".scala")(implicit defaultOptions: List[String]): Unit =
107108
compileFile(prefix, fileName, args, xerrors, extension, true)
108109

@@ -140,23 +141,28 @@ abstract class CompilerTest extends DottyTest {
140141
}
141142
}
142143
}
144+
143145
def runDir(prefix: String, dirName: String, args: List[String] = Nil, xerrors: Int = 0)
144146
(implicit defaultOptions: List[String]): Unit =
145147
compileDir(prefix, dirName, args, xerrors, true)
146148

149+
def runFiles(path: String, args: List[String] = Nil, verbose: Boolean = true)
150+
(implicit defaultOptions: List[String]): Unit =
151+
compileFiles(path, args, verbose, true)
152+
147153
/** Compiles each source in the directory path separately by calling
148154
* compileFile resp. compileDir. */
149-
def compileFiles(path: String, args: List[String] = Nil, verbose: Boolean = true)
155+
def compileFiles(path: String, args: List[String] = Nil, verbose: Boolean = true, isRunTest: Boolean = false)
150156
(implicit defaultOptions: List[String]): Unit = {
151157
val dir = Directory(path)
152158
val fileNames = dir.files.toArray.map(_.jfile.getName).filter(name => (name endsWith ".scala") || (name endsWith ".java"))
153159
for (name <- fileNames) {
154160
if (verbose) println(s"testing $path$name")
155-
compileFile(path, name, args, 0, "")
161+
compileFile(path, name, args, 0, "", isRunTest)
156162
}
157163
for (subdir <- dir.dirs) {
158164
if (verbose) println(s"testing $subdir")
159-
compileDir(path, subdir.jfile.getName, args, 0)
165+
compileDir(path, subdir.jfile.getName, args, 0, isRunTest)
160166
}
161167
}
162168

@@ -167,7 +173,7 @@ abstract class CompilerTest extends DottyTest {
167173
compileArgs((files ++ args).toArray, xerrors)
168174
} else {
169175
val destDir = Directory(DPConfig.testRoot + JFile.separator + testName)
170-
files.foreach({ file =>
176+
files.foreach({ file =>
171177
val jfile = new JFile(file)
172178
recCopyFiles(jfile, destDir / jfile.getName)
173179
})
@@ -192,7 +198,7 @@ abstract class CompilerTest extends DottyTest {
192198
if (runTest) "run"
193199
else if (xerrors > 0) "neg"
194200
else if (prefixDir.endsWith("run" + JFile.separator)) {
195-
NestUI.echoWarning("WARNING: test is being run as pos test despite being in a run directory. " +
201+
NestUI.echoWarning("WARNING: test is being run as pos test despite being in a run directory. " +
196202
"Use runFile/runDir instead of compileFile/compileDir to do a run test")
197203
"pos"
198204
} else "pos"
@@ -226,7 +232,7 @@ abstract class CompilerTest extends DottyTest {
226232
computeDestAndCopyFiles(source, nextDest, kind, flags, nerr, nr + 1, partestOutput)
227233
}
228234
}
229-
235+
230236
/** Copies the test sources. Creates flags, nerr, check and output files. */
231237
private def copyFiles(sourceFile: Path, dest: Path, partestOutput: String, flags: List[String], nerr: String, kind: String) = {
232238
recCopyFiles(sourceFile, dest)
@@ -237,7 +243,7 @@ abstract class CompilerTest extends DottyTest {
237243
dest.changeExtension("flags").createFile(true).writeAll(flags.mkString(" "))
238244
if (nerr != "0")
239245
dest.changeExtension("nerr").createFile(true).writeAll(nerr)
240-
sourceFile.changeExtension("check").ifFile({ check =>
246+
sourceFile.changeExtension("check").ifFile({ check =>
241247
if (kind == "run")
242248
FileManager.copyFile(check.jfile, dest.changeExtension("check").jfile)
243249
else
@@ -256,7 +262,7 @@ abstract class CompilerTest extends DottyTest {
256262
} else {
257263
NestUI.echoWarning(s"WARNING: ignoring $sf")
258264
}
259-
}, { sdir =>
265+
}, { sdir =>
260266
dest.jfile.mkdirs
261267
sdir.list.foreach(path => recCopyFiles(path, dest / path.name))
262268
}, Some("DPCompilerTest.recCopyFiles: sourceFile not found: " + sourceFile))
@@ -278,7 +284,7 @@ abstract class CompilerTest extends DottyTest {
278284
if (!genSrc.isDefined) {
279285
NotExists
280286
} else {
281-
val source = processFileDir(sourceFile, { f => f.safeSlurp }, { d => Some("") },
287+
val source = processFileDir(sourceFile, { f => f.safeSlurp }, { d => Some("") },
282288
Some("DPCompilerTest sourceFile doesn't exist: " + sourceFile)).get
283289
if (source == genSrc) {
284290
nerr match {
@@ -299,7 +305,7 @@ abstract class CompilerTest extends DottyTest {
299305
val nrString = nr.toString
300306
name match {
301307
case nrFinder(prefix, `nrString`) => prefix + (nr + 1)
302-
case _ =>
308+
case _ =>
303309
assert(nr == 0, "DPCompilerTest couldn't create new version of files, match error")
304310
name + "_v1"
305311
}
@@ -324,7 +330,7 @@ abstract class CompilerTest extends DottyTest {
324330
Directory(prefix + dirName).deepFiles.foreach(source => recCopyFiles(source, destDir / source.name))
325331
destDir.jfile
326332
}
327-
333+
328334
}
329335

330336
object CompilerTest extends App {

tests/pending/run/.checkSrcRegen

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source regeneration: Tue May 12 18:21:01 CEST 2015
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Course-2002-01.scala:41: warning: method loop in object M0 does nothing other than call itself recursively
2+
def loop: Int = loop;
3+
^
4+
232
5+
667
6+
11
7+
10
8+
62.8318
9+
62.8318
10+
62.8318
11+
4.0
12+
81.0
13+
256.0
14+
25.0
15+
1
16+
737.0
17+
1.0
18+
0.0
19+
1.0
20+
76.0
21+
1.4142156862745097
22+
1.7321428571428572
23+
2.0000000929222947
24+
1.4142156862745097
25+
1.7321428571428572
26+
2.0000000929222947
27+
1.4142156862745097
28+
1.7321428571428572
29+
2.0000000929222947
30+
sqrt(2) = 1.4142135623746899
31+
sqrt(2) = 1.4142135623746899
32+
cbrt(2) = 1.2599210500177698
33+
1
34+
1 1
35+
1 2 1
36+
1 3 3 1
37+
1 4 6 4 1

0 commit comments

Comments
 (0)