Skip to content

Commit e0e3446

Browse files
committed
Add bin project to separate scripted tests from compiler tests
1 parent a5785cc commit e0e3446

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
@@ -215,33 +215,44 @@ object DottyBuild extends Build {
215215
";dotty-interfaces/package" +
216216
";dotty-compiler/package" +
217217
";dotty-library/package" +
218-
";test:package"
218+
";dotty-compiler/test:package"
219219
) ++
220220
addCommandAlias(
221221
"partest",
222222
";packageAll" +
223223
";test:runMain dotc.build" +
224224
";lockPartestFile" +
225-
";test:test" +
226-
";runPartestRunner"
225+
";dotty-compiler/test:test" +
226+
";runPartestRunner" +
227+
";bin/test" // script tests need to run after the unit tests
227228
) ++
228-
addCommandAlias("partest-only",
229+
addCommandAlias(
230+
"partest-only",
229231
";packageAll" +
230232
";test:runMain dotc.build" +
231233
";lockPartestFile" +
232-
";test:test-only dotc.tests" +
234+
";dotty-compiler/test:test-only dotc.tests" +
233235
";runPartestRunner"
234236
) ++
235237
addCommandAlias(
236238
"partest-only-no-bootstrap",
237239
";packageAll" +
238240
";lockPartestFile" +
239-
";test:test-only dotc.tests" +
241+
";dotty-compiler/test:test-only dotc.tests" +
240242
";runPartestRunner"
241243
)
242244
).
243245
settings(publishing)
244246

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

0 commit comments

Comments
 (0)