tests/_exc-util.sh
author Matt Harbison <matt_harbison@yahoo.com>
Thu, 05 Mar 2015 20:02:07 -0500
branchstable
changeset 1209 fa35aeb64d32
parent 1185 cc3e68120185
child 1290 8aa9a21156fe
permissions -rwxr-xr-x
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing I've been running into a crash when pushing from my hg repo in a Fedora 16 VM to Win7 running 'hg serve', even with extensions disabled on both sides: ../hg push -r . pc pushing to http://192.168.1.4:8000/ searching for changes no changes found pushing 2 obsolescence markers (263 bytes) ** unknown exception encountered, please report by visiting ... File "hg-evolve/hgext/evolve.py", line 2482, in _pushobsolete remote.evoext_pushobsmarkers_0(obsdata) File "hg-evolve/hgext/evolve.py", line 2522, in httpclient_pushobsmarkers ret, output = self._call('evoext_pushobsmarkers_0', data=obsfile) ValueError: too many values to unpack I'm not sure how this repo differs from the one in the test suite, so I'm not sure how to craft a test for this. The failure occurs even when there _are_ csets to push. There was no crash if no obsolete markers needed to be pushed. At any rate, this code was stolen from httppeer._callpush(), where it calls self._call(). The socket exception handling wasn't necessary to fix the crash, but the calling code might as well be duplicated in its entirety. A successful push with this patch looks like this. Note the final line is _not_ in the output of the http push in test-simple4server.t: ../hg push -r . pc pushing to http://192.168.1.4:8000/ searching for changes remote has heads on branch 'default' that are not known locally: 3af110194a0c 56000e3ae44d 57ac6e51d290 7da4355c21b8 and 8 others remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 0 changes to 1 files (+1 heads) pushing 4 obsolescence markers (525 bytes) remote: 2 obsolescence markers added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
829
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     1
#!/bin/sh
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     2
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     3
cat >> $HGRCPATH <<EOF
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     4
[web]
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     5
push_ssl = false
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     6
allow_push = *
1060
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
     7
829
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     8
[ui]
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
     9
logtemplate ="{node|short} ({phase}): {desc}\n"
1060
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
    10
829
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    11
[phases]
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    12
publish=False
1060
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
    13
1035
59bc29c84ce0 evolve: hide the OBSEXC message behind a config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1001
diff changeset
    14
[experimental]
1088
528c066cd51c drop the debug output
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1060
diff changeset
    15
verbose-obsolescence-exchange=false
1089
cdd22a5e5ef1 enable bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1088
diff changeset
    16
bundle2-exp=true
1060
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
    17
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
    18
[alias]
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
    19
debugobsolete=debugobsolete -d '0 0'
f6e0cfca1bf0 test: work around a bug in debugobsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1035
diff changeset
    20
829
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    21
[extensions]
848
001f8508910a exchange: add test case for D.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 832
diff changeset
    22
hgext.strip=
829
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    23
EOF
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    24
echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    25
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    26
mkcommit() {
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    27
   echo "$1" > "$1"
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    28
   hg add "$1"
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    29
   hg ci -m "$1"
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    30
}
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    31
getid() {
1001
f7f4a1fac6c0 test: use `hg log` in the `getid` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 905
diff changeset
    32
   hg log --hidden --template '{node}\n' --rev "$1"
829
0943f327e2fb exchance: add a common setup script for all test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
    33
}
830
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    34
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    35
setuprepos() {
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    36
    echo creating test repo for test case $1
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    37
    mkdir $1
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    38
    cd $1
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    39
    echo - pulldest
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    40
    hg init pushdest
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    41
    cd pushdest
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    42
    mkcommit O
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    43
    hg phase --public .
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    44
    cd ..
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    45
    echo - main
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    46
    hg clone -q pushdest main
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    47
    echo - pushdest
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    48
    hg clone -q main pulldest
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    49
    echo 'cd into `main` and proceed with env setup'
f3b3a09ba312 exchange: have a function doing all the common initial setup
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 829
diff changeset
    50
}
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    51
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    52
dotest() {
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    53
# dotest TESTNAME [TARGETNODE]
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    54
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    55
    testcase=$1
832
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    56
    shift
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    57
    target="$1"
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    58
    if [ $# -gt 0 ]; then
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    59
        shift
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    60
    fi
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    61
    targetnode=""
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    62
    desccall=""
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    63
    cd $testcase
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    64
    echo "## Running testcase $testcase"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    65
    if [ -n "$target" ]; then
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    66
        desccall="desc("\'"$target"\'")"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    67
        targetnode="`hg -R main id -qr \"$desccall\"`"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    68
        echo "# testing echange of \"$target\" ($targetnode)"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    69
    fi
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    70
    echo "## initial state"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    71
    echo "# obstore: main"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
    72
    hg -R main     debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    73
    echo "# obstore: pushdest"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
    74
    hg -R pushdest debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    75
    echo "# obstore: pulldest"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
    76
    hg -R pulldest debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    77
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    78
    if [ -n "$target" ]; then
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    79
        echo "## pushing \"$target\"" from main to pushdest
832
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    80
        hg -R main push -r "$desccall" $@ pushdest
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    81
    else
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    82
        echo "## pushing from main to pushdest"
832
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    83
        hg -R main push pushdest $@
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    84
    fi
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    85
    echo "## post push state"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    86
    echo "# obstore: main"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
    87
    hg -R main     debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    88
    echo "# obstore: pushdest"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
    89
    hg -R pushdest debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    90
    echo "# obstore: pulldest"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
    91
    hg -R pulldest debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    92
    if [ -n "$target" ]; then
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    93
        echo "## pulling \"$targetnode\"" from main into pulldest
832
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    94
        hg -R pulldest pull -r $targetnode $@ main
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    95
    else
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    96
        echo "## pulling from main into pulldest"
832
46e81a5d2d94 exchange: add test case for A.3
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 831
diff changeset
    97
        hg -R pulldest pull main $@
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    98
    fi
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
    99
    echo "## post pull state"
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   100
    echo "# obstore: main"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
   101
    hg -R main     debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   102
    echo "# obstore: pushdest"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
   103
    hg -R pushdest debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   104
    echo "# obstore: pulldest"
905
b177fde040dd exchange: use fixed order for obstore content
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 848
diff changeset
   105
    hg -R pulldest debugobsolete | sort
831
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   106
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   107
    cd ..
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   108
a6af6919888d exchange: automate the testing process too
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 830
diff changeset
   109
}