2014-05-30 22:40:24 +04:00
|
|
|
Test that the syntax of "unified tests" is properly processed
|
|
|
|
==============================================================
|
|
|
|
|
2010-09-23 01:06:00 +04:00
|
|
|
Simple commands:
|
|
|
|
|
|
|
|
$ echo foo
|
|
|
|
foo
|
2010-11-08 03:35:40 +03:00
|
|
|
$ printf 'oh no'
|
|
|
|
oh no (no-eol)
|
2010-09-23 03:20:47 +04:00
|
|
|
$ printf 'bar\nbaz\n' | cat
|
2010-09-23 01:06:00 +04:00
|
|
|
bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
Multi-line command:
|
|
|
|
|
|
|
|
$ foo() {
|
|
|
|
> echo bar
|
|
|
|
> }
|
|
|
|
$ foo
|
|
|
|
bar
|
|
|
|
|
2011-11-07 23:46:41 +04:00
|
|
|
Return codes before inline python:
|
|
|
|
|
2012-01-27 06:00:32 +04:00
|
|
|
$ sh -c 'exit 1'
|
2011-11-07 23:46:41 +04:00
|
|
|
[1]
|
|
|
|
|
2011-10-13 19:54:38 +04:00
|
|
|
Doctest commands:
|
|
|
|
|
2016-07-03 19:58:24 +03:00
|
|
|
>>> from __future__ import print_function
|
|
|
|
>>> print('foo')
|
2011-10-13 19:54:38 +04:00
|
|
|
foo
|
|
|
|
$ echo interleaved
|
|
|
|
interleaved
|
|
|
|
>>> for c in 'xyz':
|
2016-07-03 19:58:24 +03:00
|
|
|
... print(c)
|
2011-10-13 19:54:38 +04:00
|
|
|
x
|
|
|
|
y
|
|
|
|
z
|
2016-07-03 19:58:24 +03:00
|
|
|
>>> print()
|
2011-11-07 23:46:41 +04:00
|
|
|
|
2014-09-28 09:15:43 +04:00
|
|
|
>>> foo = 'global name'
|
|
|
|
>>> def func():
|
2016-07-03 19:58:24 +03:00
|
|
|
... print(foo, 'should be visible in func()')
|
2014-09-28 09:15:43 +04:00
|
|
|
>>> func()
|
|
|
|
global name should be visible in func()
|
2016-07-03 19:58:24 +03:00
|
|
|
>>> print('''multiline
|
|
|
|
... string''')
|
2014-09-28 10:13:35 +04:00
|
|
|
multiline
|
|
|
|
string
|
2011-10-13 19:54:38 +04:00
|
|
|
|
2010-09-23 01:06:00 +04:00
|
|
|
Regular expressions:
|
|
|
|
|
|
|
|
$ echo foobarbaz
|
|
|
|
foobar.* (re)
|
|
|
|
$ echo barbazquux
|
|
|
|
.*quux.* (re)
|
|
|
|
|
2010-09-23 01:06:02 +04:00
|
|
|
Globs:
|
|
|
|
|
2010-09-23 03:20:47 +04:00
|
|
|
$ printf '* \\foobarbaz {10}\n'
|
2010-09-23 01:06:02 +04:00
|
|
|
\* \\fo?bar* {10} (glob)
|
|
|
|
|
2010-09-23 01:06:00 +04:00
|
|
|
Literal match ending in " (re)":
|
|
|
|
|
|
|
|
$ echo 'foo (re)'
|
|
|
|
foo (re)
|
|
|
|
|
2012-10-15 04:33:12 +04:00
|
|
|
Windows: \r\n is handled like \n and can be escaped:
|
|
|
|
|
|
|
|
#if windows
|
2012-10-18 02:33:26 +04:00
|
|
|
$ printf 'crlf\r\ncr\r\tcrlf\r\ncrlf\r\n'
|
2012-10-15 04:33:12 +04:00
|
|
|
crlf
|
|
|
|
cr\r (no-eol) (esc)
|
|
|
|
\tcrlf (esc)
|
2012-10-18 02:33:26 +04:00
|
|
|
crlf\r (esc)
|
2012-10-15 04:33:12 +04:00
|
|
|
#endif
|
|
|
|
|
2012-10-14 20:30:42 +04:00
|
|
|
Combining esc with other markups - and handling lines ending with \r instead of \n:
|
|
|
|
|
|
|
|
$ printf 'foo/bar\r'
|
2014-02-14 03:36:44 +04:00
|
|
|
fo?/bar\r (no-eol) (glob) (esc)
|
2012-10-14 20:30:42 +04:00
|
|
|
#if windows
|
|
|
|
$ printf 'foo\\bar\r'
|
2017-12-11 06:50:57 +03:00
|
|
|
foo/bar\r (no-eol) (esc)
|
2012-10-14 20:30:42 +04:00
|
|
|
#endif
|
|
|
|
$ printf 'foo/bar\rfoo/bar\r'
|
|
|
|
foo.bar\r \(no-eol\) (re) (esc)
|
|
|
|
foo.bar\r \(no-eol\) (re)
|
|
|
|
|
2012-06-08 17:11:05 +04:00
|
|
|
testing hghave
|
|
|
|
|
2019-09-21 03:43:59 +03:00
|
|
|
$ hg debugpython -- "$TESTDIR/hghave" true
|
|
|
|
$ hg debugpython -- "$TESTDIR/hghave" false
|
2012-06-08 17:11:05 +04:00
|
|
|
skipped: missing feature: nail clipper
|
|
|
|
[1]
|
2019-09-21 03:43:59 +03:00
|
|
|
$ hg debugpython -- "$TESTDIR/hghave" no-true
|
2012-06-08 17:11:05 +04:00
|
|
|
skipped: system supports yak shaving
|
|
|
|
[1]
|
2019-09-21 03:43:59 +03:00
|
|
|
$ hg debugpython -- "$TESTDIR/hghave" no-false
|
2012-06-08 17:11:05 +04:00
|
|
|
|
2012-06-01 04:25:12 +04:00
|
|
|
Conditional sections based on hghave:
|
|
|
|
|
2012-06-08 17:11:05 +04:00
|
|
|
#if true
|
|
|
|
$ echo tested
|
|
|
|
tested
|
|
|
|
#else
|
|
|
|
$ echo skipped
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if false
|
2012-06-01 04:25:12 +04:00
|
|
|
$ echo skipped
|
|
|
|
#else
|
|
|
|
$ echo tested
|
|
|
|
tested
|
|
|
|
#endif
|
|
|
|
|
2012-06-11 16:09:35 +04:00
|
|
|
#if no-false
|
|
|
|
$ echo tested
|
|
|
|
tested
|
|
|
|
#else
|
|
|
|
$ echo skipped
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if no-true
|
|
|
|
$ echo skipped
|
|
|
|
#else
|
|
|
|
$ echo tested
|
|
|
|
tested
|
|
|
|
#endif
|
|
|
|
|
2010-09-23 01:06:00 +04:00
|
|
|
Exit code:
|
|
|
|
|
2012-08-08 20:10:16 +04:00
|
|
|
$ (exit 1)
|
2010-09-23 01:06:00 +04:00
|
|
|
[1]
|