Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
PR #556 from me: remove Bats submodule and work around Bats bug (closes
Browse files Browse the repository at this point in the history
#552, closes #553)
  • Loading branch information
reidpr authored Sep 30, 2019
1 parent 749523e commit 0a2c810
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 71 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/sstephenson/bats.git
ignore = untracked
21 changes: 4 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ bin/version.h: VERSION.full
bin/version.sh: VERSION.full
echo "version () { echo 1>&2 '$$(cat $<)'; }" > $@

# These targets provide tarballs of HEAD (not the Git working directory) that
# are self-contained, including the source code as well as the man pages
# (both) and Bats (export-bats). To use them in an unclean working directory,
# set $CH_UNCLEAN_EXPORT_OK to non-empty.
# This target provides tarballs of HEAD (not the Git working directory) that
# are self-contained, including the source code as well as the man pages. To
# use them in an unclean working directory, set $CH_UNCLEAN_EXPORT_OK to
# non-empty.
#
# You must "cd doc-src && make" before they will work. The targets depend on
# the man pages but don't know how to build them.
Expand All @@ -66,19 +66,6 @@ export: main.tar
mv main.tar.gz charliecloud-$$(cat VERSION.full).tar.gz
ls -lh charliecloud-$$(cat VERSION.full).tar.gz

.PHONY: export-bats
export-bats: main.tar
test -d .git -a -f test/bats/.git # need recursive Git checkout
cd test/bats && \
git archive HEAD \
--prefix=charliecloud-$$(cat ../../VERSION.full)/test/bats/ \
-o ../../bats.tar
tar Af main.tar bats.tar
gzip -9 main.tar
mv main.tar.gz charliecloud-$$(cat VERSION.full).tar.gz
rm bats.tar
ls -lh charliecloud-$$(cat VERSION.full).tar.gz

# PREFIX is the prefix expected at runtime (usually /usr or /usr/local for
# system-wide installations).
# More: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
Expand Down
19 changes: 3 additions & 16 deletions doc-src/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ Test suite

To run the test suite, you also need:

* `Bats <https://github.com/sstephenson/bats>`_ 0.4.0
* `Bats <https://github.com/sstephenson/bats>`_ 0.4.0 (`Bats-core
<https://github.com/bats-core/bats-core>`_, a newer fork of Bats, is
untested)
* Bash 4.1+, for Bats and to make programming the tests tractable
* Python 2.7 or 3.4+, for building some of the tests
* Wget, to download stuff for some of the test images
Expand All @@ -153,21 +155,6 @@ Image building software tested, with varying levels of thoroughness:
* `skopeo <https://github.com/containers/skopeo>`_ and
`umoci <https://github.com/openSUSE/umoci>`_

Bats can be installed at the system level or embedded in the Charliecloud
source code. If it's in both places, the latter is used.

To embed Bats, either:

* Download Charliecloud using :code:`git clone --recursive`, which will check
out Bats as a submodule in :code:`test/bats`.

* Unpack the Bats zip file or tarball in :code:`test/bats`.

To check an embedded Bats::

$ test/bats/bin/bats --version
Bats 0.4.0


Package manager install
=======================
Expand Down
15 changes: 0 additions & 15 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ images_eg := $(sort $(wildcard ../examples/*/*/Build)) \
images := $(images_ch) $(images_eg)
sotests := check-no-icc sotest/bin/sotest sotest/lib/libsotest.so.1.0

# Favor embedded Bats, if installed, over system Bats.
export PATH := $(CURDIR)/bats/bin:$(PATH)

# Used by "make all" at top level to build these files for "make install".
.PHONY: all
all: build_auto.bats run_auto.bats $(sotests)
Expand Down Expand Up @@ -130,15 +127,3 @@ install: all
ln -sf ./libsotest.so.1.0 $(TEST)/sotest/libsotest.so.1
install -pm 755 -t $(TEST)/sotest/bin sotest/bin/sotest
install -pm 755 -t $(TEST)/sotest/lib sotest/lib/libsotest.so.1.0
# Bats (if embedded)
if [ -d test/bats/bin ]; then \
install -d $(TEST)/bats && \
install -pm 644 -t $(TEST)/bats bats/CONDUCT.md \
bats/LICENSE \
bats/README.md && \
install -d $(TEST)/bats/libexec && \
install -pm 755 -t $(TEST)/bats/libexec bats/libexec/* && \
install -d $(TEST)/bats/bin && \
ln -sf ../libexec/bats $(TEST)/bats/bin/bats && \
ln -sf bats/bin/bats $(TEST)/bats; \
fi
1 change: 0 additions & 1 deletion test/bats
Submodule bats deleted from 036081
9 changes: 9 additions & 0 deletions test/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ prerequisites_ok () {
fi
}

# Wrapper for Bats run() to work around Bats bug #89 by saving/restoring $IFS.
# See issues #552 and #555 and https://stackoverflow.com/a/32425874.
eval bats_"$(declare -f run)"
run () {
local ifs_old="$IFS"
bats_run "$@"
IFS="$ifs_old"
}

need_squashfs () {
( command -v mksquashfs >/dev/null 2>&1 ) || skip "no squashfs-tools found"
( command -v squashfuse >/dev/null 2>&1 ) || skip "no squashfuse found"
Expand Down
7 changes: 3 additions & 4 deletions test/grep
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# the exclusions manually each time.
#
# grep(1) has an --exclude-dir option, but I can't get it to work with rooted
# directories, e.g., test/bats vs bats anywhere in the tree, so we use find(1)
# instead. You may hear complaints about how find is too slow for this, but
# the project is small enough we don't care.
# directories, e.g., doc-src/_build vs _build anywhere in the tree, so we use
# find(1) instead. You may hear complaints about how find is too slow for
# this, but the project is small enough we don't care.

cd "$(dirname "$0")"/..

Expand All @@ -18,7 +18,6 @@ find . \( -path ./.git \
-o -path ./doc \
-o -path ./doc-src/_build \
-o -path ./man \
-o -path ./test/bats \
\) -prune \
-o -type f \
-exec grep --color=auto -Hn "$@" {} \;
3 changes: 3 additions & 0 deletions test/travis-install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ set -ex
# Make /usr/local/src writeable for everyone.
sudo chmod 1777 /usr/local/src

# Remove Travis Bats. We need buggy version provided by Ubuntu (issue #552).
sudo rm /usr/local/bin/bats

# Install conditional packages.
if [[ -z "$MINIMAL_DEPS" ]]; then
sudo apt-get install pigz pv skopeo squashfuse
Expand Down
13 changes: 5 additions & 8 deletions test/travis.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@ case $TARBALL in
tar xf charliecloud-*.tar.gz
cd charliecloud-*
;;
export-bats)
(cd doc-src && make)
make export-bats
mv charliecloud-*.tar.gz "$PREFIX"
cd "$PREFIX"
tar xf charliecloud-*.tar.gz
cd charliecloud-*
;;
archive)
# The Travis image already has Bats installed.
git archive HEAD --prefix=charliecloud/ -o "$PREFIX/charliecloud.tar"
cd "$PREFIX"
tar xf charliecloud.tar
cd charliecloud
;;
'')
;;
*)
false
;;
esac

make
Expand Down
12 changes: 6 additions & 6 deletions test/travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ compiler: gcc
# it up in parallel. It would be nice if "make test-build" could be done
# serially before splitting into parallel jobs.
#
# TARBALL= # build in Git checkout & use embedded Bats
# TARBALL=archive # build from "git archive" tarball & use system Bats
# TARBALL=export # build from "make export" tarball & use system Bats
# TARBALL=export-bats # build from "make export" tarball & use embedded Bats
# TARBALL= # build in Git checkout
# TARBALL=archive # build from "git archive" tarball
# TARBALL=export # build from "make export" tarball
# INSTALL= # run from build directory
# INSTALL=yes # make install to /usr/local, run that one
#
Expand Down Expand Up @@ -72,12 +71,12 @@ jobs:
env: CH_BUILDER=buildah TARBALL=export INSTALL=yes
- <<: *stage_install
env: CH_BUILDER=buildah-runc TARBALL=export INSTALL=yes
- <<: *stage_install
env: CH_BUILDER=buildah-setuid TARBALL=export INSTALL=yes
- <<: *stage_install
env: CH_BUILDER=ch-grow TARBALL=export INSTALL=yes
- <<: *stage_install
env: CH_BUILDER=docker TARBALL=export INSTALL=yes
- <<: *stage_install
env: CH_BUILDER=docker TARBALL=export-bats INSTALL=yes

- <<: *stage_misc
env: CH_BUILDER=buildah MINIMAL_DEPS=yes
Expand All @@ -95,6 +94,7 @@ addons:
sources:
- sourceline: 'ppa:projectatomic/ppa'
packages:
- bats
- python3-pip
- python3-setuptools

Expand Down

0 comments on commit 0a2c810

Please sign in to comment.