tests/test-run-tests.t
author Mads Kiilerich <mads@kiilerich.com>
Fri, 01 Jun 2012 02:25:12 +0200
changeset 16842 a3ea092203a5
parent 16014 f8955a7f82e6
child 16891 b0e8afdfa970
permissions -rw-r--r--
tests: introduce c-style conditional sections in .t tests This makes it possible to have conditional sections like: #if windows $ echo foo foo #else $ echo bar bar #endif The directives and skipped sections are treated like comments, so don't interleave them with commands and their output. The parameters to #if are evaluated while preparing the test by passing them over to hghave. Requirements can thus be negated with 'no-' prefix, and multiple requirements must all be true to return true.

Simple commands:

  $ echo foo
  foo
  $ printf 'oh no'
  oh no (no-eol)
  $ printf 'bar\nbaz\n' | cat
  bar
  baz

Multi-line command:

  $ foo() {
  >     echo bar
  > }
  $ foo
  bar

Return codes before inline python:

  $ sh -c 'exit 1'
  [1]

Doctest commands:

  >>> print 'foo'
  foo
  $ echo interleaved
  interleaved
  >>> for c in 'xyz':
  ...     print c
  x
  y
  z
  >>> print
  

Regular expressions:

  $ echo foobarbaz
  foobar.* (re)
  $ echo barbazquux
  .*quux.* (re)

Globs:

  $ printf '* \\foobarbaz {10}\n'
  \* \\fo?bar* {10} (glob)

Literal match ending in " (re)":

  $ echo 'foo (re)'
  foo (re)

Conditional sections based on hghave:

#if fifo no-fifo
  $ echo skipped
#else
  $ echo tested
  tested
#endif

Exit code:

  $ (exit 1) 
  [1]