Skip to content

Commit

Permalink
[spec/interactive] New test file for interactive cases.
Browse files Browse the repository at this point in the history
Regression for 'exit' not respected in oshrc.
  • Loading branch information
Andy Chu committed Jul 6, 2019
1 parent b536f9c commit e19a904
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 17 deletions.
53 changes: 53 additions & 0 deletions spec/interactive.test.sh
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
#

#### 'exit' in oshrc (regression)
cat >$TMP/oshrc <<EOF
echo one
exit 42
echo two
EOF
$SH --rcfile $TMP/oshrc -i -c 'echo hello'
## status: 42
## STDOUT:
one
## END
## N-I dash status: 2
## N-I dash stdout-json: ""
## N-I mksh status: 1
## N-I mksh stdout-json: ""

#### fatal errors continue

# NOTE: tried here doc, but sys.stdin.isatty() fails. Could we fake it?
$SH -i -c '
echo $(( 1 / 0 ))
echo one
exit 42
'
## status: 42
## STDOUT:
one
## END
## N-I dash status: 2
## N-I dash stdout-json: ""
## N-I mksh status: 1
## N-I mksh stdout-json: ""

#### interactive shell loads rcfile (when combined with -c)
$SH -c 'echo 1'
cat >$TMP/rcfile <<EOF
echo RCFILE
EOF
$SH --rcfile $TMP/rcfile -i -c 'echo 2'
## STDOUT:
1
RCFILE
2
## END
## N-I dash/mksh STDOUT:
1
## END
## N-I dash status: 2
## N-I mksh status: 1

17 changes: 0 additions & 17 deletions spec/sh-options.test.sh
Expand Up @@ -428,23 +428,6 @@ invalidZZ=1
invalidZZ=127
## END

#### sh -i loads rcfile (when combined with -c)
$SH -c 'echo 1'
cat >$TMP/rcfile <<EOF
echo RCFILE
EOF
$SH --rcfile $TMP/rcfile -i -c 'echo 2'
## STDOUT:
1
RCFILE
2
## END
## N-I dash/mksh STDOUT:
1
## END
## N-I dash status: 2
## N-I mksh status: 1

#### shopt -s all:strict
n=2

Expand Down
4 changes: 4 additions & 0 deletions test/spec.sh
Expand Up @@ -216,6 +216,10 @@ smoke() {
sh-spec spec/smoke.test.sh ${REF_SHELLS[@]} $OSH_LIST "$@"
}

interactive() {
sh-spec spec/interactive.test.sh ${REF_SHELLS[@]} $OSH_LIST "$@"
}

prompt() {
sh-spec spec/prompt.test.sh --osh-failures-allowed 1 \
$BASH $OSH_LIST "$@"
Expand Down

0 comments on commit e19a904

Please sign in to comment.