|
2 | 2 |
|
3 | 3 | set -eux
|
4 | 4 |
|
| 5 | +SBT="./project/scripts/sbt" # if run on CI |
| 6 | +# SBT="sbt" # if run locally |
| 7 | + |
| 8 | +SOURCE="tests/pos/HelloWorld.scala" |
| 9 | +MAIN="HelloWorld" |
| 10 | +EXPECTED_OUTPUT="hello world" |
| 11 | +COMPILER_CP="compiler/target/scala-2.12/classes" # FIXME: This is not very reliable |
| 12 | + |
5 | 13 | # check that benchmarks can run
|
6 |
| -./project/scripts/sbt "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" |
| 14 | +"$SBT" "dotty-bench/jmh:run 1 1 tests/pos/alias.scala" |
| 15 | +"$SBT" "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" |
| 16 | + |
| 17 | +OUT=$(mktemp -d) |
| 18 | +OUT1=$(mktemp -d) |
| 19 | +tmp=$(mktemp) |
| 20 | + |
| 21 | +clear_out() |
| 22 | +{ |
| 23 | + local out="$1" |
| 24 | + rm -rf "$out/*" |
| 25 | +} |
7 | 26 |
|
8 | 27 | # check that `sbt dotc` compiles and `sbt dotr` runs it
|
9 | 28 | echo "testing sbt dotc and dotr"
|
10 |
| -mkdir -p out/scriptedtest0 |
11 |
| -./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0 ;dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out |
12 |
| -cat sbtdotr1.out |
13 |
| -if grep -e "dotr test ok" sbtdotr1.out; then |
14 |
| - echo "output ok" |
15 |
| -else |
16 |
| - echo "failed output check" |
17 |
| - exit -1 |
18 |
| -fi |
| 29 | +"$SBT" ";dotc $SOURCE -d $OUT ;dotr -classpath $OUT $MAIN" > "$tmp" |
| 30 | +grep -qe "$EXPECTED_OUTPUT" "$tmp" |
19 | 31 |
|
20 | 32 | # check that `sbt dotc` compiles and `sbt dotr` runs it
|
21 | 33 | echo "testing sbt dotc -from-tasty and dotr -classpath"
|
22 |
| -mkdir out/scriptedtest1 |
23 |
| -mkdir out/scriptedtest2 |
24 |
| -./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/; dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test; dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out |
25 |
| -cat sbtdotr2.out |
26 |
| -if grep -e "dotr test ok" sbtdotr2.out; then |
27 |
| - echo "output ok" |
28 |
| -else |
29 |
| - echo "failed output check" |
30 |
| - exit -1 |
31 |
| -fi |
| 34 | +clear_out "$OUT" |
| 35 | +"$SBT" ";dotc $SOURCE -d $OUT ;dotc -from-tasty -classpath $OUT -d $OUT1 $MAIN ;dotr -classpath $OUT1 $MAIN" > "$tmp" |
| 36 | +grep -qe "$EXPECTED_OUTPUT" "$tmp" |
32 | 37 |
|
33 | 38 | # check that `sbt dotc -decompile` runs
|
34 | 39 | echo "testing sbt dotc -decompile"
|
35 |
| -./project/scripts/sbt ";dotc -decompile -color:never -classpath out/scriptedtest1 dotrtest.Test" > sbtdotc3.out |
36 |
| -cat sbtdotc3.out |
37 |
| -if grep -e "def main(args: Array\[String\]): Unit =" sbtdotc3.out; then |
38 |
| - echo "output ok" |
39 |
| -else |
40 |
| - echo "failed output check" |
41 |
| - exit -1 |
42 |
| -fi |
| 40 | +"$SBT" ";dotc -decompile -color:never -classpath $OUT $MAIN" > "$tmp" |
| 41 | +grep -qe "def main(args: Array\[String\]): Unit =" "$tmp" |
| 42 | + |
43 | 43 | echo "testing sbt dotr with no -classpath"
|
44 |
| -./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala; dotr dotrtest.Test" > sbtdotr3.out |
45 |
| -cat sbtdotr3.out |
46 |
| -if grep -e "dotr test ok" sbtdotr3.out; then |
47 |
| - echo "output ok" |
48 |
| -else |
49 |
| - exit -1 |
50 |
| -fi |
| 44 | +clear_out "$OUT" |
| 45 | +"$SBT" ";dotc $SOURCE ; dotr $MAIN" > "$tmp" |
| 46 | +grep -qe "$EXPECTED_OUTPUT" "$tmp" |
51 | 47 |
|
52 |
| -#echo "testing loading tasty from .tasty file in jar" |
53 |
| -./project/scripts/sbt ";dotc -d out/scriptedtest4.jar -YemitTasty tests/pos/sbtDotrTest.scala; dotc -decompile -classpath out/scriptedtest4.jar -color:never dotrtest.Test" > sbtdot4.out |
54 |
| -cat sbtdot4.out |
55 |
| -if grep -e "def main(args: Array\[String\]): Unit =" sbtdot4.out; then |
56 |
| - echo "output ok" |
57 |
| -else |
58 |
| - echo "failed output check" |
59 |
| - exit -1 |
60 |
| -fi |
| 48 | +echo "testing loading tasty from .tasty file in jar" |
| 49 | +clear_out "$OUT" |
| 50 | +"$SBT" ";dotc -d $OUT/out.jar -Yemit-tasty $SOURCE; dotc -decompile -classpath $OUT/out.jar -color:never $MAIN" > "$tmp" |
| 51 | +grep -qe "def main(args: Array\[String\]): Unit =" "$tmp" |
61 | 52 |
|
62 | 53 | echo "testing scala.quoted.Expr.run from sbt dotr"
|
63 |
| -./project/scripts/sbt ";dotc -classpath compiler/target/scala-2.12/classes tests/run-with-compiler/quote-run.scala; dotr -with-compiler Test" > sbtdot5.out |
64 |
| -cat sbtdot5.out |
65 |
| -if grep -e "val a: Int = 3" sbtdot5.out; then |
66 |
| - echo "output ok" |
67 |
| -else |
68 |
| - echo "failed output check" |
69 |
| - exit -1 |
70 |
| -fi |
| 54 | +"$SBT" ";dotty-compiler/compile ;dotc -classpath $COMPILER_CP tests/run-with-compiler/quote-run.scala; dotr -with-compiler Test" > "$tmp" |
| 55 | +grep -qe "val a: Int = 3" "$tmp" |
71 | 56 |
|
72 | 57 |
|
73 |
| -# check that benchmarks can run |
74 |
| -./project/scripts/sbt "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala" |
75 |
| - |
76 | 58 | # setup for `dotc`/`dotr` script tests
|
77 |
| -./project/scripts/sbt dist-bootstrapped/pack |
| 59 | +"$SBT" dist-bootstrapped/pack |
78 | 60 |
|
79 | 61 | # check that `dotc` compiles and `dotr` runs it
|
80 | 62 | echo "testing ./bin/dotc and ./bin/dotr"
|
81 |
| -mkdir -p out/scriptedtest0 |
82 |
| -./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0 |
83 |
| -./bin/dotr -classpath out/scriptedtest0 dotrtest.Test |
| 63 | +clear_out "$OUT" |
| 64 | +./bin/dotc "$SOURCE" -d "$OUT" |
| 65 | +./bin/dotr -classpath "$OUT" "$MAIN" > "$tmp" |
| 66 | +test "$EXPECTED_OUTPUT" = "$(cat "$tmp")" |
84 | 67 |
|
85 | 68 | # check that `dotc -from-tasty` compiles and `dotr` runs it
|
86 | 69 | echo "testing ./bin/dotc -from-tasty and dotr -classpath"
|
87 |
| -mkdir -p out/scriptedtest1 |
88 |
| -mkdir -p out/scriptedtest2 |
89 |
| -./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/ |
90 |
| -./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test |
91 |
| -./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test |
| 70 | +clear_out "$OUT1" |
| 71 | +./bin/dotc -from-tasty -classpath "$OUT" -d "$OUT1" "$MAIN" |
| 72 | +./bin/dotr -classpath "$OUT1" "$MAIN" > "$tmp" |
| 73 | +test "$EXPECTED_OUTPUT" = "$(cat "$tmp")" |
92 | 74 |
|
93 | 75 | # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI
|
94 |
| -mkdir -p _site && ./bin/dotd -project Hello -siteroot _site tests/run/hello.scala |
| 76 | + |
| 77 | +echo "testing ./bin/dotd" |
| 78 | +clear_out "$OUT" |
| 79 | +./bin/dotd -project Hello -siteroot "$OUT" "$SOURCE" |
95 | 80 |
|
96 | 81 | echo "running Vulpix meta test"
|
97 | 82 | tmp=$(mktemp)
|
98 |
| -if ./project/scripts/sbt "dotty-compiler/testOnly dotty.tools.vulpix.VulpixMetaTests" > "$tmp" 2>&1; then |
| 83 | +if "$SBT" "dotty-compiler/testOnly dotty.tools.vulpix.VulpixMetaTests" > "$tmp" 2>&1; then |
99 | 84 | cat "$tmp"
|
100 | 85 | echo "failed: sbt exited without error on VulpixMetaTests, these tests are expected to fail"
|
101 | 86 | exit -1
|
|
0 commit comments