Skip to content

Commit

Permalink
tests/unit/go: use su for running unit tests on 14.04
Browse files Browse the repository at this point in the history
The tests.session helper requires busctl which is not available on 14.04,
however we still want to run tests on those systems.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
  • Loading branch information
bboozzoo committed Mar 4, 2021
1 parent db4de99 commit 4866400
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions tests/unit/go/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ summary: Run project static and unit tests
# Start before anything else as it takes a long time.
priority: 1000

# tests.session requires busctl, which is not available on 14.04, but we still
# want to run the tests there at the same time, we should not run into problems
# with delayed session cleanup on this system

prepare: |
tests.session -u test prepare
if not os.query is-trusty; then
tests.session -u test prepare
fi
restore: |
tests.session -u test restore
if not os.query is-trusty; then
tests.session -u test restore
fi
rm -rf /tmp/static-unit-tests
execute: |
Expand All @@ -29,13 +37,27 @@ execute: |
skip="${skip:-} SKIP_NAKEDRET=1"
fi
tests.session -u test exec sh -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
PATH=$PATH GOPATH=/tmp/static-unit-tests \
${skip:-} \
./run-checks --static"
tests.session -u test exec sh -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
PATH=$PATH \
GOPATH=/tmp/static-unit-tests \
SKIP_COVERAGE=1 \
./run-checks --unit"
if not os.query is-trusty; then
tests.session -u test exec sh -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
PATH=$PATH GOPATH=/tmp/static-unit-tests \
${skip:-} \
./run-checks --static"
tests.session -u test exec sh -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
PATH=$PATH \
GOPATH=/tmp/static-unit-tests \
SKIP_COVERAGE=1 \
./run-checks --unit"
else
# 14.04 only
su -l -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
PATH=$PATH GOPATH=/tmp/static-unit-tests \
${skip:-} \
./run-checks --static" test
su -l -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
PATH=$PATH \
GOPATH=/tmp/static-unit-tests \
SKIP_COVERAGE=1 \
./run-checks --unit" test
fi

0 comments on commit 4866400

Please sign in to comment.