Permalink
Browse files

Tests here doc parse errors.

Also add some tests for assignments.

Addresses issue #27 and #103.
  • Loading branch information...
Andy Chu
Andy Chu committed Aug 23, 2018
1 parent 0e843eb commit 6136bbf17a15deeac5f49c40360ddc95837d28b2
Showing with 33 additions and 2 deletions.
  1. +2 −2 core/ui.py
  2. +2 −0 osh/cmd_parse.py
  3. +29 −0 test/parse-errors.sh
View
@@ -125,9 +125,9 @@ def PrettyPrintError(parse_error, arena, f=sys.stderr):
if span_id == const.NO_INTEGER: # Any clause above might return this.
# This is usually a bug.
print('*** Error has no source location info ***', file=f)
return
else:
PrintFilenameAndLine(span_id, arena, f=f)
PrintFilenameAndLine(span_id, arena, f=f)
print(parse_error.UserErrorString(), file=f)
View
@@ -121,6 +121,8 @@ def _MaybeReadHereDocs(self):
from osh import parse_lib # Avoid circular import
w_parser = parse_lib.MakeWordParserForHereDoc(lines, self.arena)
# NOTE: There can be different kinds of parse errors in here docs.
word = w_parser.ReadHereDocBody()
if not word:
self.AddErrorContext(
View
@@ -205,6 +205,35 @@ simple-command() {
_error-case 'PYTHONPATH+=1 python'
}
assign() {
set +o errexit
_error-case 'local "ab"'
_error-case 'local a.b'
}
# I can't think of any other here doc error conditions except arith/var/command
# substitution, and unterminated.
here-doc() {
set +o errexit
# Arith in here doc
_error-case 'cat <<EOF
$(( 1 * ))
EOF
'
# Varsub in here doc
_error-case 'cat <<EOF
invalid: ${a!}
EOF
'
_error-case 'cat <<EOF
$(for x in )
EOF
'
}
cases-in-strings() {
set +o errexit

0 comments on commit 6136bbf

Please sign in to comment.