.hgtags
author Idan Kamara <idankk86@gmail.com>
Wed, 12 Oct 2011 22:01:14 +0200
branchstable
changeset 987 5fc540826f9f
parent 200 7eae2cfd26fa
permissions -rw-r--r--
tests: add support for inline doctests in test files This adds doctest like syntax to .t files, that can be interleaved with regular shell code: $ echo -n a > file >>> print open('file').read() a >>> open('file', 'a').write('b') $ cat file ab The syntax is exactly the same as regular doctests, so multiline statements look like this: >>> for i in range(3): ... print i 0 1 2 Each block has its own context, i.e.: >>> x = 0 >>> print x 0 $ echo 'foo' foo >>> print x will result in a NameError. Errors are displayed in standard doctest format: >>> print 'foo' bar --- /home/idan/dev/hg/default/tests/test-test.t +++ /home/idan/dev/hg/default/tests/test-test.t.err @@ -2,3 +2,16 @@ > >>> print 'foo' > bar > EOF + ********************************************************************** + File "/tmp/tmps8X_0ohg-tst", line 1, in tmps8X_0ohg-tst + Failed example: + print 'foo' + Expected: + bar + Got: + foo + ********************************************************************** + 1 items had failures: + 1 of 1 in tmps8X_0ohg-tst + ***Test Failed*** 1 failures. + [1] As for the implementation, it's quite simple: when the test runner sees a line starting with '>>>' it converts it, and all subsequent lines until the next line that begins with '$' to a 'python -m heredoctest <<EOF' call with the proper heredoc to follow. So if we have this test file: >>> for c in 'abcd': ... print c a b c d $ echo foo foo It gets converted to: $ python -m heredoctest <<EOF > >>> for c in 'abcd': > ... print c > a > b > c > d > EOF $ echo foo foo And then processed like every other test file by converting it to a sh script. [ original upstream message ]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
bd97d6fde324 Added tag universal_scheme for changeset 536c1797202d
Christian Ebert <blacktrash@gmx.net>
parents:
diff changeset
     1
536c1797202d57efb77bea098e10968ff01602ce universal_scheme
43
fe5d9b9e78fc Added tag cvs_scheme for changeset ba000e29ecf3
Christian Ebert <blacktrash@gmx.net>
parents: 22
diff changeset
     2
ba000e29ecf3b8df09e0fd363a78cabbe3c2a78f cvs_scheme
62
736ff2dde308 Added tag r0.1 for changeset 1fe48bf82d05
Christian Ebert <blacktrash@gmx.net>
parents: 43
diff changeset
     3
1fe48bf82d056f1ece05baccab888357c10c5ab8 r0.1
91
04c899130750 Added tag very_cvs for changeset 2e930f842242
Christian Ebert <blacktrash@gmx.net>
parents: 85
diff changeset
     4
2e930f84224222ad6514a3c5dc6e00350e199e92 very_cvs
125
e09b070073b2 Added tag hgkw_standalone_setup for changeset 99dc49c5bcfb
Christian Ebert <blacktrash@gmx.net>
parents: 91
diff changeset
     5
99dc49c5bcfba9d5b412c5fa6d0bf3ba20d68df1 hgkw_standalone_setup
130
8b9912865921 Added tag nohook for changeset 15e8cd7f5295
Christian Ebert <blacktrash@gmx.net>
parents: 125
diff changeset
     6
15e8cd7f5295728b089fc8ba236c0f079572fb1d nohook
150
ba5cb61db7a0 Added tag archive for changeset 0c8b7e5c25a6
Christian Ebert <blacktrash@gmx.net>
parents: 130
diff changeset
     7
0c8b7e5c25a6b9a0d2782eaa3748eb546f5a254f archive
194
2a51062ecc60 Removed tag universal_scheme
Christian Ebert <blacktrash@gmx.net>
parents: 150
diff changeset
     8
0000000000000000000000000000000000000000 universal_scheme
195
17bd1f7ca3be Removed tag cvs_scheme
Christian Ebert <blacktrash@gmx.net>
parents: 194
diff changeset
     9
0000000000000000000000000000000000000000 cvs_scheme
196
aebd144f03f2 Removed tag r0.1
Christian Ebert <blacktrash@gmx.net>
parents: 195
diff changeset
    10
0000000000000000000000000000000000000000 r0.1
197
87f5b5365b76 Removed tag very_cvs
Christian Ebert <blacktrash@gmx.net>
parents: 196
diff changeset
    11
0000000000000000000000000000000000000000 very_cvs
198
99ab1bcffa67 Removed tag hgkw_standalone_setup
Christian Ebert <blacktrash@gmx.net>
parents: 197
diff changeset
    12
0000000000000000000000000000000000000000 hgkw_standalone_setup
199
d07c6297d4bb Removed tag nohook
Christian Ebert <blacktrash@gmx.net>
parents: 198
diff changeset
    13
0000000000000000000000000000000000000000 nohook
200
7eae2cfd26fa Removed tag archive
Christian Ebert <blacktrash@gmx.net>
parents: 199
diff changeset
    14
0000000000000000000000000000000000000000 archive