Commit Graph

735 Commits

Author SHA1 Message Date
Matt Harbison
f0863290ab run-tests: defer leftover (?) cleanup until after all output is exhausted
Previously, after matching a single line, any contiguous subsequent lines ending
with (?) would be added to the output and removed from the expected output.
This is a problem if the subsequent test output would have matched the consumed
(?) line, because it kept the optional line and then added a duplicate without
the (?) [1].  Instead, wait until there is nothing more to match before handling
the leftovers.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-February/080197.html
2016-02-28 23:21:28 -05:00
Gregory Szorc
9068a821f3 run-tests: fix Python 3 incompatibilities
At one point run-tests.py and test-run-tests.t worked and passed
under Python 3.5. Various changes to run-tests.py over the past
several months appear to have broken Python 3.5 compatibility.

This patch implements various fixes (all related to str/bytes type
coercion) to make run-tests.py and test-run-tests.t mostly work
again. There are still a few failures in test-run-tests.t due to
issues importing mercurial.* modules. But at least run-tests.py
seems to work under 3.5 again.
2016-02-27 21:29:42 -08:00
David R. MacIver
3ebd7298a9 run-tests: allow run-tests.py to run tests outside current directory
When reloading tests, run-tests.py was assuming that it could look
up the test by the basename, which only works if you are running
tests which are in the current directory.

This patch changes that lookup to use the full path. This is all
that was needed, and does not appear to cause any problems for
any of the existing testing work flows based on running the
suggested commands at the top of run-tests.py.

Motivation: In order to test Mercurial with Hypothesis (according
to https://www.mercurial-scm.org/wiki/HypothesisPlan) it is
useful to be able to generate temporary test files and execute
them. Generating temporary files in the tests/ directory leads to
a lot of suboptimal clutter.
2016-02-18 08:52:15 +00:00
timeless
8a0d103caa run-tests: stop allocating HGPORT3+HGPORT4
The only consumer was test-treemanifest.t, which has been fixed.

In general, you should be able to use killdaemons.py to recycle
ports instead of going over 3 ports (HGPORT, HGPORT1, HGPORT2).

In the future, if you want to add a port, be sure to change
portneeded in _getport.
2016-02-17 19:38:44 +00:00
timeless
7b4d0e1e16 run-tests: refactor port allocation into functions
Adding a port reservation was too hard and someone did it wrong.
By refactoring, such reservations can be managed more safely.

This also adds documentation so that the next person who tries
is more likely to update all the places correctly.

Note that in this commit the reservation and consumers do not
match, that will be fixed in the next commit.
2016-02-17 19:36:32 +00:00
Yuya Nishihara
dd5e0b4899 run-tests: add --chg option to install and run tests using chg
Because the temporary installation directory is shared between hg and chg,
--chg is not allowed if --with-hg option is specified. Also, --chg option
does not work on FreeBSD because "make" command is hard-coded. These
limitations can be improved later.

Almost all tests will fail with chg right now.
2016-02-07 18:08:59 +09:00
Yuya Nishihara
83ccd75532 run-tests: add --with-chg option to run tests using chg
Unlike --with-hg=/path/to/chg, this option allows us to start and clean up
command servers in isolated environment. And we can specify the hg command
as well as the chg command.
2016-02-07 16:34:12 +09:00
Yuya Nishihara
cf3e9474ef run-tests: remove useless "failed" flag from addOutputMismatch()
It never be set to True.
2016-01-09 13:22:26 +09:00
Yuya Nishihara
ad2de493a5 tests: load json with no fallback
The json module should be available in Python 2.6 or newer.
2016-01-09 13:20:15 +09:00
Yuya Nishihara
cd561eb91a run-tests: allow to specify executable of any name by --with-hg
If the executable is not named as "hg", TTest runner inserts alias. This
way, we can run tests with chg. But it is still warned because the alias
does not always work. We do "$BINDIR"/hg in a few places.
2016-02-07 15:21:39 +09:00
Yuya Nishihara
3ba5dbc55e run-tests: drop redundant assignment to BINDIR
We do it a few lines after.
2016-02-07 16:02:41 +09:00
Yuya Nishihara
0d8272a88a run-tests: cast --with-hg option to bytes consistently at parseargs()
parseargs() sets bytes to options.with_hg if --local is specified, so do
the same for --with-hg.
2016-02-07 16:00:05 +09:00
Yuya Nishihara
fd68b16ac6 run-tests: do not compare bytes with str while ordering tests
It failed on Python 3.
2016-02-07 15:53:02 +09:00
timeless
64b5aa82c1 run-tests: factor out _escapepath 2016-01-29 14:35:34 +00:00
timeless
e09049f8f5 run-tests: warn about symlinks to non hg scripts
If you symlink /usr/bin/true to /something/hg and try to run
--with-hg=/something/hg, run-tests will end up running /usr/bin/hg,
not /usr/bin/true.
2016-02-08 22:50:19 +00:00
Martin von Zweigbergk
e50c296659 treemanifests: fix streaming clone
Similar to the previous patch, the .hg/store/meta/ directory does not
get copied when when using "hg clone --uncompressed". Fix by including
"meta/" in store.datafiles(). This seems safe to do, as there are only
a few users of this method. "hg manifest" already filters the paths by
"data/" prefix. The calls from largefiles also seem safe. The use in
verify needs updating to prevent it from mistaking dirlogs for
orphaned filelogs. That change is included in this patch.

Since the dirlogs will now be in the fncache when using fncachestore,
let's also update debugrebuildfncache(). That will also allow any
existing treemanifest repos to get their dirlogs into the fncache.

Also update test-treemanifest.t to use an a directory name that
requires dot-encoding and uppercase-encoding so we test that the path
encoding works.
2016-02-04 08:34:07 -08:00
Bryan O'Sullivan
95a960a422 run-tests: "fix" race condition in race condition fix
Laurent's commit 56cdfddbd2ed still suffers from a race: by the
time the "job" function tries to assign to channels[channel], that
list has been truncated to empty.  The result is that every job
thread raises an IndexError.

Earlier, I tried an approach of correctly locking channels, but
that caused run-tests to hang on KeyboardInterrupt sometimes.

This approach is strictly hackier, but seems to actually work
reliably.
2016-01-22 11:00:13 -08:00
Laurent Charignon
bdac46ce5b run-tests: fix crash when --json and --blacklist are both used (issue5050)
This patch fixes a crash when both --json and --blacklist were given as
arguments of run-tests.py. Now, instead of crashing, we add an entry for
blacklisted tests in the json output to show that the tests were skipped.
2016-01-19 08:22:27 -08:00
Laurent Charignon
fb718d23a0 run-tests: fix race condition
Before this patch, it was possible for run-tests to crash on a race condition.
The race condition happens in the following case:
- the last test finishes and calls: done.put(None)
- the context switches to the main thread that clears the channels list
- the context switches to the last test mentioned above, it tries to access
channels[channel] and crashes
This happened to me while running run-tests.

This patch fixes the issue by clearing the channel before considering that the
test is done.
2016-01-21 12:37:12 -08:00
timeless
fafbbff385 run-tests: skip threading for a single test (issue5040)
This version backs out 69d5cadd84a0 and implements it in
a more consistent manner.
2016-01-14 04:14:50 +00:00
Bryan O'Sullivan
c54f58f09c run-tests: use a context manager for file I/O in TextTestRunner 2016-01-12 14:49:10 -08:00
Bryan O'Sullivan
100ad2a9c4 run-tests: use a context manager for file I/O 2016-01-12 14:29:57 -08:00
timeless
25686051e3 run-tests: skip threading for a single test
Threading is incompatible with most Python debuggers,
which makes debugging run-tests.py a real pain.

If there is only one test to run, skip using a thread for it.

Note that --debug is not compatible with debugging tests,
since it bypasses the output handling, which is where
much of the excitement is.
2015-12-28 17:48:40 +00:00
Laurent Charignon
693c12d5a7 run-tests: add 'diff' entry in json report
This patch adds to the json report the "diff" between expected and observed
result. This diff can be useful for automatically filing bug report on failing
tests.
2016-01-05 13:33:09 -08:00
timeless
ebb1d48658 cleanup: remove superfluous space after space after equals (python) 2015-12-31 08:16:59 +00:00
Bryan O'Sullivan
08b463513d tests: make a stab at approximating wall-clock times
Vaguely empirical observations:

* ".py" tests are about an order of magnitude faster than ".t" tests

* dividing size by 1000 gives an approximation to wall-clock
  run time (in seconds) that is not completely ridiculous.
2016-01-04 21:54:46 -08:00
Bryan O'Sullivan
1dfeb4f0f7 tests: only stat a test file if we don't already know its "cost" 2016-01-04 21:54:46 -08:00
Bryan O'Sullivan
5819807652 tests: write recent run times to a file named tests/.testtimes
This is an effortless way to track how long each test takes without
having to pass any extra command line options.
2016-01-04 21:54:44 -08:00
timeless
c93f79b92f run-tests: fix get port to try differing ports
The code was moving its offset each time through the loop,
but because it failed to update port, the port was not
going to be available...
2015-12-29 04:30:38 +00:00
timeless
2a6d0ff53a run-tests: avoid double counting server fails 2015-12-28 16:01:31 +00:00
timeless
da9e1e1cb0 run-tests: report missing feature for skipped tests 2015-12-22 08:00:03 +00:00
Matt Mackall
1a6d366c07 run-tests: show scheduling with --showchannels
This gives one line of output per second with one column per -j level
that allows analyzing test scheduling problems. First 24 seconds of
output at -j 30 looks like this:

  0                                                                .
  1  = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   s.
  2  c c o c r l g r s s = c p = c h c a h c g c h c b c c l l c   ss
  3  h o b o e a e u u u c o a h o e o c g o l h g h u o = a o =   s
  4  e n s n b r n n b b   m t g n l n l w n o e w e n n e r g i   .
  5  c t o = a g d - r r = m c w v p v . e v g c e c d v x g . m
  6  k r l r s e o t e e b a h e e . e . b e . k b k l e t e . p
  7  - i e e e f c e p p u n b b r . r . - r . - - - e r e f . o   .
  8  p b t v - i . s o o n d o d t . t . c t . c s = 2 t n i . r
  9  y - e s c l . t - . d - m i - . - . o - . o y r - - s l . t
 10  3 p - e h e . s s . l t b r s . s . m s . d m e f s i e . .
 11  - e c t e s . . v . e e . . v . v . m v . e r n o v o s . .
 12  c r h . c - . . n . 2 m . . n . n . a n . . e a r n n . . .
 13  o f e . k u . . . . - p . . - . - . n - . . v m m - . . . .
 14  m . c . - p . . . . e l . . s . m . d s . . . e a e . . . .
 15  p . k . r d . . . . x a . . i . o . s o . . . - t n . . . .
 16  a . h . e a . . . . c t . . n . v . . u . . . m . c . . . .
 17  t . e . s t . . . . h e . . k . e . . r . . . e . o . . . .
 18  . . a . t e . . . . a . . . . . . . . c . . . r . d . . . .
 19  . . d . o . . . . . n . . . . . . . . e . . . g . i . . . .
 20  . . s . r . . . . . g . . . . . . . . . . . . e . n . . . .
 21  . . . . e . . . . . e . . . . . . . . . . . . 2 . g . . . .
 22  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
 23  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   .
 24  . . . . . . . . . . . . . . . . . . . . . . . . . = . . . .   ^C

Test names read off vertically, beginning with '='. Idle time (not
shown) appears as blank space.
2015-12-07 16:16:06 -06:00
Matt Mackall
c4ab4cefae run-tests: add more scheduling weight hints
The scheduler would like to order test execution by expected run-time,
but doesn't know much about how long a test will run. It thus uses
test size as a proxy for run-time. By tweaking these weights we can
keep CPUs more evenly busy and thus finish sooner.

In particular, this change pushes the three currently longest-running
tests closer to the beginning:

test-largefiles-update.t
test-run-tests.t
test-gendoc.t

As the largefiles test is currently the long pole of the test suite
with higher -j factors, the sooner it's started, the sooner the tests
can end.

We also up the weight on some shorter but long-running tests that
could have previously delayed completion with low -j factors by
running very close to the end.
2015-12-04 17:05:20 -06:00
Matt Mackall
8d86df8f01 run-tests: report timeouts in a less alarming fashion
Rather than report timed-out tests like this:

 ERROR: test-convert-svn-sink.t output changed
 !

..simply put a 't' rather than a '.' in the stream.
2015-12-04 14:55:10 -06:00
timeless
7337637dd1 run-tests: add --slowtimeout and use it for slow tests 2015-11-25 00:39:05 +00:00
timeless
dd810884fd test-contrib-perf: add smoke tests for perf.py 2015-11-24 21:41:12 +00:00
Augie Fackler
f010f2acf9 run-tests: add b-prefix on two strings to fix python3 support 2015-10-12 14:15:04 -04:00
timeless@mozdev.org
dba46baf88 run-tests: report paths saved by --keep-tmpdir 2015-09-30 16:01:19 -04:00
timeless@mozdev.org
20963e1f94 run-tests: use $HGTEST_RUN_TESTS_PURE
test-run-tests and test-hghave call run-tests;
if you don't have a working build environment, and you are trying
to use --pure, then if they don't use --pure or --with-hg,
they'll break.
2015-09-02 15:19:05 -04:00
Augie Fackler
cd6222a983 run-tests: add support for marking tests as very slow
I want to add tests for our packaging rules, but those necessarily run
a whole build, or possibly two if both native packaging and docker are
available. This lets us flag such tests with a `#require slow` so that
they don't unnecessarily slow down normal test runs.
2015-08-24 22:23:45 -04:00
Augie Fackler
7a593002d6 run-tests: ignore failed removal of nonexistent installerrs
When running tests with -j100 or so on a large machine, I see this
os.remove call failing semi-regularly. Since it's not really a problem
when the file is already gone, just suppress the error in that case.
2015-08-25 00:40:42 -04:00
FUJIWARA Katsunori
4a75be9bfa run-tests.py: add TESTDIR to PATH if it differs from RUNTESTDIR
Before this patch, `RUNTESTDIR` is added to `PATH`, but `TESTDIR`
isn't.

This doesn't cause any problems, if `run-tests.py` runs in `tests`
directory of Mercurial source tree. In this case, `RUNTESTDIR` should
be equal to `TESTDIR`.

On the other hand, if `run-tests.py` runs in `tests` of third party
tools, commands in that directory should be executed with explicit
`$TESTDIR/` prefix in `*.t` test scripts. This isn't suitable for the
policy "drop explicit $TESTDIR from executables" of Mercurial itself
(see fcb1c7d8c36e).

BTW, fcb1c7d8c36e describes that "$TESTDIR is added to the path" even
though `TESTDIR` isn't added to `PATH` exactly speaking, because
`TESTDIR` and `RUNTESTDIR` weren't yet distinguished from each other
at that time.

This is a one of preparations for issue4677.
2015-07-03 06:56:03 +09:00
FUJIWARA Katsunori
70980837e8 run-tests.py: add RUNTESTDIR to refer tests of Mercurial
Before this patch, there is no way to refer files under `tests` or so
of Mercurial source tree, when `run-tests.py` runs in `tests` of third
party tools. In this case, `TESTDIR` refers the latter `tests`.

This prevents third party tools from using useful tools in Mercurial
source tree (e.g. `contrib/check-code.py`).

This patch adds `RUNTESTDIR` environment variable to refer `tests` of
Mercurial source tree, in which `run-tests.py` now running is
placed. For example, tests of third party tools can refer
`contrib/check-code.py` in Mercurial source tree as
`$RUNTESTDIR/../contrib/check-code.py`.

BTW, for similarity with `TESTDIR` referring `test*s*` directory,
newly added environment variable isn't named as `RUNTEST*S*DIR`. In
addition to it, the corresponded local variable is also named as
`runtestdir`.

This is a one of preparations for issue4677.
2015-07-03 06:56:03 +09:00
FUJIWARA Katsunori
c5c4f4ba0d run-tests.py: execute hghave by the path relative to run-tests.py
Before this patch, `run-tests.py` executes `hghave` by the path
relative to `TESTDIR` (= cwd of `run-tests.py` running).

This prevents third party tools for Mercurial from running
`run-tests.py`, which is placed in `tests` of Mercurial source tree,
in `tests` of own source tree. In such cases, `TESTDIR` refers the
latter `tests`, and `hghave` doesn't exist in it.

This is a one of preparations for issue4677.
2015-07-03 06:56:03 +09:00
Matt Mackall
b597cb9caa tests: add (?) flag for optional lines
When the test engine fails to match output on a line marked with (?),
it will simply continue to the next expected line and try again. This
allows simplifying tests that have either version-specific or
non-fixed behavior, for instance:

  $ coin-flip
  heads (?)
  tails (?)

(There's no form of back-tracking attempted, so optional matches
should be specific.)
2015-05-31 16:59:34 -05:00
Pierre-Yves David
b1a2babd78 devel: rename 'all' to 'all-warnings' (BC)
We have started to isolate extra usecases for developer-only output
that is not a warning. As the section has the fairly generic name
'devel' it makes sense to tuck them there. As a result, 'all' becomes
a bit misleading so we rename it to 'all-warnings'. This will break
some developer setups but the tests are still fine and developers will
likely spot this change.
2015-05-26 14:14:36 -07:00
Augie Fackler
10487ffdd9 run-tests: python3.5 now supports mkdtemp using bytes for paths
Now that http://bugs.python.org/issue24230 is fixed (thanks to Gregory
Smith for that quick response!) we can drop one more ugly hack around
path handling. Tests still pass in 3.5 with this cleaner version, as
well as in 2.6.
2015-05-22 21:19:08 -04:00
Augie Fackler
ab57fc9f4c run-tests: use items() instead of iteritems()
This fixes the python3.5 build. We'll presumably want to build our own
helper function or use 2to3 for this on the main source tree, but for
run-tests we want a single-source version that works in 2.6 and 3.5.
2015-05-22 21:15:52 -04:00
Matt Harbison
ff93ed30c4 run-tests: resurrect the wifexited polyfill (backout afc1c96d7d8c)
Python 2.7.3 on Windows doesn't have os.WIFEXITED, and the test output looked
like this before I interrupted it.

    $ ./run-tests.py --local -j2 -t700
    EEEEEEEEEEEEEEEEEEEEEE
2015-05-18 15:34:42 -04:00
Augie Fackler
5c9b102436 run-tests: replace open-coded .decode()s on paths with a helper (issue4667)
This also cleans up the mkdtemp code mentioned in the previous patch.

At this point, the remaining callsites of .{en,de)code() are in the
following categories:

Handling escaped lines in .t files
-----------------------------------

It seems eminently reasonable to me for us to declare that .t files
are valid utf-8, and that any escape sequences we see in .t files
should be valid unicode_escape sequences.


Making error text safe for cdata blocks for xml error reports
-------------------------------------------------------------

This is a point where we're already basically screwed, and we're
simply trying to do something "good enough" that the xml output will
be vaguely useful to the user. Punting here seems fine, and we should
probably stick to the same encoding here that we used in the previous
section.
2015-05-17 21:47:18 -04:00