Skip to content

Commit

Permalink
snapcraft.yaml: fix running hook-tests
Browse files Browse the repository at this point in the history
Only run hook tests when root otherwise the chroot to the prime
dir will not work.
  • Loading branch information
mvo5 committed Jan 14, 2019
1 parent 651cec9 commit 348a754
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions Makefile
Expand Up @@ -51,13 +51,17 @@ test:
echo "no $(TESTDIR) found, please build the tree first "; \
exit 1; \
fi
set -ex; for f in ./hook-tests/[0-9]*.test; do \
/bin/cp -a $$f $(TESTDIR)/tmp && \
if ! chroot $(TESTDIR) /tmp/$$(basename $$f); then \
exit 1; \
fi && \
rm -f $(TESTDIR)/tmp/$$(basename $$f); \
done;
if [ $$(id -u) -eq 0 ]; then \
set -ex; for f in ./hook-tests/[0-9]*.test; do \
/bin/cp -a $$f $(TESTDIR)/tmp && \
if ! chroot $(TESTDIR) /tmp/$$(basename $$f); then \
exit 1; \
fi && \
rm -f $(TESTDIR)/tmp/$$(basename $$f); \
done; \
else \
echo "Must be root to run the tests"; \
fi

# Display a report of files that are (still) present in /etc
.PHONY: etc-report
Expand Down
3 changes: 2 additions & 1 deletion hook-tests/001-extra-packages.test
Expand Up @@ -8,7 +8,8 @@

set -e

if [ "$(dpkg --print-architecture)" != "amd64" ]; then
# no dpkg in the image so we can't use `dpkg --print-architecture` here
if [ ! -d "lib/x86_64-linux-gnu" ]; then
echo "only testing on amd64 for now"
exit 0
fi
Expand Down
2 changes: 1 addition & 1 deletion snapcraft.yaml
Expand Up @@ -33,4 +33,4 @@ parts:
export PATH="$PATH:/snap/snapcraft/current/bin/scriptlet-bin"
snapcraftctl prime
# ensure build-in tests are run
(cd ${SNAPCRAFT_PART_SRC} && make test TESTDIR=${SNAPCRAFT_PRIME})
cd ${SNAPCRAFT_PART_SRC} && make test TESTDIR=${SNAPCRAFT_PRIME}

0 comments on commit 348a754

Please sign in to comment.