tests/test-run-tests.t
author Mads Kiilerich <mads@kiilerich.com>
Mon, 15 Oct 2012 02:33:12 +0200
changeset 17777 af7c6bc48d8d
parent 17345 4f8054d3171b
child 17778 80fe64581f3a
permissions -rw-r--r--
run-tests: alternative way of handling \r on Windows After f71d60da58fb all \r was stripped from output on Windows, and the places where a \r explicitly was expected it was accepted that it was missing. Ugly hack. Instead we now accept that an extra \r might appear at the end of lines on Windows. That is more to the point and less ugly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
     1
Simple commands:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
     2
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
     3
  $ echo foo
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
     4
  foo
12940
518dd70d1a6e tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents: 12406
diff changeset
     5
  $ printf 'oh no'
518dd70d1a6e tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents: 12406
diff changeset
     6
  oh no (no-eol)
12377
a5b77eb0409b tests: various fixes for new unified test pattern format
Matt Mackall <mpm@selenic.com>
parents: 12376
diff changeset
     7
  $ 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
     8
  bar
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
     9
  baz
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    10
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    11
Multi-line command:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    12
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    13
  $ foo() {
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    14
  >     echo bar
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
  bar
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    18
15434
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
    19
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
    20
16014
f8955a7f82e6 tests: don't rely on 'false' exit code in test-run-tests.t
Mads Kiilerich <mads@kiilerich.com>
parents: 15434
diff changeset
    21
  $ 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
    22
  [1]
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
    23
15249
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    24
Doctest commands:
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    25
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    26
  >>> print 'foo'
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    27
  foo
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    28
  $ echo interleaved
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    29
  interleaved
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    30
  >>> for c in 'xyz':
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    31
  ...     print c
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    32
  x
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    33
  y
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    34
  z
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    35
  >>> print
15434
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
    36
  
15249
f30c0a7b8346 tests: add basic tests for doctest syntax
Idan Kamara <idankk86@gmail.com>
parents: 12940
diff changeset
    37
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    38
Regular expressions:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    39
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    40
  $ echo foobarbaz
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    41
  foobar.* (re)
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    42
  $ echo barbazquux
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    43
  .*quux.* (re)
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    44
12376
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
    45
Globs:
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
    46
12377
a5b77eb0409b tests: various fixes for new unified test pattern format
Matt Mackall <mpm@selenic.com>
parents: 12376
diff changeset
    47
  $ printf '* \\foobarbaz {10}\n'
12376
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
    48
  \* \\fo?bar* {10} (glob)
97ffc68f71d3 tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents: 12375
diff changeset
    49
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    50
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
    51
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    52
  $ echo 'foo (re)'
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    53
  foo (re)
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    54
17777
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    55
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
    56
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    57
#if windows
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    58
  $ printf 'crlf\r\ncr\r\tcrlf\r\ncrcrlf\r\r\n'
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    59
  crlf
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    60
  cr\r (no-eol) (esc)
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    61
  \tcrlf (esc)
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    62
  crcrlf\r (esc)
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    63
#endif
af7c6bc48d8d run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents: 17345
diff changeset
    64
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    65
testing hghave
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    66
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    67
  $ "$TESTDIR/hghave" true
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    68
  $ "$TESTDIR/hghave" false
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    69
  skipped: missing feature: nail clipper
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    70
  [1]
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    71
  $ "$TESTDIR/hghave" no-true
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    72
  skipped: system supports yak shaving
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    73
  [1]
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    74
  $ "$TESTDIR/hghave" no-false
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    75
16842
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    76
Conditional sections based on hghave:
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    77
16891
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    78
#if true
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    79
  $ echo tested
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    80
  tested
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    81
#else
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    82
  $ echo skipped
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    83
#endif
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    84
b0e8afdfa970 tests/hghave: implement #if true / #if false
Adrian Buehlmann <adrian@cadifra.com>
parents: 16842
diff changeset
    85
#if false
16842
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    86
  $ echo skipped
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    87
#else
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    88
  $ echo tested
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    89
  tested
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    90
#endif
a3ea092203a5 tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents: 16014
diff changeset
    91
16914
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    92
#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
    93
  $ echo tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    94
  tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    95
#else
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    96
  $ echo skipped
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    97
#endif
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    98
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
    99
#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
   100
  $ echo skipped
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
   101
#else
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
   102
  $ echo tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
   103
  tested
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
   104
#endif
2030dec7c8fa test-run-tests: add tests for "#if no-false" and no-true
Adrian Buehlmann <adrian@cadifra.com>
parents: 16891
diff changeset
   105
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
   106
Exit code:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
   107
17345
4f8054d3171b check-code: fix check for trailing whitespace on sh command lines
Mads Kiilerich <mads@kiilerich.com>
parents: 16914
diff changeset
   108
  $ (exit 1)
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
   109
  [1]