Skip to content

Commit

Permalink
test: Add a simpler way to run an individual test in integration mode
Browse files Browse the repository at this point in the history
Aim to treat the scripts in the docker directory as machinery that
doesn't need to be unnecessarily exposed to contributors.
  • Loading branch information
CyberShadow committed Dec 23, 2021
1 parent 93dbcff commit eb22011
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ For details, see
[test/t/mocks/](https://github.com/CyberShadow/aconfmgr/tree/master/test/t/mocks),
which contain the implementation for mocked commands.


Integration mode
----------------

In the "integration" mode, the test suite is executed inside a Docker container containing a minimal installation of Arch Linux.
The test suite will create the container during execution.

To run a single test in integration mode, run `../docker/run-test.sh ./t-test_file_name_here.sh`.
To run a single test in integration mode, run `./t-test_file_name_here.sh -i`.
The Docker service needs to be running and accessible by the current user.

For details, see the [test/docker](https://github.com/CyberShadow/aconfmgr/tree/master/test/docker) directory.
Expand Down
19 changes: 19 additions & 0 deletions test/t/lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@

source ./lib-init.bash

for arg in "$@"
do
if [[ "$arg" == -i ]]
then
if ((${ACONFMGR_INTEGRATION:-0}))
then
printf 'Already in integration mode!\n' 1>&2
exit 1
else
printf 'Re-executing in integration mode.\n' 1>&2
exec ../docker/run-test.sh "$ACONFMGR_CURRENT_TEST".sh
fi
else
printf 'Unknown command line switch: %q\n' "$arg" 1>&2
exit 1
fi
done
unset arg

source ../../src/common.bash
source ../../src/save.bash
source ../../src/apply.bash
Expand Down

0 comments on commit eb22011

Please sign in to comment.