Show More
@@ -0,0 +1,76 b'' | |||
|
1 | #!/bin/sh | |
|
2 | ||
|
3 | "$TESTDIR/hghave" mtn || exit 80 | |
|
4 | ||
|
5 | # Monotone directory is called .monotone on *nix and monotone | |
|
6 | # on Windows. Having a variable here ease test patching. | |
|
7 | mtndir=.monotone | |
|
8 | echo "[extensions]" >> $HGRCPATH | |
|
9 | echo "convert=" >> $HGRCPATH | |
|
10 | echo 'hgext.graphlog =' >> $HGRCPATH | |
|
11 | ||
|
12 | HOME=`pwd`/do_not_use_HOME_mtn; export HOME | |
|
13 | # Windows version of monotone home | |
|
14 | APPDATA=$HOME; export APPDATA | |
|
15 | ||
|
16 | echo % tedious monotone keys configuration | |
|
17 | # The /dev/null redirection is necessary under Windows, or | |
|
18 | # it complains about home directory permissions | |
|
19 | mtn --quiet genkey test@selenic.com 1>/dev/null 2>&1 <<EOF | |
|
20 | passphrase | |
|
21 | passphrase | |
|
22 | EOF | |
|
23 | cat >> $HOME/$mtndir/monotonerc <<EOF | |
|
24 | function get_passphrase(keypair_id) | |
|
25 | return "passphrase" | |
|
26 | end | |
|
27 | EOF | |
|
28 | ||
|
29 | echo % create monotone repository | |
|
30 | mtn db init --db=repo.mtn | |
|
31 | mtn --db=repo.mtn --branch=com.selenic.test setup workingdir | |
|
32 | cd workingdir | |
|
33 | echo a > a | |
|
34 | mkdir dir | |
|
35 | echo b > dir/b | |
|
36 | python -c 'file("bin", "wb").write("a\\x00b")' | |
|
37 | echo c > c | |
|
38 | mtn add a dir/b c bin | |
|
39 | mtn ci -m initialize | |
|
40 | echo % update monotone working directory | |
|
41 | mtn mv a dir/a | |
|
42 | echo a >> dir/a | |
|
43 | echo b >> dir/b | |
|
44 | mtn drop c | |
|
45 | python -c 'file("bin", "wb").write("b\\x00c")' | |
|
46 | mtn ci -m update1 | |
|
47 | cd .. | |
|
48 | ||
|
49 | echo % convert once | |
|
50 | hg convert -s mtn repo.mtn | |
|
51 | ||
|
52 | cd workingdir | |
|
53 | echo e > e | |
|
54 | mtn add e | |
|
55 | mtn drop dir/b | |
|
56 | mtn mv bin bin2 | |
|
57 | mtn ci -m update2 | |
|
58 | cd .. | |
|
59 | ||
|
60 | echo % convert incrementally | |
|
61 | hg convert -s mtn repo.mtn | |
|
62 | ||
|
63 | glog() | |
|
64 | { | |
|
65 | hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@" | |
|
66 | } | |
|
67 | ||
|
68 | cd repo.mtn-hg | |
|
69 | hg up -C | |
|
70 | glog | |
|
71 | echo % manifest | |
|
72 | # BUG: c and dir/b should not appear here | |
|
73 | hg manifest | |
|
74 | echo % contents | |
|
75 | cat dir/a | |
|
76 |
@@ -0,0 +1,50 b'' | |||
|
1 | % tedious monotone keys configuration | |
|
2 | % create monotone repository | |
|
3 | mtn: adding a to workspace manifest | |
|
4 | mtn: adding bin to workspace manifest | |
|
5 | mtn: adding c to workspace manifest | |
|
6 | mtn: adding dir to workspace manifest | |
|
7 | mtn: adding dir/b to workspace manifest | |
|
8 | mtn: beginning commit on branch 'com.selenic.test' | |
|
9 | mtn: committed revision 803ef0bf815e35b951dbd4310acd1e45e675016e | |
|
10 | % update monotone working directory | |
|
11 | mtn: skipping dir, already accounted for in workspace | |
|
12 | mtn: renaming a to dir/a in workspace manifest | |
|
13 | mtn: dropping c from workspace manifest | |
|
14 | mtn: beginning commit on branch 'com.selenic.test' | |
|
15 | mtn: committed revision 4daf60753d6fe21a06ce5f716303fe55fd6d3a56 | |
|
16 | % convert once | |
|
17 | assuming destination repo.mtn-hg | |
|
18 | initializing destination repo.mtn-hg repository | |
|
19 | scanning source... | |
|
20 | sorting... | |
|
21 | converting... | |
|
22 | 1 initialize | |
|
23 | 0 update1 | |
|
24 | mtn: adding e to workspace manifest | |
|
25 | mtn: dropping dir/b from workspace manifest | |
|
26 | mtn: renaming bin to bin2 in workspace manifest | |
|
27 | mtn: beginning commit on branch 'com.selenic.test' | |
|
28 | mtn: committed revision 6c6977a6ef609ec80e40779f89dbd2772c96de62 | |
|
29 | % convert incrementally | |
|
30 | assuming destination repo.mtn-hg | |
|
31 | scanning source... | |
|
32 | sorting... | |
|
33 | converting... | |
|
34 | 0 update2 | |
|
35 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
36 | @ 2 "update2" files: bin bin2 e | |
|
37 | | | |
|
38 | o 1 "update1" files: a bin dir/a dir/b | |
|
39 | | | |
|
40 | o 0 "initialize" files: a bin c dir/b | |
|
41 | ||
|
42 | % manifest | |
|
43 | bin2 | |
|
44 | c | |
|
45 | dir/a | |
|
46 | dir/b | |
|
47 | e | |
|
48 | % contents | |
|
49 | a | |
|
50 | a |
@@ -1,181 +1,185 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | """Test the running system for features availability. Exit with zero |
|
3 | 3 | if all features are there, non-zero otherwise. If a feature name is |
|
4 | 4 | prefixed with "no-", the absence of feature is tested. |
|
5 | 5 | """ |
|
6 | 6 | import optparse |
|
7 | 7 | import os |
|
8 | 8 | import re |
|
9 | 9 | import sys |
|
10 | 10 | import tempfile |
|
11 | 11 | |
|
12 | 12 | tempprefix = 'hg-hghave-' |
|
13 | 13 | |
|
14 | 14 | def matchoutput(cmd, regexp, ignorestatus=False): |
|
15 | 15 | """Return True if cmd executes successfully and its output |
|
16 | 16 | is matched by the supplied regular expression. |
|
17 | 17 | """ |
|
18 | 18 | r = re.compile(regexp) |
|
19 | 19 | fh = os.popen(cmd) |
|
20 | 20 | s = fh.read() |
|
21 | 21 | ret = fh.close() |
|
22 | 22 | return (ignorestatus or ret is None) and r.search(s) |
|
23 | 23 | |
|
24 | 24 | def has_baz(): |
|
25 | 25 | return matchoutput('baz --version 2>&1', r'baz Bazaar version') |
|
26 | 26 | |
|
27 | 27 | def has_cvs(): |
|
28 | 28 | return matchoutput('cvs --version 2>&1', r'Concurrent Versions System') |
|
29 | 29 | |
|
30 | 30 | def has_cvsps(): |
|
31 | 31 | return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True) |
|
32 | 32 | |
|
33 | 33 | def has_darcs(): |
|
34 | 34 | return matchoutput('darcs', 'darcs version', True) |
|
35 | 35 | |
|
36 | def has_mtn(): | |
|
37 | return matchoutput('mtn --version', 'monotone', True) | |
|
38 | ||
|
36 | 39 | def has_eol_in_paths(): |
|
37 | 40 | try: |
|
38 | 41 | fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r') |
|
39 | 42 | os.close(fd) |
|
40 | 43 | os.remove(path) |
|
41 | 44 | return True |
|
42 | 45 | except: |
|
43 | 46 | return False |
|
44 | 47 | |
|
45 | 48 | def has_executablebit(): |
|
46 | 49 | fd, path = tempfile.mkstemp(prefix=tempprefix) |
|
47 | 50 | os.close(fd) |
|
48 | 51 | try: |
|
49 | 52 | s = os.lstat(path).st_mode |
|
50 | 53 | os.chmod(path, s | 0100) |
|
51 | 54 | return (os.lstat(path).st_mode & 0100 != 0) |
|
52 | 55 | finally: |
|
53 | 56 | os.remove(path) |
|
54 | 57 | |
|
55 | 58 | def has_fifo(): |
|
56 | 59 | return hasattr(os, "mkfifo") |
|
57 | 60 | |
|
58 | 61 | def has_hotshot(): |
|
59 | 62 | try: |
|
60 | 63 | # hotshot.stats tests hotshot and many problematic dependencies |
|
61 | 64 | # like profile. |
|
62 | 65 | import hotshot.stats |
|
63 | 66 | return True |
|
64 | 67 | except ImportError: |
|
65 | 68 | return False |
|
66 | 69 | |
|
67 | 70 | def has_lsprof(): |
|
68 | 71 | try: |
|
69 | 72 | import _lsprof |
|
70 | 73 | return True |
|
71 | 74 | except ImportError: |
|
72 | 75 | return False |
|
73 | 76 | |
|
74 | 77 | def has_git(): |
|
75 | 78 | return matchoutput('git --version 2>&1', r'^git version') |
|
76 | 79 | |
|
77 | 80 | def has_svn(): |
|
78 | 81 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
|
79 | 82 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
|
80 | 83 | |
|
81 | 84 | def has_svn_bindings(): |
|
82 | 85 | try: |
|
83 | 86 | import svn.core |
|
84 | 87 | return True |
|
85 | 88 | except ImportError: |
|
86 | 89 | return False |
|
87 | 90 | |
|
88 | 91 | def has_symlink(): |
|
89 | 92 | return hasattr(os, "symlink") |
|
90 | 93 | |
|
91 | 94 | def has_tla(): |
|
92 | 95 | return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
|
93 | 96 | |
|
94 | 97 | def has_unix_permissions(): |
|
95 | 98 | d = tempfile.mkdtemp(prefix=tempprefix, dir=".") |
|
96 | 99 | try: |
|
97 | 100 | fname = os.path.join(d, 'foo') |
|
98 | 101 | for umask in (077, 007, 022): |
|
99 | 102 | os.umask(umask) |
|
100 | 103 | f = open(fname, 'w') |
|
101 | 104 | f.close() |
|
102 | 105 | mode = os.stat(fname).st_mode |
|
103 | 106 | os.unlink(fname) |
|
104 | 107 | if mode & 0777 != ~umask & 0666: |
|
105 | 108 | return False |
|
106 | 109 | return True |
|
107 | 110 | finally: |
|
108 | 111 | os.rmdir(d) |
|
109 | 112 | |
|
110 | 113 | def has_pygments(): |
|
111 | 114 | try: |
|
112 | 115 | import pygments |
|
113 | 116 | return True |
|
114 | 117 | except ImportError: |
|
115 | 118 | return False |
|
116 | 119 | |
|
117 | 120 | checks = { |
|
118 | 121 | "baz": (has_baz, "GNU Arch baz client"), |
|
119 | 122 | "cvs": (has_cvs, "cvs client"), |
|
120 | 123 | "cvsps": (has_cvsps, "cvsps utility"), |
|
121 | 124 | "darcs": (has_darcs, "darcs client"), |
|
122 | 125 | "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"), |
|
123 | 126 | "execbit": (has_executablebit, "executable bit"), |
|
124 | 127 | "fifo": (has_fifo, "named pipes"), |
|
125 | 128 | "git": (has_git, "git command line client"), |
|
126 | 129 | "hotshot": (has_hotshot, "python hotshot module"), |
|
127 | 130 | "lsprof": (has_lsprof, "python lsprof module"), |
|
131 | "mtn": (has_mtn, "monotone client"), | |
|
128 | 132 | "svn": (has_svn, "subversion client and admin tools"), |
|
129 | 133 | "svn-bindings": (has_svn_bindings, "subversion python bindings"), |
|
130 | 134 | "symlink": (has_symlink, "symbolic links"), |
|
131 | 135 | "tla": (has_tla, "GNU Arch tla client"), |
|
132 | 136 | "unix-permissions": (has_unix_permissions, "unix-style permissions"), |
|
133 | 137 | "pygments": (has_pygments, "Pygments source highlighting library"), |
|
134 | 138 | } |
|
135 | 139 | |
|
136 | 140 | def list_features(): |
|
137 | 141 | for name, feature in checks.iteritems(): |
|
138 | 142 | desc = feature[1] |
|
139 | 143 | print name + ':', desc |
|
140 | 144 | |
|
141 | 145 | parser = optparse.OptionParser("%prog [options] [features]") |
|
142 | 146 | parser.add_option("--list-features", action="store_true", |
|
143 | 147 | help="list available features") |
|
144 | 148 | parser.add_option("-q", "--quiet", action="store_true", |
|
145 | 149 | help="check features silently") |
|
146 | 150 | |
|
147 | 151 | if __name__ == '__main__': |
|
148 | 152 | options, args = parser.parse_args() |
|
149 | 153 | if options.list_features: |
|
150 | 154 | list_features() |
|
151 | 155 | sys.exit(0) |
|
152 | 156 | |
|
153 | 157 | quiet = options.quiet |
|
154 | 158 | |
|
155 | 159 | failures = 0 |
|
156 | 160 | |
|
157 | 161 | def error(msg): |
|
158 | 162 | global failures |
|
159 | 163 | if not quiet: |
|
160 | 164 | sys.stderr.write(msg + '\n') |
|
161 | 165 | failures += 1 |
|
162 | 166 | |
|
163 | 167 | for feature in args: |
|
164 | 168 | negate = feature.startswith('no-') |
|
165 | 169 | if negate: |
|
166 | 170 | feature = feature[3:] |
|
167 | 171 | |
|
168 | 172 | if feature not in checks: |
|
169 | 173 | error('skipped: unknown feature: ' + feature) |
|
170 | 174 | continue |
|
171 | 175 | |
|
172 | 176 | check, desc = checks[feature] |
|
173 | 177 | if not negate and not check(): |
|
174 | 178 | error('skipped: missing feature: ' + desc) |
|
175 | 179 | elif negate and check(): |
|
176 | 180 | error('skipped: system supports %s' % desc) |
|
177 | 181 | |
|
178 | 182 | if failures != 0: |
|
179 | 183 | sys.exit(1) |
|
180 | 184 | |
|
181 | 185 |
General Comments 0
You need to be logged in to leave comments.
Login now