# HG changeset patch # User Arseniy Alekseyev # Date 1663695487 14400 # Node ID b3e77d536b537d1ec1cb9c08e73e1ae8f5caf3f4 # Parent 37debd850c160abf55b7fdae049da3e1bc854d97 tests: fix the flaky test test-logtoprocess.t The main change is that we're waiting for the [touched] file to appear for 5 seconds instead of 0.1 seconds. Also, instead of implementing wait-on-file from scratch, we use the existing one from testlib/ that works well. diff -r 37debd850c16 -r b3e77d536b53 tests/test-logtoprocess.t --- a/tests/test-logtoprocess.t Tue Sep 06 15:08:52 2022 -0400 +++ b/tests/test-logtoprocess.t Tue Sep 20 13:38:07 2022 -0400 @@ -83,10 +83,9 @@ Try to confirm that pager wait on logtoprocess: -Add a script that wait on a file to appears for 5 seconds, if it sees it touch -another file or die after 5 seconds. If the scripts is awaited by hg, the -script will die after the timeout before we could touch the file and the -resulting file will not exists. If not, we will touch the file and see it. +Add a script that waits on a file to appear. If the script is awaited by hg, +the script will die after the timeout before we could touch the file and the +resulting file will not exist. If not, we will touch the file and see it. $ cat >> fakepager.py < import sys @@ -100,15 +99,9 @@ $ cat > $TESTTMP/wait-output.sh << EOF > #!/bin/sh - > for i in \`$TESTDIR/seq.py 50\`; do - > if [ -f "$TESTTMP/wait-for-touched" ]; - > then - > touch "$TESTTMP/touched"; - > break; - > else - > sleep 0.1; - > fi - > done + > set -eu + > "$RUNTESTDIR/testlib/wait-on-file" 10 "$TESTTMP/wait-for-touched" + > touch "$TESTTMP/touched" > EOF $ chmod +x $TESTTMP/wait-output.sh @@ -124,6 +117,6 @@ $ hg version -q --pager=always Mercurial Distributed SCM (version *) (glob) $ touch $TESTTMP/wait-for-touched - $ sleep 0.2 + $ "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/touched" $ test -f $TESTTMP/touched && echo "SUCCESS Pager is not waiting on ltp" || echo "FAIL Pager is waiting on ltp" SUCCESS Pager is not waiting on ltp