Skip to content

Commit 0da788c

Browse files
felixmuldersmarter
authored andcommitted
Add bin project to separate scripted tests from compiler tests
1 parent 0bd9598 commit 0da788c

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

test/scripts/TestDotc.scala renamed to bin/test/TestScripts.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.io.Source
77
import scala.sys.process.{Process, ProcessLogger}
88
import java.io.{File => JFile, FileNotFoundException}
99

10-
class TestDotc {
10+
class TestScripts {
1111
private val lineSep = util.Properties.lineSeparator
1212
private def doUnlessWindows(op: => Unit) =
1313
if (!System.getProperty("os.name").toLowerCase.contains("windows"))
@@ -28,11 +28,13 @@ class TestDotc {
2828
}
2929

3030
try {
31-
for (jar <- Source.fromFile(".packages").getLines())
31+
for (jar <- Source.fromFile("../.packages").getLines())
3232
delete(jar)
3333

34-
delete(".packages")
35-
delete("src/dotty/tools/dotc/Dummy.scala")
34+
delete("../.packages")
35+
delete("./src/dotty/tools/dotc/Dummy.scala")
36+
delete("HelloWorld.class")
37+
delete("HelloWorld$.class")
3638
} catch {
3739
case _: FileNotFoundException => ()
3840
}
@@ -45,15 +47,15 @@ class TestDotc {
4547
* execute it using dotr
4648
*/
4749
@Test def buildAndRunHelloWorld = doUnlessWindows {
48-
val (retDotc, dotcOutput) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
50+
val (retDotc, dotcOutput) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
4951

5052
// Check correct output of building and running dotc
5153
assert(
5254
retDotc == 0,
5355
s"bin/dotc script did not run properly. Output:$lineSep$dotcOutput"
5456
)
5557

56-
val (retDotr, dotrOutput) = executeScript("bin/dotr HelloWorld")
58+
val (retDotr, dotrOutput) = executeScript("./bin/dotr HelloWorld")
5759
assert(
5860
retDotr == 0 && dotrOutput == "hello world",
5961
s"Running hello world exited with status: $retDotr and output: $dotrOutput"
@@ -64,24 +66,24 @@ class TestDotc {
6466
* rebuild dotty if needed
6567
*/
6668
@Test def rebuildIfNecessary = doUnlessWindows {
67-
val (retFirstBuild, _) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
69+
val (retFirstBuild, _) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
6870
assert(retFirstBuild == 0, "building dotc failed")
6971

70-
// Create a new file
71-
new JFile("src/dotty/tools/dotc/Dummy.scala").createNewFile()
72+
// Create a new file to force rebuild
73+
new JFile("./src/dotty/tools/dotc/Dummy.scala").createNewFile()
7274

73-
val (retSecondBuild, output) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
75+
val (retSecondBuild, output) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
7476
assert(
7577
retSecondBuild == 0 && output.contains("rebuilding"),
7678
s"Rebuilding the tool should result in jar files being rebuilt. Status: $retSecondBuild, output:$lineSep$output")
7779
}
7880

7981
/** if no changes to dotty, dotc script should be fast */
8082
@Test def beFastOnNoChanges = doUnlessWindows {
81-
val (retFirstBuild, _) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
83+
val (retFirstBuild, _) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
8284
assert(retFirstBuild == 0, "building dotc failed")
8385

84-
val (ret, output) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
86+
val (ret, output) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
8587
assert(
8688
ret == 0 && !output.contains("rebuilding"),
8789
s"Project recompiled when it didn't need to be. Status $ret, output:$lineSep$output")

project/Build.scala

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,33 +216,44 @@ object DottyBuild extends Build {
216216
";dotty-interfaces/package" +
217217
";dotty-compiler/package" +
218218
";dotty-library/package" +
219-
";test:package"
219+
";dotty-compiler/test:package"
220220
) ++
221221
addCommandAlias(
222222
"partest",
223223
";packageAll" +
224224
";test:runMain dotc.build" +
225225
";lockPartestFile" +
226-
";test:test" +
227-
";runPartestRunner"
226+
";dotty-compiler/test:test" +
227+
";runPartestRunner" +
228+
";bin/test" // script tests need to run after the unit tests
228229
) ++
229-
addCommandAlias("partest-only",
230+
addCommandAlias(
231+
"partest-only",
230232
";packageAll" +
231233
";test:runMain dotc.build" +
232234
";lockPartestFile" +
233-
";test:test-only dotc.tests" +
235+
";dotty-compiler/test:test-only dotc.tests" +
234236
";runPartestRunner"
235237
) ++
236238
addCommandAlias(
237239
"partest-only-no-bootstrap",
238240
";packageAll" +
239241
";lockPartestFile" +
240-
";test:test-only dotc.tests" +
242+
";dotty-compiler/test:test-only dotc.tests" +
241243
";runPartestRunner"
242244
)
243245
).
244246
settings(publishing)
245247

248+
/* Contains unit tests for the scripts */
249+
lazy val bin = project.in(file("bin")).
250+
settings(sourceStructure).
251+
settings(
252+
parallelExecution in Test := false,
253+
libraryDependencies +=
254+
"com.novocode" % "junit-interface" % "0.11" % "test"
255+
)
256+
246257
lazy val `dotty-library` = project.in(file("library")).
247258
settings(sourceStructure).
248259
settings(

0 commit comments

Comments
 (0)