tests/test-unified-test.t
changeset 21729 a437ce9ed65a
parent 20602 8a2dfac89ad6
child 21731 204f6a6e9b57
equal deleted inserted replaced
21728:0f73ed629362 21729:a437ce9ed65a
       
     1 Simple commands:
       
     2 
       
     3   $ echo foo
       
     4   foo
       
     5   $ printf 'oh no'
       
     6   oh no (no-eol)
       
     7   $ printf 'bar\nbaz\n' | cat
       
     8   bar
       
     9   baz
       
    10 
       
    11 Multi-line command:
       
    12 
       
    13   $ foo() {
       
    14   >     echo bar
       
    15   > }
       
    16   $ foo
       
    17   bar
       
    18 
       
    19 Return codes before inline python:
       
    20 
       
    21   $ sh -c 'exit 1'
       
    22   [1]
       
    23 
       
    24 Doctest commands:
       
    25 
       
    26   >>> print 'foo'
       
    27   foo
       
    28   $ echo interleaved
       
    29   interleaved
       
    30   >>> for c in 'xyz':
       
    31   ...     print c
       
    32   x
       
    33   y
       
    34   z
       
    35   >>> print
       
    36   
       
    37 
       
    38 Regular expressions:
       
    39 
       
    40   $ echo foobarbaz
       
    41   foobar.* (re)
       
    42   $ echo barbazquux
       
    43   .*quux.* (re)
       
    44 
       
    45 Globs:
       
    46 
       
    47   $ printf '* \\foobarbaz {10}\n'
       
    48   \* \\fo?bar* {10} (glob)
       
    49 
       
    50 Literal match ending in " (re)":
       
    51 
       
    52   $ echo 'foo (re)'
       
    53   foo (re)
       
    54 
       
    55 Windows: \r\n is handled like \n and can be escaped:
       
    56 
       
    57 #if windows
       
    58   $ printf 'crlf\r\ncr\r\tcrlf\r\ncrlf\r\n'
       
    59   crlf
       
    60   cr\r (no-eol) (esc)
       
    61   \tcrlf (esc)
       
    62   crlf\r (esc)
       
    63 #endif
       
    64 
       
    65 Combining esc with other markups - and handling lines ending with \r instead of \n:
       
    66 
       
    67   $ printf 'foo/bar\r'
       
    68   fo?/bar\r (no-eol) (glob) (esc)
       
    69 #if windows
       
    70   $ printf 'foo\\bar\r'
       
    71   foo/bar\r (no-eol) (glob) (esc)
       
    72 #endif
       
    73   $ printf 'foo/bar\rfoo/bar\r'
       
    74   foo.bar\r \(no-eol\) (re) (esc)
       
    75   foo.bar\r \(no-eol\) (re)
       
    76 
       
    77 testing hghave
       
    78 
       
    79   $ "$TESTDIR/hghave" true
       
    80   $ "$TESTDIR/hghave" false
       
    81   skipped: missing feature: nail clipper
       
    82   [1]
       
    83   $ "$TESTDIR/hghave" no-true
       
    84   skipped: system supports yak shaving
       
    85   [1]
       
    86   $ "$TESTDIR/hghave" no-false
       
    87 
       
    88 Conditional sections based on hghave:
       
    89 
       
    90 #if true
       
    91   $ echo tested
       
    92   tested
       
    93 #else
       
    94   $ echo skipped
       
    95 #endif
       
    96 
       
    97 #if false
       
    98   $ echo skipped
       
    99 #else
       
   100   $ echo tested
       
   101   tested
       
   102 #endif
       
   103 
       
   104 #if no-false
       
   105   $ echo tested
       
   106   tested
       
   107 #else
       
   108   $ echo skipped
       
   109 #endif
       
   110 
       
   111 #if no-true
       
   112   $ echo skipped
       
   113 #else
       
   114   $ echo tested
       
   115   tested
       
   116 #endif
       
   117 
       
   118 Exit code:
       
   119 
       
   120   $ (exit 1)
       
   121   [1]