Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c18fdc3

Browse files
committed
Properly fix "daemon kill" on test failure
Signed-off-by: Andrew "Tianon" Page <[email protected]>
1 parent 0db6bb3 commit c18fdc3

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

project/make/test-docker-py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ DEST=$1
77
(
88
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
99

10-
dockerPy='/docker-py'
11-
[ -d "$dockerPy" ] || {
12-
dockerPy="$DEST/docker-py"
13-
git clone https://github.com/docker/docker-py.git "$dockerPy"
14-
}
10+
# we need to wrap up everything in between integration-daemon-start and
11+
# integration-daemon-stop to make sure we kill the daemon and don't hang,
12+
# even and especially on test failures
13+
didFail=
14+
if ! {
15+
dockerPy='/docker-py'
16+
[ -d "$dockerPy" ] || {
17+
dockerPy="$DEST/docker-py"
18+
git clone https://github.com/docker/docker-py.git "$dockerPy"
19+
}
1520

16-
cd "$dockerPy"
17-
export PYTHONPATH=. # import "docker" from "."
18-
python tests/integration_test.py
21+
export PYTHONPATH="$dockerPy" # import "docker" from our local docker-py
22+
python "$dockerPy/tests/integration_test.py"
23+
}; then
24+
didFail=1
25+
fi
1926

2027
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
28+
29+
[ -z "$didFail" ] # "set -e" ftw
2130
) 2>&1 | tee -a $DEST/test.log

project/make/test-integration-cli

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,22 @@ bundle_test_integration_cli() {
1111
(
1212
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
1313

14-
# pull the busybox image before running the tests
15-
sleep 2
14+
# we need to wrap up everything in between integration-daemon-start and
15+
# integration-daemon-stop to make sure we kill the daemon and don't hang,
16+
# even and especially on test failures
17+
didFail=
18+
if ! {
19+
# pull the busybox image before running the tests
20+
sleep 2
1621

17-
source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
22+
source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
1823

19-
bundle_test_integration_cli
24+
bundle_test_integration_cli
25+
}; then
26+
didFail=1
27+
fi
2028

2129
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
30+
31+
[ -z "$didFail" ] # "set -e" ftw
2232
) 2>&1 | tee -a $DEST/test.log

0 commit comments

Comments
 (0)