On Thu, Apr 11, 2013 at 03:11:32PM -0400, Jeff King wrote: > I always get a little nervous with sleeps in the test suite, as they are > indicative that we are trying to avoid some race condition, which means > that the test can fail when the system is under load, or when a tool > like valgrind is used which drastically alters the timing (e.g., if > check-ignore takes longer than 1 second to produce its answer, we may > fail here).
Agreed, especially here where my btrfs filesystems see fit to kindly freeze my system for a few seconds many times each day :-/ > Is there a simpler way to test this? > > Like: > > # Set up a long-running "check-ignore" connected by pipes. > mkfifo in out && > (git check-ignore ... <in >out &) && > > # We cannot just "echo >in" because check-ignore > # would get EOF after echo exited; instead we open > # the descriptor in our shell, and then echo to the > # fd. We make sure to close it at the end, so that > # the subprocess does get EOF and dies properly. > exec 9>in && > test_when_finished "exec 9>&-" && > > # Now we can do interactive tests > echo >&9 one && > read response <out && > test "$response" = ... && > echo >&9 two && > read response <out && > test "$response" = ... > > Hmm. Maybe simpler wasn't the right word. :) But it avoids any sleeps or > race conditions. The shell source is strong with this one ;-) Congrats - I first tried with FIFOs (hence my other patch which moves the PIPE test prerequisite definition into the core framework - the original intention was to reuse it here) but failed to get it working. I'll re-roll using your approach. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html