From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> The fsmonitor feature allows an external tool such as watchman to monitor the working directory. The direct test t7619-status-fsmonitor.sh provides some coverage, but it would be better to run the entire test suite with watchman enabled. This would provide more confidence that the feature is working as intended. When running the test suite in parallel with 'prove -j <N>', many repos are created and deleted in parallel. When GIT_TEST_FSMONITOR points to t/t7519/fsmonitor-watchman, this can lead to watchman tracking many different folders, overloading its watch queue. As a test script completes, we can tell watchman to stop watching the directories inside the TRASH_DIRECTORY. This is particularly important on Windows where watchman keeps an open handle on the directories it watches, preventing them from being deleted. There is currently a bug in watchman [1] where this handle still is not closed, but if that is updated then these tests can be run on Windows as well. [1] https://github.com/facebook/watchman/issues/764 Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> --- t/test-lib-functions.sh | 15 +++++++++++++++ t/test-lib.sh | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index e0b3f28d3a..ef840ce097 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1475,3 +1475,18 @@ test_set_port () { port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0})) eval $var=$port } + +test_clear_watchman () { + if test -n "$GIT_TEST_FSMONITOR" + then + watchman watch-list | + grep "$TRASH_DIRECTORY" | + sed "s/\",//g" | + sed "s/\"//g" >repo-list + + while read repo + do + watchman watch-del "$repo" + done <repo-list + fi +} diff --git a/t/test-lib.sh b/t/test-lib.sh index 30b07e310f..4114953ebc 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1081,6 +1081,10 @@ test_atexit_handler () { test_done () { GIT_EXIT_OK=t + # If watchman is being used with GIT_TEST_FSMONITOR, then + # clear all watches on directories inside the TRASH_DIRECTORY. + test_clear_watchman + # Run the atexit commands _before_ the trash directory is # removed, so the commands can access pidfiles and socket files. test_atexit_handler -- gitgitgadget