tests: Fix race condition in profile locking test.

Previously, there was a possibility that "guix install emacs" would grab
the lock before "guix package -m $module_dir/manifest.scm".  When that
happened, the test would start building Emacs and all its dependencies,
which could take a while and some disk space.

This is a followup to b1fb663404.

* tests/guix-package.sh: In profile locking test, emit
"$module_dir/ready" from the manifest and wait for it to exist before
running "guix install emacs".
This commit is contained in:
Ludovic Courtès 2019-11-29 15:31:04 +01:00
parent 3f8e890d91
commit dac7928d50
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 3 additions and 1 deletions

View File

@ -468,8 +468,10 @@ guix package --list-profiles | grep '\.guix-profile'
# Make sure we can properly lock a profile.
mkdir "$module_dir"
echo '(sleep 60)' > "$module_dir/manifest.scm"
echo "(open-output-file \"$module_dir/ready\") (sleep 60)" \
> "$module_dir/manifest.scm"
guix package -m "$module_dir/manifest.scm" -p "$module_dir/profile" &
pid=$!
while [ ! -f "$module_dir/ready" ] ; do sleep 0.5 ; done
if guix install emacs -p "$module_dir/profile"; then kill $pid; false; else true; fi
kill $pid