tests/test-run-tests.t
author Matt Mackall <mpm@selenic.com>
Mon, 07 Nov 2011 13:46:41 -0600
changeset 15434 5635a4017061
parent 15249 f30c0a7b8346
child 16014 f8955a7f82e6
permissions -rw-r--r--
run-tests: replace inline python handling with more native scheme Normally changes in tests are reported like this in diffs: $ cat foo - a + b Using -i mode lets us update tests when the new results are correct and/or populate tests with their output. But with the standard doctest framework, inline Python sections in tests changes instead result in a big failure report that's unhelpful. So here, we replace the doctest calls with a simple compile/eval loop.
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
5635a4017061 run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 15249
diff changeset
    21
  $ false
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
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    55
Exit code:
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    56
12406
66a07fb76ceb tests: avoid checking the exitcode of false
Mads Kiilerich <mads@kiilerich.com>
parents: 12377
diff changeset
    57
  $ (exit 1) 
12375
02990e22150b tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
diff changeset
    58
  [1]