Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t2081-parallel-checkout-collisions.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t2081-parallel-checkout-collisions.sh` 162 lines ยท 5485 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description="path collisions during parallel checkout 4 5 Parallel checkout must detect path collisions to: 6 7 1) Avoid racily writing to different paths that represent the same file on disk. 8 2) Report the colliding entries on clone. 9 10 The tests in this file exercise parallel checkout's collision detection code in 11 both these mechanics. 12 " 13 14 . ./test-lib.sh 15 . "$TEST_DIRECTORY/lib-parallel-checkout.sh" 16 17 TEST_ROOT="$PWD" 18 19 test_expect_success CASE_INSENSITIVE_FS 'setup' ' 20 empty_oid=$(git hash-object -w --stdin objs <<-EOF && 22 100644 $empty_oid FILE_X 23 100644 $empty_oid FILE_x 24 100644 $empty_oid file_X 25 100644 $empty_oid file_x 26 EOF 27 git update-index --index-info >filter.log 33 EOF 34 ' 35 36 test_workers_in_event_trace () 37 { 38 test $1 -eq $(grep ".event.:.child_start..*checkout--worker" $2 | wc -l) 39 } 40 41 test_expect_success CASE_INSENSITIVE_FS 'worker detects basename collision' ' 42 GIT_TRACE2_EVENT="$(pwd)/trace" git \ 43 -c checkout.workers=2 -c checkout.thresholdForParallelism=0 \ 44 checkout . && 45 46 test_workers_in_event_trace 2 trace && 47 collisions=$(grep -i "category.:.pcheckout.,.key.:.collision/basename.,.value.:.file_x.}" trace | wc -l) && 48 test $collisions -eq 3 49 ' 50 51 test_expect_success CASE_INSENSITIVE_FS 'worker detects dirname collision' ' 52 test_config filter.logger.smudge "\"$TEST_ROOT/logger_script\" %f" && 53 empty_oid=$(git hash-object -w --stdin objs <<-EOF && 62 100644 $empty_oid A/B 63 100644 $empty_oid A/C 64 100644 $empty_oid a 65 100644 $attr_oid .gitattributes 66 EOF 67 git rm -rf . && 68 git update-index --index-info expected.log && 77 test_cmp filter.log expected.log && 78 79 # Check that it used the right number of workers and detected the collisions 80 test_workers_in_event_trace 2 trace && 81 test_grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/B.}" trace && 82 test_grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/C.}" trace 83 ' 84 85 test_expect_success SYMLINKS,CASE_INSENSITIVE_FS 'do not follow symlinks colliding with leading dir' ' 86 empty_oid=$(git hash-object -w --stdin objs <<-EOF && 91 120000 $symlink_oid D 92 100644 $empty_oid d/x 93 100644 $empty_oid e/y 94 EOF 95 git rm -rf . && 96 git update-index --index-info stderr && 117 118 test_grep FILE_X stderr && 119 test_grep FILE_x stderr && 120 test_grep file_X stderr && 121 test_grep file_x stderr && 122 test_grep "the following paths have collided" stderr 123 ' 124 125 # This test ensures that the collision report code is correctly looking for 126 # colliding peers in the second half of the cache_entry array. This is done by 127 # defining a smudge command for the *last* array entry, which makes it 128 # non-eligible for parallel-checkout. Thus, it is checked out *first*, before 129 # spawning the workers. 130 # 131 # Note: this test doesn't work on Windows because, on this system, the 132 # collision report code uses strcmp() to find the colliding pairs when 133 # core.ignoreCase is false. And we need this setting for this test so that only 134 # 'file_x' matches the pattern of the filter attribute. But the test works on 135 # OSX, where the colliding pairs are found using inode. 136 # 137 test_expect_success CASE_INSENSITIVE_FS,!MINGW,!CYGWIN \ 138 'collision report on clone (w/ colliding peer after the detected entry)' ' 139 140 test_config_global filter.logger.smudge "\"$TEST_ROOT/logger_script\" %f" && 141 git reset --hard basename_collision && 142 echo "file_x filter=logger" >.gitattributes && 143 git add .gitattributes && 144 git commit -m "filter for file_x" && 145 146 rm -rf clone-repo && 147 set_checkout_config 2 0 && 148 test_checkout_workers 2 \ 149 git -c core.ignoreCase=false clone . clone-repo 2>stderr && 150 151 test_grep FILE_X stderr && 152 test_grep FILE_x stderr && 153 test_grep file_X stderr && 154 test_grep file_x stderr && 155 test_grep "the following paths have collided" stderr && 156 157 # Check that only "file_x" was filtered 158 echo file_x >expected.log && 159 test_cmp clone-repo/filter.log expected.log 160 ' 161 162 test_done