mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
tests/functional/repl: fix race condition
the sleep 1 is not enough in some circumstances. Switching to a fifo
helps.
(cherry picked from commit 1de951d31d
)
This commit is contained in:
parent
f8620b451b
commit
6ce0e32766
1 changed files with 25 additions and 8 deletions
|
@ -158,15 +158,32 @@ foo + baz
|
||||||
# - Modify the flake
|
# - Modify the flake
|
||||||
# - Re-eval it
|
# - Re-eval it
|
||||||
# - Check that the result has changed
|
# - Check that the result has changed
|
||||||
replResult=$( (
|
mkfifo repl_fifo
|
||||||
echo "changingThing"
|
nix repl ./flake --experimental-features 'flakes' < repl_fifo > repl_output 2>&1 &
|
||||||
sleep 1 # Leave the repl the time to eval 'foo'
|
repl_pid=$!
|
||||||
|
exec 3>repl_fifo # Open fifo for writing
|
||||||
|
echo "changingThing" >&3
|
||||||
|
for i in $(seq 1 1000); do
|
||||||
|
if grep -q "beforeChange" repl_output; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
cat repl_output
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
if [[ "$i" -eq 100 ]]; then
|
||||||
|
echo "Timed out waiting for beforeChange"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i 's/beforeChange/afterChange/' flake/flake.nix
|
sed -i 's/beforeChange/afterChange/' flake/flake.nix
|
||||||
echo ":reload"
|
|
||||||
echo "changingThing"
|
# Send reload and second command
|
||||||
) | nix repl ./flake --experimental-features 'flakes')
|
echo ":reload" >&3
|
||||||
echo "$replResult" | grepQuiet -s beforeChange
|
echo "changingThing" >&3
|
||||||
echo "$replResult" | grepQuiet -s afterChange
|
echo "exit" >&3
|
||||||
|
exec 3>&- # Close fifo
|
||||||
|
wait $repl_pid # Wait for process to finish
|
||||||
|
grep -q "afterChange" repl_output
|
||||||
|
|
||||||
# Test recursive printing and formatting
|
# Test recursive printing and formatting
|
||||||
# Normal output should print attributes in lexicographical order non-recursively
|
# Normal output should print attributes in lexicographical order non-recursively
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue