mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-05 10:40:56 +08:00

When executing “make test -jX” (with X > 1) to build and run tests in a build directory, there is a race condition between the serial_test_low_level target and the test_prep target (a dependency of serial_test_fishscript and serial_test_interactive). As far as I can tell, these events happen in a serial build scenario (“make test” with the “Unix Makefiles” CMake generator): 1. The fish_tests binary is built and executed. 2. The test_prep target (a dependency of serial_test_fishscript) cleans up test directories. 3. Tests in test.fish are executed. In a parallel build scenario, this often happens: 1. Build of the fish_tests binary is started. 2. The test_prep target cleans up test directories. 3. Build of the fish_tests binary is finished. 4. Execution of the fish_tests binary starts. 5. Execution of the fish_tests binary finishes. 6. Tests in test.fish are executed. However, if building the fish_tests binary is fast enough but not instant (e.g. when using ccache), this can happen: 1. Build of the fish_tests binary is started. 2. Build of the fish_tests binary is finished. 3. Execution of the fish_tests binary starts. 4. The test_prep target cleans up test directories. 5. fish_tests tests that depend on said test directories may, depending on timing, fail because they are wiped by test_prep. Fix this by making test_prep a dependency of serial_test_low_level so that test_prep can’t interfere with fish_tests execution.