tests/test-bad-pull.t
author Matt Mackall <mpm@selenic.com>
Sun, 01 Apr 2012 14:23:55 -0500
branchstable
changeset 16334 b9bd95e61b49
parent 16296 4343d5226149
child 16341 91eec29dd7de
permissions -rw-r--r--
tests: fix shutdown race in test-bad-pull
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15446
c5c9ca3719f9 tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 12376
diff changeset
     1
  $ "$TESTDIR/hghave" serve || exit 80
c5c9ca3719f9 tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 12376
diff changeset
     2
11859
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
     3
  $ hg clone http://localhost:$HGPORT/ copy
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
     4
  abort: error: Connection refused
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11859
diff changeset
     5
  [255]
395
fbe8834923c5 commands: report http exceptions nicely
mpm@selenic.com
parents:
diff changeset
     6
15515
21766d5531cb tests: remove hacks for testing if file or directory exists
Mads Kiilerich <mads@kiilerich.com>
parents: 15446
diff changeset
     7
  $ test -d copy
21766d5531cb tests: remove hacks for testing if file or directory exists
Mads Kiilerich <mads@kiilerich.com>
parents: 15446
diff changeset
     8
  [1]
395
fbe8834923c5 commands: report http exceptions nicely
mpm@selenic.com
parents:
diff changeset
     9
11859
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    10
  $ cat > dumb.py <<EOF
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    11
  > import BaseHTTPServer, SimpleHTTPServer, os, signal
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    12
  > def run(server_class=BaseHTTPServer.HTTPServer,
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    13
  >         handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler):
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    14
  >     server_address = ('localhost', int(os.environ['HGPORT']))
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    15
  >     httpd = server_class(server_address, handler_class)
16334
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    16
  >     open("listening", "w")
16296
4343d5226149 tests: eliminate daemon race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 15515
diff changeset
    17
  >     httpd.handle_request()
11859
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    18
  > run()
f48178034569 tests: unify test-bad-pull
Martin Geisler <mg@lazybytes.net>
parents: 10154
diff changeset
    19
  > EOF
395
fbe8834923c5 commands: report http exceptions nicely
mpm@selenic.com
parents:
diff changeset
    20
16334
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    21
  $ python dumb.py 2> log &
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    22
  $ P=$!
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    23
  $ while [ ! -f listening ]; do true; done
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    24
  $ hg clone http://localhost:$HGPORT/foo copy2
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    25
  abort: HTTP Error 404: * (glob)
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    26
  [255]
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    27
  $ wait $P
b9bd95e61b49 tests: fix shutdown race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 16296
diff changeset
    28
  $ cat log
16296
4343d5226149 tests: eliminate daemon race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 15515
diff changeset
    29
  localhost - - [*] code 404, message File not found (glob)
4343d5226149 tests: eliminate daemon race in test-bad-pull
Matt Mackall <mpm@selenic.com>
parents: 15515
diff changeset
    30
  localhost - - [*] "GET /foo?cmd=capabilities HTTP/1.1" 404 - (glob)