@@ -205,6 +205,8 @@ test_expect_success 'setup' '
205
205
.gitignore
206
206
expect*
207
207
actual*
208
+ flush*
209
+ trace*
208
210
EOF
209
211
210
212
git -c core.fsmonitor=false add . &&
@@ -491,4 +493,117 @@ test_expect_success 'cleanup worktrees' '
491
493
stop_daemon_delete_repo wt-base
492
494
'
493
495
496
+ # The next few tests perform arbitrary/contrived file operations and
497
+ # confirm that status is correct. That is, that the data (or lack of
498
+ # data) from fsmonitor doesn't cause incorrect results. And doesn't
499
+ # cause incorrect results when the untracked-cache is enabled.
500
+
501
+ test_lazy_prereq UNTRACKED_CACHE '
502
+ git update-index --test-untracked-cache
503
+ '
504
+
505
+ test_expect_success ' Matrix: setup for untracked-cache,fsmonitor matrix' '
506
+ test_unconfig core.fsmonitor &&
507
+ git update-index --no-fsmonitor &&
508
+ test_might_fail git fsmonitor--daemon stop
509
+ '
510
+
511
+ matrix_clean_up_repo () {
512
+ git reset --hard HEAD &&
513
+ git clean -fd
514
+ }
515
+
516
+ matrix_try () {
517
+ uc=$1 &&
518
+ fsm=$2 &&
519
+ fn=$3 &&
520
+
521
+ if test $uc = true && test $fsm = false
522
+ then
523
+ # The untracked-cache is buggy when FSMonitor is
524
+ # DISABLED, so skip the tests for this matrix
525
+ # combination.
526
+ #
527
+ # We've observed random, occasional test failures on
528
+ # Windows and MacOS when the UC is turned on and FSM
529
+ # is turned off. These are rare, but they do happen
530
+ # indicating that it is probably a race condition within
531
+ # the untracked cache itself.
532
+ #
533
+ # It usually happens when a test does F/D trickery and
534
+ # then the NEXT test fails because of extra status
535
+ # output from stale UC data from the previous test.
536
+ #
537
+ # Since FSMonitor is not involved in the error, skip
538
+ # the tests for this matrix combination.
539
+ #
540
+ return 0
541
+ fi &&
542
+
543
+ test_expect_success " Matrix[uc:$uc ][fsm:$fsm ] $fn " '
544
+ matrix_clean_up_repo &&
545
+ $fn &&
546
+ if test $uc = false && test $fsm = false
547
+ then
548
+ git status --porcelain=v1 >.git/expect.$fn
549
+ else
550
+ git status --porcelain=v1 >.git/actual.$fn &&
551
+ test_cmp .git/expect.$fn .git/actual.$fn
552
+ fi
553
+ '
554
+ }
555
+
556
+ uc_values=" false"
557
+ test_have_prereq UNTRACKED_CACHE && uc_values=" false true"
558
+ for uc_val in $uc_values
559
+ do
560
+ if test $uc_val = false
561
+ then
562
+ test_expect_success " Matrix[uc:$uc_val ] disable untracked cache" '
563
+ git config core.untrackedcache false &&
564
+ git update-index --no-untracked-cache
565
+ '
566
+ else
567
+ test_expect_success " Matrix[uc:$uc_val ] enable untracked cache" '
568
+ git config core.untrackedcache true &&
569
+ git update-index --untracked-cache
570
+ '
571
+ fi
572
+
573
+ fsm_values=" false true"
574
+ for fsm_val in $fsm_values
575
+ do
576
+ if test $fsm_val = false
577
+ then
578
+ test_expect_success " Matrix[uc:$uc_val ][fsm:$fsm_val ] disable fsmonitor" '
579
+ test_unconfig core.fsmonitor &&
580
+ git update-index --no-fsmonitor &&
581
+ test_might_fail git fsmonitor--daemon stop
582
+ '
583
+ else
584
+ test_expect_success " Matrix[uc:$uc_val ][fsm:$fsm_val ] enable fsmonitor" '
585
+ git config core.fsmonitor true &&
586
+ git fsmonitor--daemon start &&
587
+ git update-index --fsmonitor
588
+ '
589
+ fi
590
+
591
+ matrix_try $uc_val $fsm_val edit_files
592
+ matrix_try $uc_val $fsm_val delete_files
593
+ matrix_try $uc_val $fsm_val create_files
594
+ matrix_try $uc_val $fsm_val rename_files
595
+ matrix_try $uc_val $fsm_val file_to_directory
596
+ matrix_try $uc_val $fsm_val directory_to_file
597
+
598
+ if test $fsm_val = true
599
+ then
600
+ test_expect_success " Matrix[uc:$uc_val ][fsm:$fsm_val ] disable fsmonitor at end" '
601
+ test_unconfig core.fsmonitor &&
602
+ git update-index --no-fsmonitor &&
603
+ test_might_fail git fsmonitor--daemon stop
604
+ '
605
+ fi
606
+ done
607
+ done
608
+
494
609
test_done
0 commit comments