Permalink
Browse files

Fix test flakiness pointed out by Yorwba.

dash was nondeterministically failing the 'pwd -P' test.

- Every *.test.sh file gets a different $TMP directory now.
- Within each file, you can create subdirectories to avoid conflicts
between individual test cases.

Addresses issue #22.
  • Loading branch information...
Andy Chu
Andy Chu committed Jun 25, 2018
1 parent d032351 commit f1fea78fbfca196b694c83f734125bc3f1c28342
Showing with 40 additions and 20 deletions.
  1. +13 −11 spec/builtin-test.test.sh
  2. +8 −6 spec/builtins.test.sh
  3. +3 −2 test/common.sh
  4. +16 −1 test/spec.sh
View
@@ -212,17 +212,19 @@ test -w $TMP/testw_no || echo 'no'
# stdout-json: "yes\nno\n"
### -h and -L test for symlink
touch $TMP/zz
ln -s -f $TMP/zz $TMP/symlink
ln -s -f $TMP/__nonexistent_ZZ__ $TMP/dangling
test -L $TMP/zz || echo no
test -h $TMP/zz || echo no
test -f $TMP/symlink && echo is-file
test -L $TMP/symlink && echo symlink
test -h $TMP/symlink && echo symlink
test -L $TMP/dangling && echo dangling
test -h $TMP/dangling && echo dangling
test -f $TMP/dangling || echo 'dangling is not file'
tmp=$TMP/builtin-test-1
mkdir -p $tmp
touch $tmp/zz
ln -s -f $tmp/zz $tmp/symlink
ln -s -f $tmp/__nonexistent_ZZ__ $tmp/dangling
test -L $tmp/zz || echo no
test -h $tmp/zz || echo no
test -f $tmp/symlink && echo is-file
test -L $tmp/symlink && echo symlink
test -h $tmp/symlink && echo symlink
test -L $tmp/dangling && echo dangling
test -h $tmp/dangling && echo dangling
test -f $tmp/dangling || echo 'dangling is not file'
## STDOUT:
no
no
View
@@ -34,13 +34,15 @@ pwd
# stdout: /
### pwd -P
mkdir -p $TMP/symtarg
ln -s $TMP/symtarg $TMP/symlink
cd $TMP/symlink
tmp=$TMP/builtins-pwd-1
mkdir -p $tmp
mkdir -p $tmp/symtarg
ln -s $tmp/symtarg $tmp/symlink
cd $tmp/symlink
basename $(pwd -P)
cd $TMP
rmdir $TMP/symtarg
rm $TMP/symlink
cd $tmp
rmdir $tmp/symtarg
rm $tmp/symlink
# stdout: symtarg
### cd with no arguments
View
@@ -7,8 +7,9 @@ set -o nounset
set -o pipefail
set -o errexit
# TODO: Release process can use the release binary. This is like $OSH_OVM
# in benchmarks/common.sh.
# TODO: Remove/rename this. The release process might use the release binary
# instead of this dev binary. test/spec.sh already has its own scheme.
# This is analogous to $OSH_OVM in benchmarks/common.sh.
readonly OSH=${OSH:-bin/osh}
# For xargs -P in spec-runner.sh, wild-runner.sh.
View
@@ -7,6 +7,13 @@ set -o nounset
set -o pipefail
set -o errexit
# Duplicate definition since we can't source test/common.sh without clobbering
# OSH!
die() {
echo "$@" 1>&2
exit 1
}
readonly DASH=$(which dash 2>/dev/null || echo /bin/sh)
readonly BASH=$(which bash)
readonly MKSH=$(which mksh)
@@ -135,14 +142,22 @@ version-text() {
#
sh-spec() {
local test_file=$1
shift
if [[ $test_file != *.test.sh ]]; then
die "Test file should end with .test.sh"
fi
local this_dir=$(cd $(dirname $0) && pwd)
local tmp_env=$this_dir/../_tmp/spec-tmp
local tmp_env=$this_dir/../_tmp/spec-tmp/$(basename $test_file)
mkdir -p $tmp_env
test/sh_spec.py \
--tmp-env $tmp_env \
--path-env "$this_dir/../spec/bin:$PATH" \
"$test_file" \
"$@"
}

0 comments on commit f1fea78

Please sign in to comment.