Skip to content

Commit bdfe740

Browse files
authored
Merge pull request #4078 from dotty-staging/fix-dotr
Fix dotr script
2 parents 4be2e76 + b53a577 commit bdfe740

File tree

2 files changed

+52
-67
lines changed

2 files changed

+52
-67
lines changed

dist/bin/dotr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
8888
else
8989
cp_arg+="$PSEP$CLASS_PATH"
9090
fi
91-
if [ $class_path_count > 1 ]; then
91+
if [ "$class_path_count" -gt 1 ]; then
9292
echo "warning: multiple classpaths are found, dotr only use the last one."
9393
fi
9494
if [ $with_compiler == true ]; then

project/scripts/cmdTests

Lines changed: 51 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,85 @@
22

33
set -eux
44

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+
513
# 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+
}
726

827
# check that `sbt dotc` compiles and `sbt dotr` runs it
928
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"
1931

2032
# check that `sbt dotc` compiles and `sbt dotr` runs it
2133
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"
3237

3338
# check that `sbt dotc -decompile` runs
3439
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+
4343
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"
5147

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"
6152

6253
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"
7156

7257

73-
# check that benchmarks can run
74-
./project/scripts/sbt "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala"
75-
7658
# setup for `dotc`/`dotr` script tests
77-
./project/scripts/sbt dist-bootstrapped/pack
59+
"$SBT" dist-bootstrapped/pack
7860

7961
# check that `dotc` compiles and `dotr` runs it
8062
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")"
8467

8568
# check that `dotc -from-tasty` compiles and `dotr` runs it
8669
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")"
9274

9375
# 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"
9580

9681
echo "running Vulpix meta test"
9782
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
9984
cat "$tmp"
10085
echo "failed: sbt exited without error on VulpixMetaTests, these tests are expected to fail"
10186
exit -1

0 commit comments

Comments
 (0)