Permalink
Browse files

A script to build known versions of all shells we test against.

Right now they are the versions that come with Ubuntu 16.04.

test/spec.sh: If possible, use these hermetic shell binaries for spec
tests.

Addresses issue #42.

I'm not sure why, but I had to adjust two tests.

glob.test.sh:
  Upstream dash 0.5.8 also has the same bug as mksh.

  I'm not sure why the Ubuntu package, which is marked 0.5.8, doesn't
  have it.  Maybe they ported a patch over?

quote.test.sh:
  hermetic ash doesn't have this bug for some reason.

Also: the regex test is currently failing for ZSH because we're not
building with regex support.  To be fixed.
  • Loading branch information...
Andy Chu
Andy Chu committed Jul 3, 2018
1 parent 5fc5f8a commit 5151cf83828b72f04a76e6782ba1a02e6aed94b7
Showing with 87 additions and 9 deletions.
  1. +2 −1 spec/glob.test.sh
  2. +0 −3 spec/quote.test.sh
  3. +65 −0 test/spec-bin.sh
  4. +20 −5 test/spec.sh
View
@@ -199,6 +199,7 @@ echo [[z] []z] # also accepted
## END
#### Glob of negated unescaped [[] and []]
# osh does this "correctly" because it defers to libc!
touch $TMP/_G
cd $TMP
echo _[^\[z] _[^\]z] # the right way to do it
@@ -207,7 +208,7 @@ echo _[^[z] _[^]z] # also accepted
_G _G
_G _G
## END
## BUG mksh STDOUT:
## BUG dash/mksh STDOUT:
_[^[z] _[^]z]
_[^[z] _[^]z]
## END
View
@@ -175,9 +175,6 @@ echo -n $'\001' $'\377' | od -A n -c | sed 's/ \+/ /g'
## N-I dash STDOUT:
$ 001 $ 377
## END
## BUG ash STDOUT:
001 0O7
## END
#### $'' octal escapes with fewer than 3 chars
echo $'\1 \11 \11 \111' | od -A n -c | sed 's/ \+/ /g'
View
@@ -0,0 +1,65 @@
#!/bin/bash
#
# Build binaries for the spec tests.
#
# Usage:
# ./spec-bin.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
readonly DIR=_tmp/spec-bin
download() {
mkdir -p $DIR
wget --no-clobber --directory $DIR \
https://www.oilshell.org/blob/spec-bin/bash-4.3.tar.gz \
https://www.oilshell.org/blob/spec-bin/busybox-1.22.0.tar.bz2 \
https://www.oilshell.org/blob/spec-bin/dash-0.5.8.tar.gz \
https://www.oilshell.org/blob/spec-bin/mksh-R52c.tgz \
https://www.oilshell.org/blob/spec-bin/zsh-5.1.1.tar.xz
}
extract-all() {
pushd $DIR
for archive in *.tar.* *.tgz; do
echo $archive
tar --extract --file $archive
done
mv -v mksh mksh-R52c # so it doesn't collide
popd
}
build-all() {
# bash/dash/zsh: ./configure; make
# mksh: sh Build.sh
# busybox: make defconfig (default config); make
pushd $DIR
# TODO: Are they all different?
popd
}
link-all() {
pushd $DIR
ln -s -f -v bash-4.3/bash .
ln -s -f -v dash-0.5.8/src/dash .
ln -s -f -v zsh-5.1.1/Src/zsh .
ln -s -f -v mksh-R52c/mksh .
ln -s -f -v busybox-1.22.0/busybox ./ash
popd
}
test-all() {
for sh in bash dash zsh mksh ash; do
$DIR/$sh -c 'echo "Hello from $0"'
# bash and zsh depend on libtinfo, but others don't
# ash and zsh depend on libm, but others don't
# bash and zsh depend on libdl, but others don't
ldd $DIR/$sh
done
}
"$@"
View
@@ -14,11 +14,26 @@ die() {
exit 1
}
readonly DASH=$(which dash 2>/dev/null || echo /bin/sh)
readonly BASH=$(which bash)
readonly MKSH=$(which mksh)
readonly ZSH=$(which zsh)
readonly BUSYBOX_ASH=_tmp/shells/ash
# For now, fall back to the shell in $PATH.
shell-path() {
local name=$1
if test -f _tmp/spec-bin/$name; then
echo _tmp/spec-bin/$name
else
which $name
fi
}
readonly DASH=$(shell-path dash)
readonly BASH=$(shell-path bash)
readonly MKSH=$(shell-path mksh)
readonly ZSH=$(shell-path zsh)
if test -f _tmp/spec-bin/ash; then
readonly BUSYBOX_ASH=_tmp/spec-bin/ash
else
readonly BUSYBOX_ASH=_tmp/shells/ash
fi
readonly OSH_PYTHON=${OSH_PYTHON:-bin/osh}
readonly OSH_OVM=${OSH_OVM:-_bin/osh}

0 comments on commit 5151cf8

Please sign in to comment.