tests/compose: Use workdir in tmpdir

This way when debugging if I want to preserve the state so I can
go there and rerun command under gdb for exmaple, all I need
to do is set `env TEST_SKIP_CLEANUP=1` rather than also needing
to find a separate dir and also set `env RPMOSTREE_PRESERVE_TMPDIR=1`.

Closes: #1630
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-10-21 15:59:35 +00:00 committed by Atomic Bot
parent f1fa436c8a
commit 95c1ed3695
2 changed files with 8 additions and 2 deletions

View File

@ -63,10 +63,14 @@ EOF
}
composejson=$(pwd)/compose.json
compose_base_argv="--repo ${repobuild} --write-composejson-to ${composejson}"
compose_workdir=${test_tmpdir}/workdir
compose_base_argv="--workdir ${compose_workdir} --repo ${repobuild} --write-composejson-to ${composejson}"
runcompose() {
echo "$(date): starting compose"
rpm-ostree compose tree ${compose_base_argv} ${treefile} "$@"
# The workdir will be cleaned up (or not) with the overall test dir
rm ${compose_workdir} -rf
mkdir ${test_tmpdir}/workdir
env RPMOSTREE_PRESERVE_TMPDIR=1 rpm-ostree compose tree ${compose_base_argv} ${treefile} "$@"
commit=$(jq -r '.["ostree-commit"]' < "${composejson}")
ostree --repo=${repo} pull-local ${repobuild} "${treeref:-${commit}}"
echo "$(date): finished compose"

View File

@ -12,6 +12,8 @@ pysetjsonmember "units" '["tuned.service"]'
# Do the compose -- we call compose directly because `set -e` has no effect when
# calling functions within an if condition context
rm ${compose_workdir} -rf
mkdir ${test_tmpdir}/workdir
if rpm-ostree compose tree ${compose_base_argv} ${treefile} |& tee err.txt; then
assert_not_reached err.txt "Successfully composed with units and machineid-compat=False?"
fi