Skip to content

Commit cdc6603

Browse files
committed
Run syntax scripts for Rscripts
We have a similar method for Python. Also added an example submission, which should give COMPILER-ERROR as its invalid syntax.
1 parent 48578e5 commit cdc6603

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This should give COMPILER-ERROR on the default problem 'hello'.
2+
#
3+
# @EXPECTED_RESULTS@: COMPILER-ERROR
4+
5+
cat("Missing closing bracket!\n"

sql/files/defaultdata/r/run

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ if [ -z "$ENTRY_POINT" ]; then
2020
echo "Info: detected entry_point: $MAINSOURCE"
2121
fi
2222

23-
# No easy way to test R scripts for syntax
24-
2523
# Check if entry point is valid
2624
if [ ! -r "$MAINSOURCE" ]; then
2725
echo "Error: main source file '$MAINSOURCE' is not readable" >&2
2826
exit 1
2927
fi
3028

29+
# Check syntax
30+
Rscript -e "parse('"$@"')"
31+
EXITCODE=$?
32+
[ "$EXITCODE" -ne 0 ] && exit $EXITCODE
3133

3234
# Write executing script:
3335
cat > "$DEST" <<EOF

0 commit comments

Comments
 (0)