Commit Graph

260 Commits

Author SHA1 Message Date
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
Patrick Mezard
f7c5a41400 run-tests: fix summary when accepting changes interactively
Accepted changes were not counted as success.
2011-07-13 19:23:08 +02:00
Thomas Arendsen Hein
0b341ae9aa run-test: revert most of 723925f3994b, timeout uses fallback for terminate() 2011-06-30 16:36:38 +02:00
Thomas Arendsen Hein
3453fd49fa run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate() 2011-06-30 16:25:05 +02:00
Idan Kamara
cf84c46249 run-tests: verbose log ignored test 2011-06-12 17:26:20 +03:00
Augie Fackler
6f67427a80 run-tests: allow whitelisting tests that should always run
It's desirable to run some tests all the time, for example
test-check-pyflakes.t and test-check-code-hg.py. This allows passing
--whitelist as a path to a file (flag can be specified more than once)
which contains a list of files to whitelist. Whitelisted tests are run
even if they're blacklisted or wouldn't match a --keyword test
run. For example, to do a quick test of usehttp2, one can now do

  $ cat > test-whitelist <<EOF
  > test-check-pyflakes.t
  > test-check-code-hg.py
  > EOF
  $ (cd tests && ./run-tests.py --extra-config-opt 'ui.usehttp2=true'
  >                             -k http -j 8  --whitelist test-whitelist)

and have all http-specific tests run as well as the two code linters.
2011-05-31 20:39:04 -05:00
Patrick Mezard
51439bc0e1 run-tests: fix --blacklist (broken by 098f69771978) 2011-05-28 11:44:27 +02:00
Idan Kamara
f4c2cac599 run-tests: fix --blacklist with jobs > 1
filter blacklisted tests before partitioning them
to the children.

maintains the 'Skipped...' output but not the 's'.
2011-05-27 17:46:48 +03:00
Idan Kamara
13676f41c0 run-tests: slightly simplify blacklist check 2011-05-27 17:46:47 +03:00
Thomas Arendsen Hein
843bd0fb63 run-tests: print a newline after all warnings 2011-05-18 15:45:57 +02:00
Patrick Mezard
f88224316a run-tests: replace chdir() with Popen cwd option 2011-05-16 21:56:26 +02:00
Patrick Mezard
7f9abee9a9 run-tests: make --debug run in the temporary test directory 2011-05-16 21:54:43 +02:00
Patrick Mezard
7151b3e567 run-tests: use the common test path on Windows and Java
The alternate one did not run in the test directory and controlling
the jobs execution with threads instead of process made it harder
to fix.
2011-05-16 21:52:28 +02:00
Patrick Mezard
ee13516475 run-tests: ignore timeout when Popen.terminate is unavailable
Popen.terminate was introduced in python 2.6
2011-05-16 21:41:46 +02:00
Patrick Mezard
c7b66c8493 run-tests: fix hg.bat python reference
hg.bat expects to live in pythonxx/scripts and the python interpreter
to be in pythonxx. run-tests.py file layout is a little different and
python location must be fixed.
2011-05-16 21:26:50 +02:00
Patrick Mezard
954f0d5383 run-tests: fix python executable detection and copy on Windows 2011-05-16 21:24:14 +02:00