Skip to content

Commit f007b01

Browse files
committed
integration: improve package- and filename for junit.xml
Generate more unique names, based on architecture and test-suite name. Clean up the path to this integration test to create a useful package name. "$dir" can be either absolute (/go/src/github.com/docker/docker/integration/foo) or relative (./integration/foo). To account for both, first we strip the absolute path, then any leading periods and slashes. For the package-name, we use periods as separator instead of slashes, to be more in-line with Java package names (which is what junit.xml was originally designed for). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d2e00d6 commit f007b01

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

hack/make/.integration-test-helpers

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,27 @@ run_test_integration_suites() {
5959
for dir in ${integration_api_dirs}; do
6060
if ! (
6161
cd "$dir"
62-
echo "Running $PWD flags=${flags}"
62+
# Create a useful package name based on the tests's $dir. We need to take
63+
# into account that "$dir" can be either an absolute (/go/src/github.com/docker/docker/integration/foo)
64+
# or relative (./integration/foo) path. To account for both, first we strip
65+
# the absolute path, then remove any leading periods and slashes.
66+
pkgname="${dir}"
67+
pkgname="${pkgname#*${GOPATH}/src/${DOCKER_PKG}}"
68+
pkgname="${pkgname#*.}"
69+
pkgname="${pkgname#*\/}"
70+
71+
# Finally, we use periods as separator (instead of slashes) to be more
72+
# in line with Java package names (which is what junit.xml was designed for)
73+
pkgname="$(go env GOARCH).${pkgname//\//.}"
74+
echo "Running $PWD (${pkgname}) flags=${flags}"
6375
[ -n "$TESTDEBUG" ] && set -x
6476
# shellcheck disable=SC2086
6577
test_env gotestsum \
6678
--format=standard-verbose \
67-
--jsonfile="${ABS_DEST}/$(basename "$dir")-go-test-report.json" \
68-
--junitfile="${ABS_DEST}/$(basename "$dir")-junit-report.xml" \
79+
--jsonfile="${ABS_DEST}/${pkgname//./-}-go-test-report.json" \
80+
--junitfile="${ABS_DEST}/${pkgname//./-}-junit-report.xml" \
6981
--raw-command \
70-
-- go tool test2json -t ./test.main ${flags}
82+
-- go tool test2json -p "${pkgname}" -t ./test.main ${flags}
7183
); then exit 1; fi
7284
done
7385
}

0 commit comments

Comments
 (0)