##// END OF EJS Templates
test: Add tests for webdir symlinks and walkrepos.
Eric Hopper -
r6341:63bdfcc3 default
parent child Browse files
Show More
@@ -0,0 +1,49 b''
1 #!/bin/sh
2 # Tests whether or not hgwebdir properly handles various symlink topologies.
3
4 "$TESTDIR/hghave" symlink || exit 80
5
6 hg init a
7 echo a > a/a
8 hg --cwd a ci -Ama -d'1 0'
9
10 mkdir webdir
11 cd webdir
12
13 hg init b
14 echo b > b/b
15 hg --cwd b ci -Amb -d'2 0'
16
17 hg init c
18 echo c > c/c
19 hg --cwd c ci -Amc -d'3 0'
20
21 ln -s ../a al
22 ln -s ../webdir circle
23
24 root=`pwd`
25
26 cd ..
27
28 cat > collections.conf <<EOF
29 [collections]
30 $root=$root
31 EOF
32
33 hg serve -p $HGPORT -d --pid-file=hg.pid --webdir-conf collections.conf \
34 -A access-collections.log -E error-collections.log
35 cat hg.pid >> $DAEMON_PIDS
36
37 echo % should succeed
38 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?style=raw'
39 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/al/file/tip/a?style=raw'
40 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/b/file/tip/b?style=raw'
41 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/c/file/tip/c?style=raw'
42
43 echo % should fail
44 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/al/file/tip/a?style=raw'
45 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/b/file/tip/a?style=raw'
46 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/circle/c/file/tip/a?style=raw'
47
48 echo % collections errors
49 cat error-collections.log
@@ -0,0 +1,34 b''
1 adding a
2 adding b
3 adding c
4 % should succeed
5 200 Script output follows
6
7
8 /al/
9 /b/
10 /c/
11
12 200 Script output follows
13
14 a
15 200 Script output follows
16
17 b
18 200 Script output follows
19
20 c
21 % should fail
22 404 Not Found
23
24
25 error: repository circle not found
26 404 Not Found
27
28
29 error: repository circle not found
30 404 Not Found
31
32
33 error: repository circle not found
34 % collections errors
@@ -0,0 +1,53 b''
1 import os
2 import os.path
3 from mercurial import hg, ui
4 from mercurial.util import walkrepos, set, frozenset
5 from os import mkdir, chdir
6 from os.path import join as pjoin
7
8 u = ui.ui()
9 sym = hasattr(os, 'symlink') and hasattr(os.path, 'samestat')
10
11 hg.repository(u, 'top1', create=1)
12 mkdir('subdir')
13 chdir('subdir')
14 hg.repository(u, 'sub1', create=1)
15 mkdir('subsubdir')
16 chdir('subsubdir')
17 hg.repository(u, 'subsub1', create=1)
18 chdir(os.path.pardir)
19 if sym:
20 os.symlink(os.path.pardir, 'circle')
21 os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1')
22
23 def runtest():
24 reposet = frozenset(walkrepos('.', followsym=True))
25 if sym and (len(reposet) != 3):
26 print "reposet = %r" % (reposet,)
27 raise SystemExit(1, "Found %d repositories when I should have found 3" % (len(reposet),))
28 if (not sym) and (len(reposet) != 2):
29 print "reposet = %r" % (reposet,)
30 raise SystemExit(1, "Found %d repositories when I should have found 2" % (len(reposet),))
31 sub1set = frozenset((pjoin('.', 'sub1'),
32 pjoin('.', 'circle', 'subdir', 'sub1')))
33 if len(sub1set & reposet) != 1:
34 print "sub1set = %r" % (sub1set,)
35 print "reposet = %r" % (reposet,)
36 raise SystemExit(1, "sub1set and reposet should have exactly one path in common.")
37 sub2set = frozenset((pjoin('.', 'subsub1'),
38 pjoin('.', 'subsubdir', 'subsub1')))
39 if len(sub2set & reposet) != 1:
40 print "sub2set = %r" % (sub2set,)
41 print "reposet = %r" % (reposet,)
42 raise SystemExit(1, "sub1set and reposet should have exactly one path in common.")
43 sub3 = pjoin('.', 'circle', 'top1')
44 if sym and not (sub3 in reposet):
45 print "reposet = %r" % (reposet,)
46 raise SystemExit(1, "Symbolic links are supported and %s is not in reposet" % (sub3,))
47
48 runtest()
49 if sym:
50 # Simulate not having symlinks.
51 del os.path.samestat
52 sym = False
53 runtest()
General Comments 0
You need to be logged in to leave comments. Login now