Commit Graph

275 Commits

Author SHA1 Message Date
Siddharth Agarwal
19a33f47fb run-tests: open child-parent pipes in binary mode
Python's pickle is a binary format.
2012-11-10 11:37:41 -08:00
Siddharth Agarwal
0f4a538ae3 run-tests: add --time option to log times for each test
--time also prints out the wall-clock time each test takes in descending order.
2012-11-09 14:49:30 -08:00
Siddharth Agarwal
1e050996f6 run-tests: remove resultslock since it serves no useful purpose
Each child process has its own copy of the results dict, so all access to the results dict is serial.
2012-11-09 15:09:35 -08:00
Siddharth Agarwal
c3f43bc1f7 run-tests: use pickle to send results from children to parent
JSON would probably be preferable, but it isn't available for Python 2.4 or 2.5.
2012-11-09 14:42:36 -08:00
Simon Heimberg
d277fc55af run-tests: skip unnecessary operations on the args in the child proces
The arguments are already sorted and never empty.
2012-10-24 23:09:31 +02:00
Mads Kiilerich
7e19bad572 run-tests: remove dead code for supporting old test scripts 2012-10-18 00:44:32 +02:00
Mads Kiilerich
1c2faf6c4c run-tests: handle windows crlf in .py tests again
Before a55b74d8de3a all crlf occurrences in test output on Windows were simply
changed to lf. In a55b74d8de3a it was replaced by more clever handling in the
.t test runner ... but the .py runner was forgotten and many .py tests were
failing on Windows.

The crlf/lf replacement is now reintroduced in the py test runner.
2012-10-18 00:33:29 +02:00
Mads Kiilerich
1aa09f180d run-tests: make it possible to combine (esc) with (glob) and (re)
This makes it possible to combine the annotations ... if done in the right
order.
2012-10-14 18:30:42 +02:00
Mads Kiilerich
ffdf739c4d run-tests: alternative way of handling \r on Windows
After d5471ad04cf6 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.
2012-10-15 02:33:12 +02:00
Bryan O'Sullivan
5e8ce6dc50 tests: correctly report a test killed by a signal 2012-10-11 16:05:14 -07:00
Mads Kiilerich
f815002da3 run-tests: allow test output lines to be terminated with \r in addition to \n
str.splitlines could not be used in 2d839579ce70, but _now_ we would like to
have lines with other line endings than \n.

Some fine occurences of (esc) markup of \r is replaced with multiple lines
ending with '\r (no-eol) (esc)'.  That is no win but also no significant loss.

This change makes it possible to drop filtercr.py - _that_ is a win.
2012-09-26 00:56:27 +02:00
Mads Kiilerich
749801aeb2 run-tests: use more explicit criteria for detecting no-eol
Preparing for the situation where there could be unsalted lines not terminated
with \n.
2012-10-10 01:37:53 +02:00
Mads Kiilerich
d7654fef63 run-tests: drop unused enumerate 2012-10-10 01:30:45 +02:00
Simon Heimberg
2c59c1be4b tests: unset variable HG if it is set
When hg tries to call itself it can call a different hg executable when this
variable is set. Some tests fail when the called hg version is different.
2012-07-28 23:28:17 +02:00
Patrick Mezard
50b52183c2 run-tests: do not duplicate killdaemons() code 2012-08-19 16:41:09 +02:00
Mads Kiilerich
936718b970 tests: use the right directory for running hghave from run-tests.py 2012-06-10 18:50:42 +02:00
Mads Kiilerich
cb3472a4d3 tests: make .t tests stop immediately if a cd fails
This prevents tests from escaping from TESTTMP as a consequence of a failing
directory creation.
2012-06-10 18:50:42 +02:00
Adrian Buehlmann
cc8d5d2d8e tests/run-tests: avoid C:/ in arguments
MSYS replaces C:/... in arguments with C;... as it interprets the C:/ as a
colon separated POSIX path list. The colon is replaced with ; (path separator
on Windows) according to

  http://www.mingw.org/wiki/Posix_path_conversion

So we must not replace \ with / for neither $TESTTMP nor $TESTDIR, but we
have to keep replacing \ with / for the Popen4 call of function hghave. If we
don't do the latter, test-run-tests.t will fail with

  $ python run-tests.py --local test-run-tests.t

  --- C:\Users\adi\hgrepos\hg-main\tests\test-run-tests.t
  +++ C:\Users\adi\hgrepos\hg-main\tests\test-run-tests.t.err
  @@ -70,6 +70,7 @@
     tested
   #else
     $ echo skipped
  +  skipped
   #endif

   #if false


An additional tweak in test-ssh.t is needed that globs away an encoded path,
as it can't be translated back to $TESTTMP, because the backslashes in the
output have been already encoded as %5C.

This patch makes test-ssh.t pass in MSYS on Windows.
2012-06-10 03:05:59 +02:00
Adrian Buehlmann
2f072ea573 tests/run-tests: use $TMP on Windows (issue3490)
This is just a short-term workaround for that issue. More work needs to be
done on scmutil.canonpath & friends.

$TMP on Windows is specified to be defined, and it has correct casing, so we
can use that as the default dir for tempfile.mkdtemp on Windows.
2012-06-08 15:11:05 +02:00
Mads Kiilerich
7d411da706 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.
2012-06-01 02:25:12 +02:00
Adrian Buehlmann
a82229c619 run-tests: don't add python lines to expected dict
For test input lines of *.t files starting with '  >>> ', the code block for
'  >>> '

609:        if l.startswith('  >>> '): # python inlines
610:            after.setdefault(pos, []).append(l)

was (unsurprisingly) executed, but because there was an "if" instead of an
"elif" on the condition "l.startswith('  ... ')", program execution proceeded
to line 636

635:        elif l.startswith('  '): # results
636:            # queue up a list of expected results
637:            expected.setdefault(pos, []).append(l[2:])

due to the fact that if l starts with '  >>> ' it also starts with '  '.

The net effect was that python command lines in *.t files were (surprisingly)
also added to the "expected" dict.

This caused no externally observable bad behavior, as the "expected" dict was
not consulted for these lines.
2012-05-30 14:28:57 +02:00
Adrian Buehlmann
2a2b372dec run-test: replace backslashes in TESTDIR
This may cause troubles in MSYS on Windows.
2012-06-03 19:35:23 +02:00
Brodie Rao
c577fac135 cleanup: replace naked excepts with more specific ones 2012-05-12 16:02:45 +02:00
Matt Mackall
153e35df5d tests: set a standard terminal type
This makes test-ui-color.py happy when run in a dumb terminal.

Spotted by Jesse Glick <jesse.glick@oracle.com>
2012-05-08 15:46:51 -05:00
Mads Kiilerich
df37dcb230 tests: don't require 'hg' without extension on windows
Hackable uses hg.exe instead.
2012-04-28 01:22:47 +02:00
Matt Mackall
8bb041e398 tests: shorten post-test sleeps
This helps expose races
2012-04-02 17:02:03 -05:00
Mads Kiilerich
9bb6f6608a run-tests: expand user in --with-hg
This makes it possible to run:
  $ ./run-tests.py --with-hg=~/hg-bin/hg
2012-01-14 01:56:27 +01:00
Mads Kiilerich
41bb79518b tests: let run-tests.py default to use 'sh' in $PATH instead of '/bin/sh'
This makes it easier to run tests on systems that have a usable sh in the
search path but not in the standard location.
2012-01-20 01:24:16 +01:00
Mads Kiilerich
efadf4b249 tests: add 'set -x' to the .t sh scripts in run-tests.py debug mode
This makes -d output much more readable when debugging the test framework or
very strange test failures.
2012-01-14 01:55:50 +01:00
Markus Zapke-Gründemann
46ae5d8243 tests: add htmlcov option 2012-01-11 15:38:31 +01:00
Matt Mackall
f2d5e5c061 run-tests: use a list comprehension instead of map 2012-01-12 14:39:02 -06:00
Markus Zapke-Gründemann
9311522001 tests: fix omit path list
All directories need a trailing asterisk. Otherwise the files are not excluded
from coverage.
2012-01-11 15:37:25 +01:00
Mads Kiilerich
210dda88ee tests: use an alias to make msys 'pwd' return paths with forward slashes 2011-11-21 01:49:20 +01:00
Mads Kiilerich
e0ce7904f7 tests: use the specified shell for running old fashioned sh tests 2011-11-16 03:45:14 +01:00
Mads Kiilerich
725ccda893 run-tests: make $TESTTMP matching case-insensitive on windows 2011-11-07 03:25:10 +01:00
Mads Kiilerich
b38bca46c2 run-tests: don't quote command names - that do apparently not work with msys 2011-11-07 03:25:10 +01:00
Mads Kiilerich
460890c579 tests: ignore \r on windows 2011-11-07 03:25:10 +01:00
Mads Kiilerich
d71aaf4c6b run-tests: convert windows paths to unix 2011-11-07 03:25:10 +01:00
Mads Kiilerich
8c22a0ec28 tests: make (glob) on windows accept \ instead of /
Globbing is usually used for filenames, so on windows it is reasonable and very
convenient that glob patterns accepts '\' or '/' when the pattern specifies
'/'.
2011-11-07 03:25:10 +01:00
Mads Kiilerich
d9065e4fb9 tests: make '(esc)' matching in run-tests.py work as intended
The code for match on (esc) lines didn't work, and it would thus always end up
emitting another suggestion ... which however would match the old one.
2011-11-07 02:44:04 +01:00
Matt Mackall
17d82e7fd5 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.
2011-11-07 13:46:41 -06:00
Matt Mackall
88220425c1 run-tests: minor cleanups 2011-11-03 15:18:10 -05:00
Matt Mackall
4f749024f0 run-tests: pull out line matching function 2011-11-03 15:08:45 -05:00
Matt Mackall
e770714829 run-tests: pull out unified matching funcs 2011-11-03 14:51:04 -05:00
Matt Mackall
5f6366d991 tests: add some comments to the unified test code 2011-11-03 14:48:56 -05:00
Matt Mackall
65859d124f tests: rewrite inline Python support
Tests with inline Python could turn '>>>' into their underlying python
invocation if the test got updated with -i.
2011-11-03 14:30:00 -05:00
Thomas Arendsen Hein
e30c56ef39 run-tests: make sure no_proxy/NO_PROXY are empty to fix test-http-proxy.t
If no_proxy (or NO_PROXY) includes localhost, the test for detecting an
unreachable proxy fails, because the proxy setting is ignored.
2011-10-22 23:21:38 +02:00
Idan Kamara
3cb661bac7 run-tests: end doctest block when seeing a non-command 2011-10-13 17:54:37 +02:00
Idan Kamara
cb06843ca5 tests: add support for inline doctests in test files
This adds doctest like syntax to .t files, that can be interleaved with regular
shell code:

  $ echo -n a > file
  >>> print open('file').read()
  a
  >>> open('file', 'a').write('b')
  $ cat file
  ab

The syntax is exactly the same as regular doctests, so multiline statements
look like this:

  >>> for i in range(3):
  ...     print i
  0
  1
  2

Each block has its own context, i.e.:

  >>> x = 0
  >>> print x
  0
  $ echo 'foo'
  foo
  >>> print x

will result in a NameError.

Errors are displayed in standard doctest format:

  >>> print 'foo'
  bar

  --- /home/idan/dev/hg/default/tests/test-test.t
  +++ /home/idan/dev/hg/default/tests/test-test.t.err
  @@ -2,3 +2,16 @@
     > >>> print 'foo'
     > bar
     > EOF
  +  **********************************************************************
  +  File "/tmp/tmps8X_0ohg-tst", line 1, in tmps8X_0ohg-tst
  +  Failed example:
  +      print 'foo'
  +  Expected:
  +      bar
  +  Got:
  +      foo
  +  **********************************************************************
  +  1 items had failures:
  +     1 of   1 in tmps8X_0ohg-tst
  +  ***Test Failed*** 1 failures.
  +  [1]

As for the implementation, it's quite simple: when the test runner sees a line
starting with '>>>' it converts it, and all subsequent lines until the next
line that begins with '$' to a 'python -m heredoctest <<EOF' call with the
proper heredoc to follow. So if we have this test file:

  >>> for c in 'abcd':
  ...     print c
  a
  b
  c
  d
  $ echo foo
  foo

It gets converted to:

  $ python -m heredoctest <<EOF
  > >>> for c in 'abcd':
  > ...     print c
  > a
  > b
  > c
  > d
  > EOF
  $ echo foo
  foo

And then processed like every other test file by converting it to a sh script.
2011-10-12 22:01:14 +02:00
Augie Fackler
dfe2a9638f tests: use getattr instead of hasattr 2011-07-25 16:37:18 -05:00