Skip to content

Commit fbed6cc

Browse files
Merge pull request #3493 from rsoeldner/dotr-classpath
Fix #3477: Add custom classpath to dotr script
2 parents 42f8369 + a477cd5 commit fbed6cc

File tree

2 files changed

+50
-27
lines changed

2 files changed

+50
-27
lines changed

dist/bin/dotr

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,45 @@ fi
2929

3030
source "$PROG_HOME/bin/common"
3131

32-
CLASS_PATH=".$PSEP$DOTTY_LIB$PSEP$SCALA_LIB"
32+
declare -a residual_args
33+
run_repl=false
34+
CLASS_PATH=""
3335

34-
# -d must be the first option
35-
case "$1" in
36-
-d) DEBUG="$DEBUG_STR" && shift ;;
37-
esac
36+
while [[ $# -gt 0 ]]; do
37+
case "$1" in
38+
-repl)
39+
run_repl=true
40+
shift
41+
;;
42+
-classpath)
43+
CLASS_PATH="$2"
44+
shift
45+
shift
46+
;;
47+
-d)
48+
DEBUG="$DEBUG_STR"
49+
shift
50+
;;
51+
*)
52+
residual_args+=("$1")
53+
shift
54+
;;
3855

39-
first_arg="$1"
56+
esac
57+
done
4058

41-
if [ -z "$1" ]; then
42-
echo "Starting dotty REPL..."
43-
eval "$PROG_HOME/bin/dotc -repl"
44-
elif [[ ${first_arg:0:1} == "-" ]]; then
45-
eval "$PROG_HOME/bin/dotc -repl $@"
59+
if [ $run_repl == true ] || [ ${#residual_args[@]} -eq 0 ]; then
60+
if [ "$CLASS_PATH" ]; then
61+
cp_arg="-classpath $CLASS_PATH"
62+
fi
63+
echo "Starting dotty REPL"
64+
eval "$PROG_HOME/bin/dotc $cp_arg -repl ${residual_args[@]}"
4665
else
47-
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$CLASS_PATH\"" $@
66+
cp_arg="-classpath $DOTTY_LIB$PSEP$SCALA_LIB"
67+
if [ -z "$CLASS_PATH" ]; then
68+
cp_arg+="$PSEP."
69+
else
70+
cp_arg+="$PSEP$CLASS_PATH"
71+
fi
72+
eval exec "\"$JAVACMD\"" "$DEBUG" "$cp_arg" "${residual_args[@]}"
4873
fi

project/scripts/sbtBootstrappedTests

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
# check that benchmarks can run
44
./project/scripts/sbt "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala"
55

6-
76
# setup for `dotc`/`dotr` script tests
87
./project/scripts/sbt dist-bootstrapped/pack
98

109
# check that `dotc` compiles and `dotr` runs it
1110
echo "testing ./bin/dotc and ./bin/dotr"
1211
mkdir out/scriptedtest0
1312
./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0
14-
# FIXME #3477
15-
#./bin/dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out
16-
#if grep -e "dotr test ok" sbtdotr1.out; then
17-
# echo "output ok"
18-
#else
19-
# exit -1
20-
#fi
13+
14+
./bin/dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out
15+
if grep -e "dotr test ok" sbtdotr1.out; then
16+
echo "output ok"
17+
else
18+
exit -1
19+
fi
2120
2221
2322
# check that `dotc` compiles and `dotr` runs it
@@ -26,10 +25,9 @@ mkdir out/scriptedtest1
2625
mkdir out/scriptedtest2
2726
./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/
2827
./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test
29-
# FIXME #3477
30-
#./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out
31-
#if grep -e "dotr test ok" sbtdotr2.out; then
32-
# echo "output ok"
33-
#else
34-
# exit -1
35-
#fi
28+
./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out
29+
if grep -e "dotr test ok" sbtdotr2.out; then
30+
echo "output ok"
31+
else
32+
exit -1
33+
fi

0 commit comments

Comments
 (0)