@@ -7,7 +7,7 @@ import scala.io.Source
7
7
import scala .sys .process .{Process , ProcessLogger }
8
8
import java .io .{File => JFile , FileNotFoundException }
9
9
10
- class TestDotc {
10
+ class TestScripts {
11
11
private val lineSep = util.Properties .lineSeparator
12
12
private def doUnlessWindows (op : => Unit ) =
13
13
if (! System .getProperty(" os.name" ).toLowerCase.contains(" windows" ))
@@ -28,11 +28,13 @@ class TestDotc {
28
28
}
29
29
30
30
try {
31
- for (jar <- Source .fromFile(" .packages" ).getLines())
31
+ for (jar <- Source .fromFile(" ../. packages" ).getLines())
32
32
delete(jar)
33
33
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" )
36
38
} catch {
37
39
case _ : FileNotFoundException => ()
38
40
}
@@ -45,15 +47,15 @@ class TestDotc {
45
47
* execute it using dotr
46
48
*/
47
49
@ 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" )
49
51
50
52
// Check correct output of building and running dotc
51
53
assert(
52
54
retDotc == 0 ,
53
55
s " bin/dotc script did not run properly. Output: $lineSep$dotcOutput"
54
56
)
55
57
56
- val (retDotr, dotrOutput) = executeScript(" bin/dotr HelloWorld" )
58
+ val (retDotr, dotrOutput) = executeScript(" ./ bin/dotr HelloWorld" )
57
59
assert(
58
60
retDotr == 0 && dotrOutput == " hello world" ,
59
61
s " Running hello world exited with status: $retDotr and output: $dotrOutput"
@@ -64,24 +66,24 @@ class TestDotc {
64
66
* rebuild dotty if needed
65
67
*/
66
68
@ Test def rebuildIfNecessary = doUnlessWindows {
67
- val (retFirstBuild, _) = executeScript(" bin/dotc tests/pos/HelloWorld.scala" )
69
+ val (retFirstBuild, _) = executeScript(" ./ bin/dotc ./ tests/pos/HelloWorld.scala" )
68
70
assert(retFirstBuild == 0 , " building dotc failed" )
69
71
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()
72
74
73
- val (retSecondBuild, output) = executeScript(" bin/dotc tests/pos/HelloWorld.scala" )
75
+ val (retSecondBuild, output) = executeScript(" ./ bin/dotc ./ tests/pos/HelloWorld.scala" )
74
76
assert(
75
77
retSecondBuild == 0 && output.contains(" rebuilding" ),
76
78
s " Rebuilding the tool should result in jar files being rebuilt. Status: $retSecondBuild, output: $lineSep$output" )
77
79
}
78
80
79
81
/** if no changes to dotty, dotc script should be fast */
80
82
@ Test def beFastOnNoChanges = doUnlessWindows {
81
- val (retFirstBuild, _) = executeScript(" bin/dotc tests/pos/HelloWorld.scala" )
83
+ val (retFirstBuild, _) = executeScript(" ./ bin/dotc ./ tests/pos/HelloWorld.scala" )
82
84
assert(retFirstBuild == 0 , " building dotc failed" )
83
85
84
- val (ret, output) = executeScript(" bin/dotc tests/pos/HelloWorld.scala" )
86
+ val (ret, output) = executeScript(" ./ bin/dotc ./ tests/pos/HelloWorld.scala" )
85
87
assert(
86
88
ret == 0 && ! output.contains(" rebuilding" ),
87
89
s " Project recompiled when it didn't need to be. Status $ret, output: $lineSep$output" )
0 commit comments