tests/test-run-tests.t
branchstable
changeset 21926 6c36dc6cd61a
parent 20602 8a2dfac89ad6
parent 21763 84cd5ee787ed
child 21977 4ca4e1572022
child 22121 706b91f6dd0e
equal deleted inserted replaced
21876:584bbfd1b50d 21926:6c36dc6cd61a
     1 Simple commands:
     1 This file tests the behavior of run-tests.py itself.
     2 
     2 
     3   $ echo foo
     3 Smoke test
     4   foo
     4 ============
     5   $ printf 'oh no'
     5 
     6   oh no (no-eol)
     6   $ $TESTDIR/run-tests.py
     7   $ printf 'bar\nbaz\n' | cat
     7   
     8   bar
     8   # Ran 0 tests, 0 skipped, 0 warned, 0 failed.
     9   baz
     9 
    10 
    10 a succesful test
    11 Multi-line command:
    11 =======================
    12 
    12 
    13   $ foo() {
    13   $ cat > test-success.t << EOF
    14   >     echo bar
    14   >   $ echo babar
    15   > }
    15   >   babar
    16   $ foo
    16   > EOF
    17   bar
    17 
    18 
    18   $ $TESTDIR/run-tests.py --with-hg=`which hg`
    19 Return codes before inline python:
    19   .
    20 
    20   # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
    21   $ sh -c 'exit 1'
    21 
    22   [1]
    22 failing test
    23 
    23 ==================
    24 Doctest commands:
    24 
    25 
    25   $ cat > test-failure.t << EOF
    26   >>> print 'foo'
    26   >   $ echo babar
    27   foo
    27   >   rataxes
    28   $ echo interleaved
    28   > EOF
    29   interleaved
    29 
    30   >>> for c in 'xyz':
    30   $ $TESTDIR/run-tests.py --with-hg=`which hg`
    31   ...     print c
    31   
    32   x
    32   --- $TESTTMP/test-failure.t
    33   y
    33   +++ $TESTTMP/test-failure.t.err
    34   z
    34   @@ -1,2 +1,2 @@
    35   >>> print
    35      $ echo babar
    36   
    36   -  rataxes
    37 
    37   +  babar
    38 Regular expressions:
    38   
    39 
    39   ERROR: test-failure.t output changed
    40   $ echo foobarbaz
    40   !.
    41   foobar.* (re)
    41   Failed test-failure.t: output changed
    42   $ echo barbazquux
    42   # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
    43   .*quux.* (re)
    43   python hash seed: * (glob)
    44 
    44   [1]
    45 Globs:
    45 
    46 
    46 test for --retest
    47   $ printf '* \\foobarbaz {10}\n'
    47 ====================
    48   \* \\fo?bar* {10} (glob)
    48 
    49 
    49   $ $TESTDIR/run-tests.py --with-hg=`which hg` --retest
    50 Literal match ending in " (re)":
    50   
    51 
    51   --- $TESTTMP/test-failure.t
    52   $ echo 'foo (re)'
    52   +++ $TESTTMP/test-failure.t.err
    53   foo (re)
    53   @@ -1,2 +1,2 @@
    54 
    54      $ echo babar
    55 Windows: \r\n is handled like \n and can be escaped:
    55   -  rataxes
    56 
    56   +  babar
    57 #if windows
    57   
    58   $ printf 'crlf\r\ncr\r\tcrlf\r\ncrlf\r\n'
    58   ERROR: test-failure.t output changed
    59   crlf
    59   !
    60   cr\r (no-eol) (esc)
    60   Failed test-failure.t: output changed
    61   \tcrlf (esc)
    61   # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
    62   crlf\r (esc)
    62   python hash seed: * (glob)
    63 #endif
    63   [1]
    64 
    64 
    65 Combining esc with other markups - and handling lines ending with \r instead of \n:
    65 Selecting Tests To Run
    66 
    66 ======================
    67   $ printf 'foo/bar\r'
    67 
    68   fo?/bar\r (no-eol) (glob) (esc)
    68 successful
    69 #if windows
    69 
    70   $ printf 'foo\\bar\r'
    70   $ $TESTDIR/run-tests.py --with-hg=`which hg` test-success.t
    71   foo/bar\r (no-eol) (glob) (esc)
    71   .
    72 #endif
    72   # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
    73   $ printf 'foo/bar\rfoo/bar\r'
    73 
    74   foo.bar\r \(no-eol\) (re) (esc)
    74 failed
    75   foo.bar\r \(no-eol\) (re)
    75 
    76 
    76   $ $TESTDIR/run-tests.py --with-hg=`which hg` test-failure.t
    77 testing hghave
    77   
    78 
    78   --- $TESTTMP/test-failure.t
    79   $ "$TESTDIR/hghave" true
    79   +++ $TESTTMP/test-failure.t.err
    80   $ "$TESTDIR/hghave" false
    80   @@ -1,2 +1,2 @@
    81   skipped: missing feature: nail clipper
    81      $ echo babar
    82   [1]
    82   -  rataxes
    83   $ "$TESTDIR/hghave" no-true
    83   +  babar
    84   skipped: system supports yak shaving
    84   
    85   [1]
    85   ERROR: test-failure.t output changed
    86   $ "$TESTDIR/hghave" no-false
    86   !
    87 
    87   Failed test-failure.t: output changed
    88 Conditional sections based on hghave:
    88   # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
    89 
    89   python hash seed: * (glob)
    90 #if true
    90   [1]
    91   $ echo tested
    91 
    92   tested
    92 Running In Debug Mode
    93 #else
    93 ======================
    94   $ echo skipped
    94 
    95 #endif
    95   $ $TESTDIR/run-tests.py --with-hg=`which hg` --debug
    96 
    96   + echo SALT* 0 0 (glob)
    97 #if false
    97   SALT* 0 0 (glob)
    98   $ echo skipped
    98   + echo babar
    99 #else
    99   babar
   100   $ echo tested
   100   + echo SALT* 2 0 (glob)
   101   tested
   101   SALT* 2 0 (glob)
   102 #endif
   102   .+ echo SALT* 0 0 (glob)
   103 
   103   SALT* 0 0 (glob)
   104 #if no-false
   104   + echo babar
   105   $ echo tested
   105   babar
   106   tested
   106   + echo SALT* 2 0 (glob)
   107 #else
   107   SALT* 2 0 (glob)
   108   $ echo skipped
   108   .
   109 #endif
   109   # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
   110 
   110 
   111 #if no-true
   111 Parallel runs
   112   $ echo skipped
   112 ==============
   113 #else
   113 
   114   $ echo tested
   114 (duplicate the failing test to get predictable output)
   115   tested
   115   $ cp test-failure.t test-failure-copy.t
   116 #endif
   116 
   117 
   117   $ $TESTDIR/run-tests.py --with-hg=`which hg` --jobs 2 test-failure*.t
   118 Exit code:
   118   
   119 
   119   --- $TESTTMP/test-failure*.t (glob)
   120   $ (exit 1)
   120   +++ $TESTTMP/test-failure*.t.err (glob)
   121   [1]
   121   @@ -1,2 +1,2 @@
       
   122      $ echo babar
       
   123   -  rataxes
       
   124   +  babar
       
   125   
       
   126   ERROR: test-failure*.t output changed (glob)
       
   127   !
       
   128   --- $TESTTMP/test-failure*.t (glob)
       
   129   +++ $TESTTMP/test-failure*.t.err (glob)
       
   130   @@ -1,2 +1,2 @@
       
   131      $ echo babar
       
   132   -  rataxes
       
   133   +  babar
       
   134   
       
   135   ERROR: test-failure*.t output changed (glob)
       
   136   !
       
   137   Failed test-failure*.t: output changed (glob)
       
   138   Failed test-failure*.t: output changed (glob)
       
   139   # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
       
   140   python hash seed: * (glob)
       
   141   [1]
       
   142 
       
   143 (delete the duplicated test file)
       
   144   $ rm test-failure-copy.t
       
   145 
       
   146 
       
   147 Interactive run
       
   148 ===============
       
   149 
       
   150 (backup the failing test)
       
   151   $ cp test-failure.t backup
       
   152 
       
   153 Refuse the fix
       
   154 
       
   155   $ echo 'n' | $TESTDIR/run-tests.py --with-hg=`which hg` -i
       
   156   
       
   157   --- $TESTTMP/test-failure.t
       
   158   +++ $TESTTMP/test-failure.t.err
       
   159   @@ -1,2 +1,2 @@
       
   160      $ echo babar
       
   161   -  rataxes
       
   162   +  babar
       
   163   Accept this change? [n] 
       
   164   ERROR: test-failure.t output changed
       
   165   !.
       
   166   Failed test-failure.t: output changed
       
   167   # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
       
   168   python hash seed: * (glob)
       
   169   [1]
       
   170 
       
   171   $ cat test-failure.t
       
   172     $ echo babar
       
   173     rataxes
       
   174 
       
   175 Accept the fix
       
   176 
       
   177   $ echo 'y' | $TESTDIR/run-tests.py --with-hg=`which hg` -i
       
   178   
       
   179   --- $TESTTMP/test-failure.t
       
   180   +++ $TESTTMP/test-failure.t.err
       
   181   @@ -1,2 +1,2 @@
       
   182      $ echo babar
       
   183   -  rataxes
       
   184   +  babar
       
   185   Accept this change? [n] ..
       
   186   # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
       
   187 
       
   188   $ cat test-failure.t
       
   189     $ echo babar
       
   190     babar
       
   191 
       
   192 (reinstall)
       
   193   $ mv backup test-failure.t
       
   194 
       
   195 No Diff
       
   196 ===============
       
   197 
       
   198   $ $TESTDIR/run-tests.py --with-hg=`which hg` --nodiff
       
   199   !.
       
   200   Failed test-failure.t: output changed
       
   201   # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
       
   202   python hash seed: * (glob)
       
   203   [1]