Permalink
Browse files

Failing tests for 'source' with arguments.

This is a minor cleanup of tests written by BatmanAoD.

Co-authored-by: BatmanAoD <BatmanAoD@users.noreply.github.com>
  • Loading branch information...
Andy Chu and BatmanAoD committed Jun 22, 2018
1 parent eec59fb commit 1d6bbeb408bfbe5af7b76f5d232d75059460ec69
Showing with 43 additions and 1 deletion.
  1. +33 −0 spec/builtins.test.sh
  2. +2 −0 spec/testdata/show-argv.sh
  3. +7 −0 spec/testdata/source-argv.sh
  4. +1 −1 test/spec.sh
View
@@ -156,6 +156,39 @@ echo status=$?
# OK bash stdout: status=2
# OK dash stdout: status=127
### Source with arguments
. spec/testdata/show-argv.sh foo bar # dash doesn't have source
## STDOUT:
show-argv: foo bar
## END
## N-I dash STDOUT:
show-argv:
## END
### Source from a function, mutating argv and defining a local var
f() {
. spec/testdata/source-argv.sh # no argv
. spec/testdata/source-argv.sh args to src # new argv
echo $@
echo foo=$foo # defined in source-argv.sh
}
f args to func
echo foo=$foo # not defined
## STDOUT:
source-argv: args to func
source-argv: args to src
to func
foo=foo_val
foo=
## END
## N-I dash STDOUT:
source-argv: args to func
source-argv: to func
func
foo=foo_val
foo=
## END
### Exit out of function
f() { exit 3; }
f
@@ -0,0 +1,2 @@
# File that can be sourced
echo show-argv: $@
@@ -0,0 +1,7 @@
#!/bin/bash
echo source-argv: $@
# 'shift' will only apply to the args of 'f()' when no new args are provided.
# This can mutate the "caller's" arguments array!
shift
local foo=foo_val
View
@@ -268,7 +268,7 @@ if_() {
}
builtins() {
sh-spec spec/builtins.test.sh --osh-failures-allowed 1 \
sh-spec spec/builtins.test.sh --osh-failures-allowed 3 \
${REF_SHELLS[@]} $OSH "$@"
}

0 comments on commit 1d6bbeb

Please sign in to comment.