-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: script to run integration tests as {user,root} and from /{home,…
…tmp}
- Loading branch information
1 parent
afc5b78
commit 0dfe73f
Showing
3 changed files
with
164 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash -eux | ||
|
||
readonly TEST_ARGS="$@" | ||
|
||
# auto cleanup | ||
at_exit() { | ||
[ "${TMP_DIR:-}" ] && rm -Rf "${TMP_DIR}" | ||
} | ||
trap at_exit EXIT | ||
|
||
readonly TMP_DIR=$(mktemp -d /tmp/$(basename -- $0).XXXXXXXXXX) | ||
|
||
if ! pwd | grep -q '^/home/' | ||
then | ||
echo 'This script should be run from /home' >&2 | ||
exit 1 | ||
fi | ||
|
||
# | ||
# runs test in current dir | ||
# | ||
|
||
# unit tests + integration tests | ||
cargo test ${TEST_ARGS} | ||
|
||
# integration tests as root | ||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test --features as-root --test '*' ${TEST_ARGS} | ||
|
||
# | ||
# runs test in /tmp | ||
# | ||
|
||
cp -Ra . "${TMP_DIR}" | ||
pushd "${TMP_DIR}" | ||
|
||
# unit tests + integration tests | ||
cargo test --test '*' ${TEST_ARGS} | ||
|
||
# integration tests as root | ||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test --features as-root --test '*' ${TEST_ARGS} | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters