##// END OF EJS Templates
tests: conditionalize Windows difference in test-dispatch.t...
Matt Harbison -
r41430:ed99c7b5 default
parent child Browse files
Show More
@@ -1,220 +1,221 b''
1 test command parsing and dispatch
1 test command parsing and dispatch
2
2
3 $ hg init a
3 $ hg init a
4 $ cd a
4 $ cd a
5
5
6 Redundant options used to crash (issue436):
6 Redundant options used to crash (issue436):
7 $ hg -v log -v
7 $ hg -v log -v
8 $ hg -v log -v x
8 $ hg -v log -v x
9
9
10 $ echo a > a
10 $ echo a > a
11 $ hg ci -Ama
11 $ hg ci -Ama
12 adding a
12 adding a
13
13
14 Missing arg:
14 Missing arg:
15
15
16 $ hg cat
16 $ hg cat
17 hg cat: invalid arguments
17 hg cat: invalid arguments
18 hg cat [OPTION]... FILE...
18 hg cat [OPTION]... FILE...
19
19
20 output the current or given revision of files
20 output the current or given revision of files
21
21
22 options ([+] can be repeated):
22 options ([+] can be repeated):
23
23
24 -o --output FORMAT print output to file with formatted name
24 -o --output FORMAT print output to file with formatted name
25 -r --rev REV print the given revision
25 -r --rev REV print the given revision
26 --decode apply any matching decode filter
26 --decode apply any matching decode filter
27 -I --include PATTERN [+] include names matching the given patterns
27 -I --include PATTERN [+] include names matching the given patterns
28 -X --exclude PATTERN [+] exclude names matching the given patterns
28 -X --exclude PATTERN [+] exclude names matching the given patterns
29 -T --template TEMPLATE display with template
29 -T --template TEMPLATE display with template
30
30
31 (use 'hg cat -h' to show more help)
31 (use 'hg cat -h' to show more help)
32 [255]
32 [255]
33
33
34 Missing parameter for early option:
34 Missing parameter for early option:
35
35
36 $ hg log -R 2>&1 | grep 'hg log'
36 $ hg log -R 2>&1 | grep 'hg log'
37 hg log: option -R requires argument
37 hg log: option -R requires argument
38 hg log [OPTION]... [FILE]
38 hg log [OPTION]... [FILE]
39 (use 'hg log -h' to show more help)
39 (use 'hg log -h' to show more help)
40
40
41 "--" may be an option value:
41 "--" may be an option value:
42
42
43 $ hg -R -- log
43 $ hg -R -- log
44 abort: repository -- not found!
44 abort: repository -- not found!
45 [255]
45 [255]
46 $ hg log -R --
46 $ hg log -R --
47 abort: repository -- not found!
47 abort: repository -- not found!
48 [255]
48 [255]
49 $ hg log -T --
49 $ hg log -T --
50 -- (no-eol)
50 -- (no-eol)
51 $ hg log -T -- -k nomatch
51 $ hg log -T -- -k nomatch
52
52
53 Parsing of early options should stop at "--":
53 Parsing of early options should stop at "--":
54
54
55 $ hg cat -- --config=hooks.pre-cat=false
55 $ hg cat -- --config=hooks.pre-cat=false
56 --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
56 --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b
57 [1]
57 [1]
58 $ hg cat -- --debugger
58 $ hg cat -- --debugger
59 --debugger: no such file in rev cb9a9f314b8b
59 --debugger: no such file in rev cb9a9f314b8b
60 [1]
60 [1]
61
61
62 Unparsable form of early options:
62 Unparsable form of early options:
63
63
64 $ hg cat --debugg
64 $ hg cat --debugg
65 abort: option --debugger may not be abbreviated!
65 abort: option --debugger may not be abbreviated!
66 [255]
66 [255]
67
67
68 Parsing failure of early options should be detected before executing the
68 Parsing failure of early options should be detected before executing the
69 command:
69 command:
70
70
71 $ hg log -b '--config=hooks.pre-log=false' default
71 $ hg log -b '--config=hooks.pre-log=false' default
72 abort: option --config may not be abbreviated!
72 abort: option --config may not be abbreviated!
73 [255]
73 [255]
74 $ hg log -b -R. default
74 $ hg log -b -R. default
75 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
75 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
76 [255]
76 [255]
77 $ hg log --cwd .. -b --cwd=. default
77 $ hg log --cwd .. -b --cwd=. default
78 abort: option --cwd may not be abbreviated!
78 abort: option --cwd may not be abbreviated!
79 [255]
79 [255]
80
80
81 However, we can't prevent it from loading extensions and configs:
81 However, we can't prevent it from loading extensions and configs:
82
82
83 $ cat <<EOF > bad.py
83 $ cat <<EOF > bad.py
84 > raise Exception('bad')
84 > raise Exception('bad')
85 > EOF
85 > EOF
86 $ hg log -b '--config=extensions.bad=bad.py' default
86 $ hg log -b '--config=extensions.bad=bad.py' default
87 *** failed to import extension bad from bad.py: bad
87 *** failed to import extension bad from bad.py: bad
88 abort: option --config may not be abbreviated!
88 abort: option --config may not be abbreviated!
89 [255]
89 [255]
90
90
91 $ mkdir -p badrepo/.hg
91 $ mkdir -p badrepo/.hg
92 $ echo 'invalid-syntax' > badrepo/.hg/hgrc
92 $ echo 'invalid-syntax' > badrepo/.hg/hgrc
93 $ hg log -b -Rbadrepo default
93 $ hg log -b -Rbadrepo default
94 hg: parse error at badrepo/.hg/hgrc:1: invalid-syntax
94 hg: parse error at badrepo/.hg/hgrc:1: invalid-syntax
95 [255]
95 [255]
96
96
97 $ hg log -b --cwd=inexistent default
97 $ hg log -b --cwd=inexistent default
98 abort: $ENOENT$: 'inexistent'
98 abort: $ENOENT$: 'inexistent'
99 [255]
99 [255]
100
100
101 $ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback'
101 $ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback'
102 Traceback (most recent call last):
102 Traceback (most recent call last):
103 $ hg log -b '--config=profiling.enabled=yes' 2>&1 | grep -i sample
103 $ hg log -b '--config=profiling.enabled=yes' 2>&1 | grep -i sample
104 Sample count: .*|No samples recorded\. (re)
104 Sample count: .*|No samples recorded\. (re)
105
105
106 Early options can't be specified in [aliases] and [defaults] because they are
106 Early options can't be specified in [aliases] and [defaults] because they are
107 applied before the command name is resolved:
107 applied before the command name is resolved:
108
108
109 $ hg log -b '--config=alias.log=log --config=hooks.pre-log=false'
109 $ hg log -b '--config=alias.log=log --config=hooks.pre-log=false'
110 hg log: option -b not recognized
110 hg log: option -b not recognized
111 error in definition for alias 'log': --config may only be given on the command
111 error in definition for alias 'log': --config may only be given on the command
112 line
112 line
113 [255]
113 [255]
114
114
115 $ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
115 $ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
116 abort: option --config may not be abbreviated!
116 abort: option --config may not be abbreviated!
117 [255]
117 [255]
118
118
119 Shell aliases bypass any command parsing rules but for the early one:
119 Shell aliases bypass any command parsing rules but for the early one:
120
120
121 $ hg log -b '--config=alias.log=!echo howdy'
121 $ hg log -b '--config=alias.log=!echo howdy'
122 howdy
122 howdy
123
123
124 Early options must come first if HGPLAIN=+strictflags is specified:
124 Early options must come first if HGPLAIN=+strictflags is specified:
125 (BUG: chg cherry-picks early options to pass them as a server command)
125 (BUG: chg cherry-picks early options to pass them as a server command)
126
126
127 #if no-chg
127 #if no-chg
128 $ HGPLAIN=+strictflags hg log -b --config='hooks.pre-log=false' default
128 $ HGPLAIN=+strictflags hg log -b --config='hooks.pre-log=false' default
129 abort: unknown revision '--config=hooks.pre-log=false'!
129 abort: unknown revision '--config=hooks.pre-log=false'!
130 [255]
130 [255]
131 $ HGPLAIN=+strictflags hg log -b -R. default
131 $ HGPLAIN=+strictflags hg log -b -R. default
132 abort: unknown revision '-R.'!
132 abort: unknown revision '-R.'!
133 [255]
133 [255]
134 $ HGPLAIN=+strictflags hg log -b --cwd=. default
134 $ HGPLAIN=+strictflags hg log -b --cwd=. default
135 abort: unknown revision '--cwd=.'!
135 abort: unknown revision '--cwd=.'!
136 [255]
136 [255]
137 #endif
137 #endif
138 $ HGPLAIN=+strictflags hg log -b --debugger default
138 $ HGPLAIN=+strictflags hg log -b --debugger default
139 abort: unknown revision '--debugger'!
139 abort: unknown revision '--debugger'!
140 [255]
140 [255]
141 $ HGPLAIN=+strictflags hg log -b --config='alias.log=!echo pwned' default
141 $ HGPLAIN=+strictflags hg log -b --config='alias.log=!echo pwned' default
142 abort: unknown revision '--config=alias.log=!echo pwned'!
142 abort: unknown revision '--config=alias.log=!echo pwned'!
143 [255]
143 [255]
144
144
145 $ HGPLAIN=+strictflags hg log --config='hooks.pre-log=false' -b default
145 $ HGPLAIN=+strictflags hg log --config='hooks.pre-log=false' -b default
146 abort: option --config may not be abbreviated!
146 abort: option --config may not be abbreviated!
147 [255]
147 [255]
148 $ HGPLAIN=+strictflags hg log -q --cwd=.. -b default
148 $ HGPLAIN=+strictflags hg log -q --cwd=.. -b default
149 abort: option --cwd may not be abbreviated!
149 abort: option --cwd may not be abbreviated!
150 [255]
150 [255]
151 $ HGPLAIN=+strictflags hg log -q -R . -b default
151 $ HGPLAIN=+strictflags hg log -q -R . -b default
152 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
152 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
153 [255]
153 [255]
154
154
155 $ HGPLAIN=+strictflags hg --config='hooks.pre-log=false' log -b default
155 $ HGPLAIN=+strictflags hg --config='hooks.pre-log=false' log -b default
156 abort: pre-log hook exited with status 1
156 abort: pre-log hook exited with status 1
157 [255]
157 [255]
158 $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
158 $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
159 0:cb9a9f314b8b
159 0:cb9a9f314b8b
160 $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
160 $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
161 0:cb9a9f314b8b
161 0:cb9a9f314b8b
162 $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
162 $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
163 0:cb9a9f314b8b
163 0:cb9a9f314b8b
164
164
165 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain HGPLAIN:
165 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain HGPLAIN:
166
166
167 $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
167 $ HGPLAIN= hg log --config='hooks.pre-log=false' -b default
168 abort: pre-log hook exited with status 1
168 abort: pre-log hook exited with status 1
169 [255]
169 [255]
170 $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
170 $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
171 0:cb9a9f314b8b
171 0:cb9a9f314b8b
172
172
173 [defaults]
173 [defaults]
174
174
175 $ hg cat a
175 $ hg cat a
176 a
176 a
177 $ cat >> $HGRCPATH <<EOF
177 $ cat >> $HGRCPATH <<EOF
178 > [defaults]
178 > [defaults]
179 > cat = -r null
179 > cat = -r null
180 > EOF
180 > EOF
181 $ hg cat a
181 $ hg cat a
182 a: no such file in rev 000000000000
182 a: no such file in rev 000000000000
183 [1]
183 [1]
184
184
185 $ cd "$TESTTMP"
185 $ cd "$TESTTMP"
186
186
187 OSError "No such file or directory" / "The system cannot find the path
187 OSError "No such file or directory" / "The system cannot find the path
188 specified" should include filename even when it is empty
188 specified" should include filename even when it is empty
189
189
190 $ hg -R a archive ''
190 $ hg -R a archive ''
191 abort: $ENOENT$: ''
191 abort: $ENOENT$: '' (no-windows !)
192 abort: $ENOTDIR$: '' (windows !)
192 [255]
193 [255]
193
194
194 #if no-outer-repo
195 #if no-outer-repo
195
196
196 No repo:
197 No repo:
197
198
198 $ hg cat
199 $ hg cat
199 abort: no repository found in '$TESTTMP' (.hg not found)!
200 abort: no repository found in '$TESTTMP' (.hg not found)!
200 [255]
201 [255]
201
202
202 #endif
203 #endif
203
204
204 #if rmcwd
205 #if rmcwd
205
206
206 Current directory removed:
207 Current directory removed:
207
208
208 $ mkdir $TESTTMP/repo1
209 $ mkdir $TESTTMP/repo1
209 $ cd $TESTTMP/repo1
210 $ cd $TESTTMP/repo1
210 $ rm -rf $TESTTMP/repo1
211 $ rm -rf $TESTTMP/repo1
211
212
212 The output could be one of the following and something else:
213 The output could be one of the following and something else:
213 chg: abort: failed to getcwd (errno = *) (glob)
214 chg: abort: failed to getcwd (errno = *) (glob)
214 abort: error getting current working directory: * (glob)
215 abort: error getting current working directory: * (glob)
215 sh: 0: getcwd() failed: $ENOENT$
216 sh: 0: getcwd() failed: $ENOENT$
216 Since the exact behavior depends on the shell, only check it returns non-zero.
217 Since the exact behavior depends on the shell, only check it returns non-zero.
217 $ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false
218 $ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false
218 [1]
219 [1]
219
220
220 #endif
221 #endif
General Comments 0
You need to be logged in to leave comments. Login now