Commit Graph

403 Commits

Author SHA1 Message Date
Gregory Szorc
c8d17d56b0 run-tests: move createenv() into Test
createenv() is consulting lots of test-specific variables. It makes
sense to attach it to the Test class.
2014-04-19 13:07:05 -07:00
Gregory Szorc
baae441146 run-tests: move replacements generation into Test
The API is a bit funky. Things will look better once all state is
captured in Test.
2014-04-19 13:03:24 -07:00
Gregory Szorc
37bc48e832 run-tests: move testtmp into Test class
This patch starts the process of moving test-specific variables into the
Test class. The ultimate goal is to be able to instantiate a Test with
minimal arguments and to call run() on it without too much thinking.
This will make it much easier to run tests from other contexts. It will
also enable things like running a test multiple times.
2014-04-19 12:54:09 -07:00
Gregory Szorc
b01959b720 run-tests: create classes for representing tests
Currently, the state for an individual test is scattered across a number
of functions and variables. This patch begins a process of isolating a
single test's state into instances of a class. It does this by
establishing a new Test base class and child classes for Python tests
and T tests. The class currently has a run() API that proxies into the
existing "runner" functions. Upcoming patches will move the logic for
each test type into the class.
2014-04-19 12:26:34 -07:00
Yuya Nishihara
50920757c6 run-tests: initialize global variables to suppress pyflakes warning 2014-05-02 18:25:23 +09:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Mads Kiilerich
56bd029861 tests: warn on invalid #if directive 2014-04-13 19:01:00 +02:00
Simon Heimberg
584b6544fe run-tests: test result shows when a failed test could not start a server
Failing to start a server happens regularly, at least on windows buildbot.
Such a failure often has nothing to do with the test, but with the environment.
But half the test output can change because some data is missing. Therefore this
is worth an extended error message.

Detect the server failure in the diff output because it is most reliable
there. Checking the output only does not show if the server failure was
expected.

 Old failure message when server start failed:
Failed test-serve.t: output changed

 New message:
Failed test-serve.t: serve failed and output changed
2013-11-25 22:00:46 +01:00
Gregory Szorc
a283450c0f run-tests: allow test paths in other directories
Previously, test paths were assumed to be in the same directory and
wouldn't have a directory component. If a path with a directory
component was specified, it would be filtered out. This change allow
paths to contain directories. This in turn allows tests from other
directories to be executed.

Executing tests in other directories may break assumptions elsewhere in
the testing code. However, on initial glance, things appear to "just
work." This approach of running tests from other directories is
successfully being used at
https://hg.mozilla.org/hgcustom/version-control-tools/file/7085790ff3af/run-mercurial-tests.py
2014-03-24 22:12:37 -07:00
Gregory Szorc
c299dbb10c run-tests: allow option parser to be extended
This patch moves the OptionParser population into its own function so
consumers may modify the OptionParser before arguments are evaluated.
This will allow consumers to add custom options, set different defaults,
etc.
2014-03-24 21:52:28 -07:00
Gregory Szorc
f33d6c4e65 run-tests: use return values instead of sys.exit 2014-03-24 21:41:56 -07:00
Gregory Szorc
2ae9bd8d6c run-tests: Pass arguments into argument parser
Before, arguments were not passed into the optparse.OptionParser
instance and were coming from sys.argv. This patch enables consumers to
define the list of arguments to parse without having to adjust sys.argv.
2014-03-24 21:37:33 -07:00
Mads Kiilerich
6a1dd62dee tests: add run-tests --changed option for running tests changed in revisions
Convenient when polishing patches and changing details of how they change test
output.

This will probably break in weird ways for revsets with special quoting ... but
it is good enough for run-tests.

Usage example:
  yes | ./run-tests.py -li --changed qparent
2014-02-28 02:09:00 +01:00
Mads Kiilerich
9617b497ff tests: small refactoring of run-tests' handling of tests list 2014-03-19 00:19:54 +01:00
Augie Fackler
1960bb215f run-tests: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:19:43 -04:00
Matt Mackall
66c8bd54e8 extensions: remove the inotify extension (BC)
This extension has always had correctness issues and has been
unmaintained for years. It is now removed in favor of the third-party
hgwatchman which is maintained and appears to be correct.

Users with inotify enabled in their config files will fall back to
standard status performance.
2014-03-01 16:20:15 -06:00
Simon Heimberg
66d9266de8 run-tests: fixed warn detection on failures with too many output
The state "warned" was reported too often. The problem fixed here is that
warnonly was only reset when a line did not match. When there was a line too
much, warnonly remained set.
Fix this by setting more states to warnonly.

More negative testing (testing on result "Failed") has been done this time.
2014-02-16 23:41:24 +01:00
Simon Heimberg
f532046c29 run-tests: fixed warn detection on detecting warn only for lines
The state "warned" was reported too often. The main problem was that
"False == 0" is true in python. Therefore use an empty string instead of 0
for reporting warn only for a line.
The other problem is fixed in the next patch.
2014-02-16 23:36:02 +01:00
Siddharth Agarwal
1f2e1568a5 run-tests.py: work when --with-hg is set to system hg
Previously we'd always assume that --with-hg is a script in a user directory,
and would write out a 'python' symlink to the same location. That didn't work
if --with-hg was set to a system installation of hg, e.g. /usr/bin/hg.

Introduce a TMPBINDIR directory which is used to write out the python symlink.
2014-02-19 21:32:14 -08:00
Patrick Mezard
5bf3ef6c1b run-tests: fix heredoctest for out-of-tree extensions
heredoctest.py directory must be in python path to use heredoctest (>>>) in
out-of-tree extension tests like:

  $ cd ext/tests
  $ python /some/hg/install/tests/run-tests.py test-ext.t
2014-02-15 15:28:32 +01:00
Simon Heimberg
b2a439bb78 run-tests: unnecessary globs also count as warnings
When a glob is unnecessary, now there's a diff output and 'run-tests.py -i'
works for accepting the output.
On windows, some tests which have "passed" currently (with some info lines
printed) will now be reported as "warned". (I recommend to recognize "warned"
by buildbot before applying this patch.)
2014-02-13 08:29:44 +01:00
Simon Heimberg
1e51f26c6e run-tests: report a test as warned when only missing globs
On windows, some test reported as failed will now be reported as "warned".
2014-02-13 08:27:53 +01:00
Simon Heimberg
434d0f2c98 run-tests: add possibility for test-runners to report a "warned" test result
A test result is recognized as "warned" when the test runner returns the exit
code False. (False is similar to 0, which is reporting a command has run
sucessfully.)

The only difference in display is that the failure message while running writes
"Warning:" instead of "ERROR:". The diff output is the same as when the test
fails. Runing "run-tests.py -i" asks to accept the changed result also for
tests reported as "warned".

When running tests, a "warned" test would look like this:
..
 --- xxxx\tests\test-something.t
 +++ xxxx\tests\test-something.t.err
@@ -1279,7 +1279,7 @@
   $ echo anything
   $ hg commit -S -m whatever
   committing subrepository s
-  committing subrepository s/sbs
+  committing subrepository s/sbs (glob)
   warning: something happened
   committing subrepository t
   $ echo something

Warning: xxxx\tests\test-sOMETHING.t output changed
~.s...s...s..


Reporting a test result as "warned" will be used in following patches.
2014-02-13 08:26:13 +01:00
Simon Heimberg
11e4ef2216 run-tests: separate exit code when no failed tests but warned ones
This can be used by buildbot to set the result "warnings" instead of "failed".
2014-02-13 08:17:39 +01:00
Simon Heimberg
8864ac070e run-tests: introduce 'warned' as test result
While running, a test resulting in 'warned' is shown as '~'.
Test results with state warned are listed between the skipped and the failed
tests. Example:
Skipped test-revert-flags.t: missing feature: executable bit
Skipped test-inotify-lookup.t: missing feature: inotify extension support
Warned test-something.t: output changed
Failed test-largefiles.t: output changed
Failed test-subrepo.t: output changed
# Ran 11 tests, 2 skipped, 1 warned, 2 failed.


The test result "warned" will be used in later patches.
2014-02-13 08:14:54 +01:00
Simon Heimberg
9463ba6189 run-tests: handle sys.exit in main function 2014-02-13 08:02:06 +01:00
Simon Heimberg
073dd453ab run-tests: remove unnecessary variable initialisation
ret is always set before it is used, so remove ret = 0
2014-02-13 07:29:28 +01:00
Simon Heimberg
9d8139803a run-tests: fix typo and print out failing line
Instead of stripping the newline and printing the line, only the newline was
printed.
The output on buildbot will make more sense now.
2014-02-11 01:15:07 +01:00
Simon Heimberg
14f515afb4 run-tests: print more information on unnecessary glob matching
Extend the message with the test name and the approximate line number. (The
line number is the one of the command producing the output.)
Finding the line to fix is easier now.

old message:
......
Info, unnecessary glob: at a/b/c (glob)
..

new message:
......
Info, unnecessary glob in test-example.t (after line 9): at a/b/c (glob)
..


The test result is still pass as before.
2014-01-16 12:08:57 +01:00
Simon Heimberg
2967b15687 run-tests: suggest to append glob when only path sep does not match
When the line does not match because of \ instead of / (on windows), append
(glob) in the expected output.
This allows to rename test-bla.t.err to test-bla.t for getting a correct
output. This worked for other failures like missing (esc), but not here.

  Output example (only +- lines of diff):
Before:
-  path/with/local/sep
+  path\\with\\local/sep
Now:
-  path/with/local/sep
+  path/with/local/sep (glob)
2014-01-16 12:08:29 +01:00
Simon Heimberg
ee6f6f78e3 run-tests: test each line matching function on its own
This has several advantages.
 * Each match function can return some information to the caller runone (used in
   the next patch).
 * It is not checked that the line ends in " (glob)" when rematch() returns
   false.
 * And it looks more readable.
2014-01-16 12:06:49 +01:00
Simon Heimberg
4367a66877 run-tests: set the thread name to the test name for info on error
This does not happen when running normal. But when fiddling around with
the test infrastructure, this helps a lot.

  Old traceback messge
Exception in thread Thread-7:
Traceback (most recent call last):
...

  new traceback message
Exception in thread test-something.t:
Traceback (most recent call last):
...
2014-01-16 11:26:54 +01:00
Simon Heimberg
eff53c5d86 run-tests: report tests as failed when run-test raises an error
Before no message was returned to the main thread. No result was registered
and no new thread was started.
This does not happen when running normal. But when fiddling around with
the test infrastructure, this helps a lot.
2014-01-16 18:55:35 +01:00
Simon Heimberg
d4d6543b3a run-tests: better check for python version
Compare version by using pythons tuple comparison. So we do not match on python
3.0 or newer.
2013-11-25 22:00:46 +01:00
Mads Kiilerich
ca46558bdd tests: python hash seed is only relevant after failures - otherwise keep quiet 2013-11-17 10:59:35 -05:00
Sean Farley
2ced3aebc5 run-tests: remove files that we potentially create outside of $TMPDIR 2013-11-15 22:57:11 -05:00
Sean Farley
1c3131bb1b run-tests: remove code that creates a dummy 'diffstat'
This was introduced in 23816898bed5 for an old test that is no longer the same.
2013-11-15 22:56:08 -05:00
Mads Kiilerich
8c414ba152 run-tests: place the .t shell script next to $TESTTMP and with a useful name
--keep can thus keep it around - very convenient for debugging.
2013-10-03 14:50:47 +02:00
David Soria Parra
72600cc4d7 shelve: add a shelve extension to save/restore working changes
This extension saves shelved changes using a temporary draft commit,
and bundles the temporary commit and its draft ancestors, then
strips them.

This strategy makes it possible to use Mercurial's bundle and merge
machinery to resolve conflicts if necessary when unshelving, even
when the destination commit or its ancestors have been amended,
squashed, or evolved. (Once a change has been unshelved, its
associated unbundled commits are either rolled back or stripped.)

Storing the shelved change as a bundle also avoids the difficulty
that hidden commits would cause, of making it impossible to amend
the parent if it is a draft commits (a common scenario).

Although this extension shares its name and some functionality with
the third party hgshelve extension, it has little else in common.
Notably, the hgshelve extension shelves changes as unified diffs,
which makes conflict resolution a matter of finding .rej files and
conflict markers, and cleaning up the mess by hand.

We do not yet allow hunk-level choosing of changes to record.
Compared to the hgshelve extension, this is a small regression in
usability, but we hope to integrate that at a later point, once the
record machinery becomes more reusable and robust.
2013-08-29 09:22:13 -07:00
Augie Fackler
3f08f4aa32 run-tests: find mercurial path with syntax valid on both py2 and py3 2013-09-19 15:29:28 -04:00
Augie Fackler
a4c5cf3750 run-tests: if run by python3, execute setup.py with --c2to3 2013-09-19 15:29:04 -04:00
Simon Heimberg
96b55afc5a run-tests: only check the common criteria once per test 2013-07-26 21:18:40 -04:00
Matt Mackall
d64dd7b443 run-tests: backout a71b92f5b8d5 line endings change
It made the windows buildbot sad.
2013-07-18 23:22:59 -05:00
Brendan Cully
b22788d1aa run-tests: revert previous commit, run() waits after a timeout 2013-07-18 09:42:44 -07:00
Brendan Cully
ec9f9a7a0f run-tests: reap timed-out zombies 2013-07-18 09:39:01 -07:00
Simon Heimberg
690fb7f82d run-tests: generally handle line endings on windows by re
Recently this regexp was only appended when running a python test. When running
a tsttest there was a separate handling for each line type. Simplify and unify
this.
2013-07-13 23:58:01 +02:00
Simon Heimberg
2fc2f7ad2e run-tests: test for os.altsep instead of os.name when checking \ for /
This tells more explicitly what it is about
2013-07-13 23:57:55 +02:00
Brendan Cully
4e99027450 run-tests: replace popen locking with a noop _cleanup handler on py24
This also avoids the race condition, and isn't detrimental to job scheduling.
2013-07-17 13:42:08 -07:00
Brendan Cully
f3860d2150 run-tests: only lock Popen wait/poll on python 2.4
It can cause scheduling bubbles and is not necessary on newer pythons.
2013-07-17 13:02:12 -07:00
Brendan Cully
90d44a096b run-tests: lock popen wait/poll
In python2.4, any call to Popen() may attempt to wait on any active
process, and wait is not thread-safe. Make it thread-safe.
See http://bugs.python.org/issue1731717 for details.
2013-07-17 12:45:12 -07:00