-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathcmdTests
executable file
·91 lines (80 loc) · 3.41 KB
/
cmdTests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
source $(dirname $0)/cmdTestsCommon.inc.sh
# check that `sbt scalac` compiles and `sbt scala` runs it
echo "testing sbt scalac and scala"
"$SBT" ";scalac $SOURCE -d $OUT ;scala -classpath $OUT $MAIN" > "$tmp"
grep -qe "$EXPECTED_OUTPUT" "$tmp"
# check that `sbt scalac -from-tasty` compiles and `sbt scala` runs it
echo "testing sbt scalac -from-tasty and scala -classpath"
clear_out "$OUT"
"$SBT" ";scalac $SOURCE -d $OUT ;scalac -from-tasty -d $OUT1 $OUT/$TASTY ;scala -classpath $OUT1 $MAIN" > "$tmp"
grep -qe "$EXPECTED_OUTPUT" "$tmp"
echo "testing sbt scalac -from-tasty from a jar and scala -classpath"
clear_out "$OUT"
"$SBT" ";scalac -d $OUT/out.jar $SOURCE ;scalac -from-tasty -d $OUT1 $OUT/out.jar ;scala -classpath $OUT1 $MAIN" > "$tmp"
grep -qe "$EXPECTED_OUTPUT" "$tmp"
echo "testing sbt scala with no -classpath"
clear_out "$OUT"
"$SBT" ";scalac $SOURCE ; scala $MAIN" > "$tmp"
grep -qe "$EXPECTED_OUTPUT" "$tmp"
echo "testing sbt scalac -print-tasty"
clear_out "$OUT"
"$SBT" ";scalac $SOURCE -d $OUT ;scalac -print-tasty -color:never $OUT/$TASTY" > "$tmp"
grep -qe "0: ASTs" "$tmp"
grep -qe "0: 41 \[tests/pos/HelloWorld.scala\]" "$tmp"
echo "testing that paths SourceFile annotations are relativized"
clear_out "$OUT"
"$SBT" "scalac -d $OUT/out.jar -sourceroot tests/pos $(pwd)/tests/pos/i10430/lib.scala $(pwd)/tests/pos/i10430/app.scala"
"$SBT" "scalac -print-tasty -color:never $OUT/out.jar" > "$tmp"
# cat "$tmp" # for debugging
grep -q ": i10430/lib.scala" "$tmp"
grep -q ": i10430/app.scala" "$tmp"
grep -q "[i10430/lib.scala]" "$tmp"
grep -q "[i10430/app.scala]" "$tmp"
if grep -q "tests/pos/i10430/lib.scala" "$tmp"; then
echo "incorrect source file path in tasty"
exit 1
fi
if grep -q "tests/pos/i10430/app.scala" "$tmp"; then
echo "incorrect source file path in tasty"
exit 1
fi
# check that missing source file does not crash message rendering
echo "testing that missing source file does not crash message rendering"
clear_out "$OUT"
clear_out "$OUT1"
cp tests/neg-macros/i6371/A_1.scala $OUT/A.scala
cp tests/neg-macros/i6371/B_2.scala $OUT/B.scala
"$SBT" "scalac $OUT/A.scala -d $OUT1"
rm $OUT/A.scala
# this command is expected to fail
# setting -Dscan=false disables publishing scans to develocity.scala-lang.org
"$SBT" "scalac -classpath $OUT1 -d $OUT1 $OUT/B.scala" -Dscan=false > "$tmp" 2>&1 || echo "ok"
# cat "$tmp" # for debugging
grep -qe "B.scala:2:7" "$tmp"
grep -qe "This location contains code that was inlined from A.scala:3" "$tmp"
echo "testing -Ythrough-tasty"
clear_out "$OUT"
"$SBT" ";scalac -Ythrough-tasty $SOURCE"
## Disabled because of flakeyness, should be changed to not depend on sbt
# echo "running Vulpix meta test"
# tmp=$(mktemp)
# if "$SBT" "scala3-compiler/testOnly dotty.tools.vulpix.VulpixMetaTests" > "$tmp" 2>&1; then
# cat "$tmp"
# echo "failed: sbt exited without error on VulpixMetaTests, these tests are expected to fail"
# exit -1
# fi
# tmp1=$(mktemp)
# cat "$tmp" | sed '/Test run started/,$!d' > "$tmp1"
# set +x # Or the code below produces too much noise
# while read expected <&4 && read actual <&3; do
# if [[ "$expected" != *"SKIP" ]]; then
# if [ "$actual" != "$expected" ]; then
# echo "failed Vulpix meta: the output of sbt differs from the expected output"
# echo "expected : $expected"
# echo "actual : $actual"
# exit -1
# fi
# fi
# done 3<"$tmp1" 4<"./tests/vulpix-tests/meta/sbt-output.check"
echo "cmdTests successful"