##// END OF EJS Templates
test: use a more direct approach to test racy mutation...
marmoute -
r50886:3997c64e default
parent child Browse files
Show More
@@ -6,8 +6,12 b' Test situations that "should" only be re'
6 - something (that doesn't respect the lock file) writing to the .hg directory
6 - something (that doesn't respect the lock file) writing to the .hg directory
7 while we're running
7 while we're running
8
8
9 $ hg init a
9
10 $ cd a
10 Initial setup
11 -------------
12
13 $ hg init base-repo
14 $ cd base-repo
11
15
12 $ cat > "$TESTTMP_FORWARD_SLASH/waitlock_editor.sh" <<EOF
16 $ cat > "$TESTTMP_FORWARD_SLASH/waitlock_editor.sh" <<EOF
13 > [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
17 > [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
@@ -26,46 +30,63 b" this all starts, so let's make one."
26 $ echo r0 > r0
30 $ echo r0 > r0
27 $ hg commit -qAm 'r0'
31 $ hg commit -qAm 'r0'
28
32
33 $ cd ..
34 $ cp -R base-repo main-client
35 $ cp -R base-repo racing-client
36
37 $ mkdir sync
38 $ EDITOR_STARTED="$TESTTMP_FORWARD_SLASH/sync/.editor_started"
39 $ MISCHIEF_MANAGED="$TESTTMP_FORWARD_SLASH/sync/.mischief_managed"
40 $ JOBS_FINISHED="$TESTTMP_FORWARD_SLASH/sync/.jobs_finished"
41
42 Actual test
43 -----------
44
29 Start an hg commit that will take a while
45 Start an hg commit that will take a while
30 $ EDITOR_STARTED="$TESTTMP_FORWARD_SLASH/a/.editor_started"
46
31 $ MISCHIEF_MANAGED="$TESTTMP_FORWARD_SLASH/a/.mischief_managed"
47 $ cd main-client
32 $ JOBS_FINISHED="$TESTTMP_FORWARD_SLASH/a/.jobs_finished"
33
48
34 #if fail-if-detected
49 #if fail-if-detected
35 $ cat >> .hg/hgrc << EOF
50 $ cat >> $HGRCPATH << EOF
36 > [debug]
51 > [debug]
37 > revlog.verifyposition.changelog = fail
52 > revlog.verifyposition.changelog = fail
38 > EOF
53 > EOF
39 #endif
54 #endif
40
55
41 $ cat >> .hg/hgrc << EOF
42 > [ui]
43 > editor=sh $TESTTMP_FORWARD_SLASH/waitlock_editor.sh
44 > EOF
45
46 $ echo foo > foo
56 $ echo foo > foo
47 $ (unset HGEDITOR;
57 $ (
48 > WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
58 > unset HGEDITOR;
49 > WAITLOCK_FILE="${MISCHIEF_MANAGED}" \
59 > WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \
50 > hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; touch "${JOBS_FINISHED}") &
60 > WAITLOCK_FILE="${MISCHIEF_MANAGED}" \
61 > hg commit -qAm 'r1 (foo)' --edit foo \
62 > --config ui.editor="sh $TESTTMP_FORWARD_SLASH/waitlock_editor.sh" \
63 > > .foo_commit_out 2>&1 ;\
64 > touch "${JOBS_FINISHED}"
65 > ) &
51
66
52 Wait for the "editor" to actually start
67 Wait for the "editor" to actually start
53 $ sh "$RUNTESTDIR_FORWARD_SLASH/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
68 $ sh "$RUNTESTDIR_FORWARD_SLASH/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
54
69
55 $ cat >> .hg/hgrc << EOF
56 > [ui]
57 > editor=
58 > EOF
59
70
60 Break the locks, and make another commit.
71 Do a concurrent edition
61 $ hg debuglocks -LW
72 $ cd ../racing-client
73 $ touch ../pre-race
74 $ sleep 1
62 $ echo bar > bar
75 $ echo bar > bar
63 $ hg commit -qAm 'r2 (bar)' bar
76 $ hg --repository ../racing-client commit -qAm 'r2 (bar)' bar
64 $ hg debugrevlogindex -c
77 $ hg --repository ../racing-client debugrevlogindex -c
65 rev linkrev nodeid p1 p2
78 rev linkrev nodeid p1 p2
66 0 0 222799e2f90b 000000000000 000000000000
79 0 0 222799e2f90b 000000000000 000000000000
67 1 1 6f124f6007a0 222799e2f90b 000000000000
80 1 1 6f124f6007a0 222799e2f90b 000000000000
68
81
82 We simulate an network FS race by overwriting raced repo content with the new
83 content of the files changed in the racing repository
84
85 $ for x in `find . -type f -newer ../pre-race`; do
86 > cp $x ../main-client/$x
87 > done
88 $ cd ../main-client
89
69 Awaken the editor from that first commit
90 Awaken the editor from that first commit
70 $ touch "${MISCHIEF_MANAGED}"
91 $ touch "${MISCHIEF_MANAGED}"
71 And wait for it to finish
92 And wait for it to finish
General Comments 0
You need to be logged in to leave comments. Login now