##// END OF EJS Templates
tests: eliminate shutdown race and sleeps in test-serve
Matt Mackall -
r16297:1791d766 stable
parent child Browse files
Show More
@@ -1,83 +1,82
1 $ "$TESTDIR/hghave" serve || exit 80
1 $ "$TESTDIR/hghave" serve || exit 80
2
2
3 $ hgserve()
3 $ hgserve()
4 > {
4 > {
5 > hg serve -a localhost -d --pid-file=hg.pid -E errors.log -v $@ \
5 > hg serve -a localhost -d --pid-file=hg.pid -E errors.log -v $@ \
6 > | sed -e "s/:$HGPORT1\\([^0-9]\\)/:HGPORT1\1/g" \
6 > | sed -e "s/:$HGPORT1\\([^0-9]\\)/:HGPORT1\1/g" \
7 > -e "s/:$HGPORT2\\([^0-9]\\)/:HGPORT2\1/g" \
7 > -e "s/:$HGPORT2\\([^0-9]\\)/:HGPORT2\1/g" \
8 > -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
8 > -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
9 > cat hg.pid >> "$DAEMON_PIDS"
9 > cat hg.pid >> "$DAEMON_PIDS"
10 > echo % errors
10 > echo % errors
11 > cat errors.log
11 > cat errors.log
12 > sleep 1
13 > if [ "$KILLQUIETLY" = "Y" ]; then
12 > if [ "$KILLQUIETLY" = "Y" ]; then
14 > kill `cat hg.pid` 2>/dev/null
13 > kill `cat hg.pid` 2>/dev/null
15 > else
14 > else
16 > kill `cat hg.pid`
15 > kill `cat hg.pid`
17 > fi
16 > fi
18 > sleep 1
17 > while kill -0 `cat hg.pid` 2>/dev/null; do true; done
19 > }
18 > }
20
19
21 $ hg init test
20 $ hg init test
22 $ cd test
21 $ cd test
23 $ echo '[web]' > .hg/hgrc
22 $ echo '[web]' > .hg/hgrc
24 $ echo 'accesslog = access.log' >> .hg/hgrc
23 $ echo 'accesslog = access.log' >> .hg/hgrc
25 $ echo "port = $HGPORT1" >> .hg/hgrc
24 $ echo "port = $HGPORT1" >> .hg/hgrc
26
25
27 Without -v
26 Without -v
28
27
29 $ hg serve -a localhost -p $HGPORT -d --pid-file=hg.pid -E errors.log
28 $ hg serve -a localhost -p $HGPORT -d --pid-file=hg.pid -E errors.log
30 $ cat hg.pid >> "$DAEMON_PIDS"
29 $ cat hg.pid >> "$DAEMON_PIDS"
31 $ if [ -f access.log ]; then
30 $ if [ -f access.log ]; then
32 $ echo 'access log created - .hg/hgrc respected'
31 $ echo 'access log created - .hg/hgrc respected'
33 access log created - .hg/hgrc respected
32 access log created - .hg/hgrc respected
34 $ fi
33 $ fi
35
34
36 errors
35 errors
37
36
38 $ cat errors.log
37 $ cat errors.log
39
38
40 With -v
39 With -v
41
40
42 $ hgserve
41 $ hgserve
43 listening at http://localhost/ (bound to 127.0.0.1:HGPORT1)
42 listening at http://localhost/ (bound to 127.0.0.1:HGPORT1)
44 % errors
43 % errors
45
44
46 With -v and -p HGPORT2
45 With -v and -p HGPORT2
47
46
48 $ hgserve -p "$HGPORT2"
47 $ hgserve -p "$HGPORT2"
49 listening at http://localhost/ (bound to 127.0.0.1:HGPORT2)
48 listening at http://localhost/ (bound to 127.0.0.1:HGPORT2)
50 % errors
49 % errors
51
50
52 With -v and -p daytime (should fail because low port)
51 With -v and -p daytime (should fail because low port)
53
52
54 $ KILLQUIETLY=Y
53 $ KILLQUIETLY=Y
55 $ hgserve -p daytime
54 $ hgserve -p daytime
56 abort: cannot start server at 'localhost:13': Permission denied
55 abort: cannot start server at 'localhost:13': Permission denied
57 abort: child process failed to start
56 abort: child process failed to start
58 % errors
57 % errors
59 $ KILLQUIETLY=N
58 $ KILLQUIETLY=N
60
59
61 With --prefix foo
60 With --prefix foo
62
61
63 $ hgserve --prefix foo
62 $ hgserve --prefix foo
64 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
63 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
65 % errors
64 % errors
66
65
67 With --prefix /foo
66 With --prefix /foo
68
67
69 $ hgserve --prefix /foo
68 $ hgserve --prefix /foo
70 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
69 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
71 % errors
70 % errors
72
71
73 With --prefix foo/
72 With --prefix foo/
74
73
75 $ hgserve --prefix foo/
74 $ hgserve --prefix foo/
76 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
75 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
77 % errors
76 % errors
78
77
79 With --prefix /foo/
78 With --prefix /foo/
80
79
81 $ hgserve --prefix /foo/
80 $ hgserve --prefix /foo/
82 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
81 listening at http://localhost/foo/ (bound to 127.0.0.1:HGPORT1)
83 % errors
82 % errors
General Comments 0
You need to be logged in to leave comments. Login now