Permalink
Browse files

Fix spec tests and adjust allowed failures.

- Fix a bug in arithmetic parse error
- Disallow redirects in assignments
- Adjust for 'A= (1 2)' being fixed

- Add a failing test for 'echo a(b)' in osh
  • Loading branch information...
Andy Chu
Andy Chu committed Oct 18, 2017
1 parent fba1a2e commit c19885e49639a42c7995bb1476ea42cf3a93a169
Showing with 23 additions and 12 deletions.
  1. +4 −1 osh/arith_parse.py
  2. +0 −2 spec/arith.test.sh
  3. +5 −0 spec/parse-errors.test.sh
  4. +13 −8 spec/redirect.test.sh
  5. +1 −1 test/spec.sh
View
@@ -6,10 +6,13 @@
import sys
from core import tdop
from core import util
from core.id_kind import Id
from core import word
from osh import ast_ as ast
p_die = util.p_die
def NullIncDec(p, w, bp):
""" ++x or ++x[1] """
@@ -64,7 +67,7 @@ def LeftIndex(p, w, left, unused_bp):
3. strings don't have mutable characters.
"""
if not tdop.IsIndexable(left):
raise tdop.TdopParseError("%s can't be indexed" % left)
p_die("%s can't be indexed", left, word=w)
index = p.ParseUntil(0)
p.Eat(Id.Arith_RBracket)
View
@@ -323,5 +323,3 @@ echo "status=$?"
# N-I dash stdout: status=127
# N-I dash status: 0
@@ -98,3 +98,8 @@ f() {
}
# status: 2
# BUG dash/bash/mksh status: 0
### misplaced parentheses are not a subshell
echo a(b)
# status: 2
# OK mksh status: 1
View
@@ -23,18 +23,20 @@ echo status=$?
# stdout: status=1
# OK dash stdout: status=2
### No command
# Hm this is valid in bash and dash. It's parsed as an assigment with a
# redirect, which doesn't make sense. But it's a mistake, and should be a W2
# warning for us.
FOO=bar 2>/dev/null
### Redirect in subshell
### Redirect in command sub
FOO=$(echo foo 1>&2)
echo $FOO
# stdout:
# stderr: foo
### Redirect in assignment is invalid
# Hm this is valid in bash and dash. It's parsed as an assigment with a
# redirect, which doesn't make sense. But it's a mistake, and should be a W2
# warning for us.
FOO=bar 2>/dev/null
# status: 2
# OK bash/dash/mksh status: 0
### Redirect in assignment
# dash captures stderr to a file here, which seems correct. Bash doesn't and
# just lets it go to actual stderr.
@@ -44,8 +46,11 @@ FOO=$(echo foo 1>&2) 2>$TMP/no-command.txt
echo FILE=
cat $TMP/no-command.txt
echo "FOO=$FOO"
# stdout-json: "FILE=\nfoo\nFOO=\n"
# status: 2
# OK dash/mksh stdout-json: "FILE=\nfoo\nFOO=\n"
# OK dash/mksh status: 0
# BUG bash stdout-json: "FILE=\nFOO=\n"
# OK bash status: 0
### Redirect in function body.
func() { echo hi; } 1>&2
View
@@ -416,7 +416,7 @@ arith-context() {
}
array() {
sh-spec spec/array.test.sh --osh-failures-allowed 12 \
sh-spec spec/array.test.sh --osh-failures-allowed 11 \
$BASH $MKSH $OSH "$@"
}

0 comments on commit c19885e

Please sign in to comment.