annotate tests/test-unified-test.t @ 40320:9b2e1b00ee94

tests: use byte literals in test-storage.py This fixes a Python 3 breakage due to unknown key due to str/bytes type mismatch. # skip-blame just b'' literals Differential Revision: https://phab.mercurial-scm.org/D5114
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 16 Oct 2018 17:48:28 +0200
parents e504fa630860
children bd0f122f3f51
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21731
204f6a6e9b57 tests: comment the main purpose of ``test-unified-test.t``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21729
diff changeset
1 Test that the syntax of "unified tests" is properly processed
204f6a6e9b57 tests: comment the main purpose of ``test-unified-test.t``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21729
diff changeset
2 ==============================================================
204f6a6e9b57 tests: comment the main purpose of ``test-unified-test.t``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 21729
diff changeset
3
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
4 Simple commands:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
5
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
6 $ echo foo
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
7 foo
12940
518dd70d1a6e tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents: 12406
diff changeset
8 $ printf 'oh no'
518dd70d1a6e tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents: 12406
diff changeset
9 oh no (no-eol)
12377
a5b77eb0409b tests: various fixes for new unified test pattern format
Matt Mackall <mpm@selenic.com>
parents: 12376
diff changeset
10 $ printf 'bar\nbaz\n' | cat
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
11 bar
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
12 baz
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
13
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
14 Multi-line command:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
15
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
16 $ foo() {
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
17 > echo bar
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
18 > }
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
19 $ foo
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
20 bar
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
21
15434
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
22 Return codes before inline python:
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
23
16014
f8955a7f82e6 tests: don't rely on 'false' exit code in test-run-tests.t
Mads Kiilerich <mads@kiilerich.com>
parents: 15434
diff changeset
24 $ sh -c 'exit 1'
15434
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
25 [1]
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
26
15249
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
27 Doctest commands:
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
28
29485
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
29 >>> from __future__ import print_function
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
30 >>> print('foo')
15249
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
31 foo
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
32 $ echo interleaved
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
33 interleaved
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
34 >>> for c in 'xyz':
29485
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
35 ... print(c)
15249
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
36 x
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
37 y
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
38 z
29485
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
39 >>> print()
15434
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
40
22564
9599e86159ac heredoctest: use the same dict for local/global contexts as in doctest
Yuya Nishihara <yuya@tcha.org>
parents: 21731
diff changeset
41 >>> foo = 'global name'
9599e86159ac heredoctest: use the same dict for local/global contexts as in doctest
Yuya Nishihara <yuya@tcha.org>
parents: 21731
diff changeset
42 >>> def func():
29485
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
43 ... print(foo, 'should be visible in func()')
22564
9599e86159ac heredoctest: use the same dict for local/global contexts as in doctest
Yuya Nishihara <yuya@tcha.org>
parents: 21731
diff changeset
44 >>> func()
9599e86159ac heredoctest: use the same dict for local/global contexts as in doctest
Yuya Nishihara <yuya@tcha.org>
parents: 21731
diff changeset
45 global name should be visible in func()
29485
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
46 >>> print('''multiline
6a98f9408a50 py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25472
diff changeset
47 ... string''')
22565
8d45a42b0c0f heredoctest: do not append extra newline character to continuation line
Yuya Nishihara <yuya@tcha.org>
parents: 22564
diff changeset
48 multiline
8d45a42b0c0f heredoctest: do not append extra newline character to continuation line
Yuya Nishihara <yuya@tcha.org>
parents: 22564
diff changeset
49 string
15249
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
50
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
51 Regular expressions:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
52
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
53 $ echo foobarbaz
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
54 foobar.* (re)
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
55 $ echo barbazquux
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
56 .*quux.* (re)
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
57
12376
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
58 Globs:
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
59
12377
a5b77eb0409b tests: various fixes for new unified test pattern format
Matt Mackall <mpm@selenic.com>
parents: 12376
diff changeset
60 $ printf '* \\foobarbaz {10}\n'
12376
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
61 \* \\fo?bar* {10} (glob)
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
62
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
63 Literal match ending in " (re)":
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
64
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
65 $ echo 'foo (re)'
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
66 foo (re)
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
67
17777
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
68 Windows: \r\n is handled like \n and can be escaped:
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
69
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
70 #if windows
17799
327fbe0b84fd test-run-tests.t: fix wrong test case for cr handling on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17778
diff changeset
71 $ printf 'crlf\r\ncr\r\tcrlf\r\ncrlf\r\n'
17777
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
72 crlf
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
73 cr\r (no-eol) (esc)
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
74 \tcrlf (esc)
17799
327fbe0b84fd test-run-tests.t: fix wrong test case for cr handling on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17778
diff changeset
75 crlf\r (esc)
17777
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
76 #endif
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
77
17778
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
78 Combining esc with other markups - and handling lines ending with \r instead of \n:
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
79
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
80 $ printf 'foo/bar\r'
20602
8a2dfac89ad6 tests: glob match has a glob character for not getting a warning on windows
Simon Heimberg <simohe@besonet.ch>
parents: 17799
diff changeset
81 fo?/bar\r (no-eol) (glob) (esc)
17778
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
82 #if windows
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
83 $ printf 'foo\\bar\r'
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 29485
diff changeset
84 foo/bar\r (no-eol) (esc)
17778
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
85 #endif
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
86 $ printf 'foo/bar\rfoo/bar\r'
38094
e504fa630860 tests: use [(] instead of \( to avoid warning on py3
Augie Fackler <augie@google.com>
parents: 35393
diff changeset
87 foo.bar\r [(]no-eol[)] (re) (esc)
17778
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
88 foo.bar\r \(no-eol\) (re)
80fe64581f3a run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents: 17777
diff changeset
89
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
90 testing hghave
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
91
25472
4d2b9b304ad0 tests: drop explicit $TESTDIR from executables
Matt Mackall <mpm@selenic.com>
parents: 22565
diff changeset
92 $ hghave true
4d2b9b304ad0 tests: drop explicit $TESTDIR from executables
Matt Mackall <mpm@selenic.com>
parents: 22565
diff changeset
93 $ hghave false
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
94 skipped: missing feature: nail clipper
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
95 [1]
25472
4d2b9b304ad0 tests: drop explicit $TESTDIR from executables
Matt Mackall <mpm@selenic.com>
parents: 22565
diff changeset
96 $ hghave no-true
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
97 skipped: system supports yak shaving
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
98 [1]
25472
4d2b9b304ad0 tests: drop explicit $TESTDIR from executables
Matt Mackall <mpm@selenic.com>
parents: 22565
diff changeset
99 $ hghave no-false
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
100
16842
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
101 Conditional sections based on hghave:
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
102
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
103 #if true
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
104 $ echo tested
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
105 tested
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
106 #else
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
107 $ echo skipped
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
108 #endif
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
109
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
110 #if false
16842
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
111 $ echo skipped
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
112 #else
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
113 $ echo tested
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
114 tested
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
115 #endif
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
116
16914
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
117 #if no-false
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
118 $ echo tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
119 tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
120 #else
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
121 $ echo skipped
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
122 #endif
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
123
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
124 #if no-true
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
125 $ echo skipped
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
126 #else
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
127 $ echo tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
128 tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
129 #endif
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
130
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
131 Exit code:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
132
17345
4f8054d3171b check-code: fix check for trailing whitespace on sh command lines
Mads Kiilerich <mads@kiilerich.com>
parents: 16914
diff changeset
133 $ (exit 1)
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
134 [1]