##// END OF EJS Templates
test: use `wait-on-file` in `test-racy-mutations.t`...
marmoute -
r49834:bd752712 stable
parent child Browse files
Show More
@@ -1,101 +1,94 b''
1 1 #testcases skip-detection fail-if-detected
2 2
3 3 Test situations that "should" only be reproducible:
4 4 - on networked filesystems, or
5 5 - user using `hg debuglocks` to eliminate the lock file, or
6 6 - something (that doesn't respect the lock file) writing to the .hg directory
7 7 while we're running
8 8
9 9 $ hg init a
10 10 $ cd a
11 11
12 12 $ cat > "$TESTTMP/waitlock_editor.sh" <<EOF
13 13 > [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
14 14 > f="\${WAITLOCK_FILE}"
15 15 > start=\`date +%s\`
16 16 > timeout=5
17 > while [ \\( ! -f \$f \\) -a \\( ! -L \$f \\) ]; do
18 > now=\`date +%s\`
19 > if [ "\`expr \$now - \$start\`" -gt \$timeout ]; then
20 > echo "timeout: \$f was not created in \$timeout seconds (it is now \$(date +%s))"
21 > exit 1
22 > fi
23 > sleep 0.1
24 > done
17 > $RUNTESTDIR/testlib/wait-on-file "\$timeout" "\$f"
25 18 > if [ \$# -gt 1 ]; then
26 19 > cat "\$@"
27 20 > fi
28 21 > EOF
29 22
30 23 Things behave differently if we don't already have a 00changelog.i file when
31 24 this all starts, so let's make one.
32 25
33 26 $ echo r0 > r0
34 27 $ hg commit -qAm 'r0'
35 28
36 29 Start an hg commit that will take a while
37 30 $ EDITOR_STARTED="$(pwd)/.editor_started"
38 31 $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed"
39 32 $ JOBS_FINISHED="$(pwd)/.jobs_finished"
40 33
41 34 #if fail-if-detected
42 35 $ cat >> .hg/hgrc << EOF
43 36 > [debug]
44 37 > revlog.verifyposition.changelog = fail
45 38 > EOF
46 39 #endif
47 40
48 41 $ echo foo > foo
49 42 $ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
50 43 > WAITLOCK_FILE="${MISCHIEF_MANAGED}" \
51 44 > HGEDITOR="sh $TESTTMP/waitlock_editor.sh" \
52 45 > hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; touch "${JOBS_FINISHED}") &
53 46
54 47 Wait for the "editor" to actually start
55 48 $ WAITLOCK_FILE="${EDITOR_STARTED}" sh "$TESTTMP/waitlock_editor.sh"
56 49
57 50 Break the locks, and make another commit.
58 51 $ hg debuglocks -LW
59 52 $ echo bar > bar
60 53 $ hg commit -qAm 'r2 (bar)' bar
61 54 $ hg debugrevlogindex -c
62 55 rev linkrev nodeid p1 p2
63 56 0 0 222799e2f90b 000000000000 000000000000
64 57 1 1 6f124f6007a0 222799e2f90b 000000000000
65 58
66 59 Awaken the editor from that first commit
67 60 $ touch "${MISCHIEF_MANAGED}"
68 61 And wait for it to finish
69 62 $ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP/waitlock_editor.sh"
70 63
71 64 #if skip-detection
72 65 (Ensure there was no output)
73 66 $ cat .foo_commit_out
74 67 And observe a corrupted repository -- rev 2's linkrev is 1, which should never
75 68 happen for the changelog (the linkrev should always refer to itself).
76 69 $ hg debugrevlogindex -c
77 70 rev linkrev nodeid p1 p2
78 71 0 0 222799e2f90b 000000000000 000000000000
79 72 1 1 6f124f6007a0 222799e2f90b 000000000000
80 73 2 1 ac80e6205bb2 222799e2f90b 000000000000
81 74 #endif
82 75
83 76 #if fail-if-detected
84 77 $ cat .foo_commit_out
85 78 transaction abort!
86 79 rollback completed
87 80 note: commit message saved in .hg/last-message.txt
88 81 note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it
89 82 abort: 00changelog.i: file cursor at position 249, expected 121
90 83 And no corruption in the changelog.
91 84 $ hg debugrevlogindex -c
92 85 rev linkrev nodeid p1 p2
93 86 0 0 222799e2f90b 000000000000 000000000000
94 87 1 1 6f124f6007a0 222799e2f90b 000000000000 (missing-correct-output !)
95 88 And, because of transactions, there's none in the manifestlog either.
96 89 $ hg debugrevlogindex -m
97 90 rev linkrev nodeid p1 p2
98 91 0 0 7b7020262a56 000000000000 000000000000
99 92 1 1 ad3fe36d86d9 7b7020262a56 000000000000
100 93 #endif
101 94
General Comments 0
You need to be logged in to leave comments. Login now