| 1 |
Test that the syntax of "unified tests" is properly processed |
| 2 |
============================================================== |
| 3 |
|
| 4 |
Simple commands: |
| 5 |
|
| 6 |
$ echo foo |
| 7 |
foo |
| 8 |
$ printf 'oh no' |
| 9 |
oh no (no-eol) |
| 10 |
$ printf 'bar\nbaz\n' | cat |
| 11 |
bar |
| 12 |
baz |
| 13 |
|
| 14 |
Multi-line command: |
| 15 |
|
| 16 |
$ foo() { |
| 17 |
> echo bar |
| 18 |
> } |
| 19 |
$ foo |
| 20 |
bar |
| 21 |
|
| 22 |
Return codes before inline python: |
| 23 |
|
| 24 |
$ sh -c 'exit 1' |
| 25 |
[1] |
| 26 |
|
| 27 |
Doctest commands: |
| 28 |
|
| 29 |
>>> print('foo') |
| 30 |
foo |
| 31 |
$ echo interleaved |
| 32 |
interleaved |
| 33 |
>>> for c in 'xyz': |
| 34 |
... print(c) |
| 35 |
x |
| 36 |
y |
| 37 |
z |
| 38 |
>>> print() |
| 39 |
|
| 40 |
>>> foo = 'global name' |
| 41 |
>>> def func(): |
| 42 |
... print(foo, 'should be visible in func()') |
| 43 |
>>> func() |
| 44 |
global name should be visible in func() |
| 45 |
>>> print('''multiline |
| 46 |
... string''') |
| 47 |
multiline |
| 48 |
string |
| 49 |
|
| 50 |
Regular expressions: |
| 51 |
|
| 52 |
$ echo foobarbaz |
| 53 |
foobar.* (re) |
| 54 |
$ echo barbazquux |
| 55 |
.*quux.* (re) |
| 56 |
|
| 57 |
Globs: |
| 58 |
|
| 59 |
$ printf '* \\foobarbaz {10}\n' |
| 60 |
\* \\fo?bar* {10} (glob) |
| 61 |
|
| 62 |
Literal match ending in " (re)": |
| 63 |
|
| 64 |
$ echo 'foo (re)' |
| 65 |
foo (re) |
| 66 |
|
| 67 |
Windows: \r\n is handled like \n and can be escaped: |
| 68 |
|
| 69 |
#if windows |
| 70 |
$ printf 'crlf\r\ncr\r\tcrlf\r\ncrlf\r\n' |
| 71 |
crlf |
| 72 |
cr\r (no-eol) (esc) |
| 73 |
\tcrlf (esc) |
| 74 |
crlf\r (esc) |
| 75 |
#endif |
| 76 |
|
| 77 |
Escapes: |
| 78 |
|
| 79 |
$ "$PYTHON" -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")' |
| 80 |
\xff (no-eol) (esc) |
| 81 |
|
| 82 |
Escapes with conditions: |
| 83 |
|
| 84 |
$ "$PYTHON" -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")' |
| 85 |
\xff (no-eol) (esc) (true !) |
| 86 |
|
| 87 |
Combining esc with other markups - and handling lines ending with \r instead of \n: |
| 88 |
|
| 89 |
$ printf 'foo/bar\r' |
| 90 |
fo?/bar\r (no-eol) (glob) (esc) |
| 91 |
#if windows |
| 92 |
$ printf 'foo\\bar\r' |
| 93 |
foo/bar\r (no-eol) (esc) |
| 94 |
#endif |
| 95 |
$ printf 'foo/bar\rfoo/bar\r' |
| 96 |
foo.bar\r [(]no-eol[)] (re) (esc) |
| 97 |
foo.bar\r \(no-eol\) (re) |
| 98 |
|
| 99 |
testing hghave |
| 100 |
|
| 101 |
$ hghave true |
| 102 |
$ hghave false |
| 103 |
skipped: missing feature: nail clipper |
| 104 |
[1] |
| 105 |
$ hghave no-true |
| 106 |
skipped: system supports yak shaving |
| 107 |
[1] |
| 108 |
$ hghave no-false |
| 109 |
|
| 110 |
Conditional sections based on hghave: |
| 111 |
|
| 112 |
#if true |
| 113 |
$ echo tested |
| 114 |
tested |
| 115 |
#else |
| 116 |
$ echo skipped |
| 117 |
#endif |
| 118 |
|
| 119 |
#if false |
| 120 |
$ echo skipped |
| 121 |
#else |
| 122 |
$ echo tested |
| 123 |
tested |
| 124 |
#endif |
| 125 |
|
| 126 |
#if no-false |
| 127 |
$ echo tested |
| 128 |
tested |
| 129 |
#else |
| 130 |
$ echo skipped |
| 131 |
#endif |
| 132 |
|
| 133 |
#if no-true |
| 134 |
$ echo skipped |
| 135 |
#else |
| 136 |
$ echo tested |
| 137 |
tested |
| 138 |
#endif |
| 139 |
|
| 140 |
Exit code: |
| 141 |
|
| 142 |
$ (exit 1) |
| 143 |
[1] |