Permalink
Browse files

Tests: portability improvements and additional test (#40)

* Add test for :- substitution w/ empty alternative

The correct behaviour here is to substitute the empty string, but
osh currently substitutes nothing.

* Use /usr/bin/env time rather than /usr/bin/time

This is more portable to operating systems such as NixOS which do
not have /usr as a global shared namespace.

* spec.sh: Find busybox portably
  • Loading branch information...
lheckemann authored and andychu committed Sep 22, 2017
1 parent 1d964ee commit ec7ca9d9f5b92ac3bfa42ce32ce1588cef3efe47
Showing with 9 additions and 4 deletions.
  1. +2 −2 spec/show-fd-table.sh
  2. +5 −0 spec/var-sub-quote.test.sh
  3. +1 −1 test/spec-runner.sh
  4. +1 −1 test/spec.sh
View
@@ -13,7 +13,7 @@ show-fd-table() {
echo " function in pid $$"
# Make it truly parallel
sleep 0.5
/usr/bin/time --output /tmp/$$.txt -- spec/bin/show_fd_table.py "$@"
/usr/bin/env time --output /tmp/$$.txt -- spec/bin/show_fd_table.py "$@"
}
# Trying to recreate spec-runner problem with file descriptors.
@@ -25,7 +25,7 @@ main() {
echo
# File descriptor 3 is open!
/usr/bin/time --output /tmp/task.txt -- spec/bin/show_fd_table.py
/usr/bin/env time --output /tmp/task.txt -- spec/bin/show_fd_table.py
echo
# Cannot reproduce problem. What's the deal with descriptors 8 and 9? Oh
@@ -14,6 +14,11 @@
# LexState.OUTER. If we have "${}", then it's parsed as LexState.DQ. That
# makes sense I guess. Vim's syntax highlighting is throwing me off.
### :- with empty alternative
foo=
argv.py "${foo:-}"
# stdout: ['']
### :-
empty=''
argv.py ${empty:-a} ${Unset:-b}
View
@@ -62,7 +62,7 @@ run-task-with-status() {
shift
# --quiet suppresses a warning message
/usr/bin/time \
/usr/bin/env time \
--output $out_file \
--format '%x %e' \
-- "$@" || true # suppress failure
View
@@ -37,7 +37,7 @@ readonly REF_SHELLS=($DASH $BASH $MKSH)
install-shells() {
sudo apt-get install busybox-static mksh zsh
mkdir -p _tmp/shells
ln -s -f --verbose /bin/busybox $BUSYBOX_ASH
ln -s -f --verbose "$(which busybox)" $BUSYBOX_ASH
}
# TODO: Maybe do this before running all tests.

0 comments on commit ec7ca9d

Please sign in to comment.