Commit Graph

425 Commits

Author SHA1 Message Date
Gregory Szorc
8fab6ea01c run-tests: move err path handling to Test 2014-04-19 20:32:38 -07:00
Gregory Szorc
0dcb1a6ed2 run-tests: handle interrupted in Test.run() 2014-04-19 20:27:18 -07:00
Gregory Szorc
ddc2d7190f run-tests: kill daemons during Test.cleanup()
As a safety precaution, we kill daemons in Test.cleanup(). This is
necessary for a subsequent patch that will reraise KeyboardInterrupt
before killdaemons() runs as part of run().
2014-04-19 20:22:32 -07:00
Gregory Szorc
aa0568676a run-tests: capture reference output in Test.__init__
Reference output should be constant and doesn't need to be computed at
test execution time. We calculate it earlier.

This patch is the first in a mini series that will change how the
TestResult object works.
2014-04-19 18:50:40 -07:00
Gregory Szorc
c3bcf32fc2 run-tests: make globmatch a static method of TTest 2014-04-19 16:14:30 -07:00
Gregory Szorc
1b34005cfc run-tests: make rematch a static method of TTest 2014-04-19 16:13:02 -07:00
Gregory Szorc
19099dc4f1 run-tests: make linematch a static method of TTest
linematch only applies to t tests. It makes sense to move everything t
test related to the TTest class.
2014-04-19 16:11:49 -07:00
Gregory Szorc
df67209088 run-tests: finish moving tsttest() into TTest 2014-04-19 15:37:50 -07:00
Gregory Szorc
044e5b3e56 run-tests: move t test execution from tsttest() to TTest.run()
After this patch, tsttest() only contains output/result processing.
2014-04-19 15:28:31 -07:00
Gregory Szorc
21e213cf15 run-tests: move t test parsing into its own function
Test parsing is somewhat complicated. This patch extracts it into its
own function.

The impetus of this patch is folding tsttest() into the TTest class.
Subsequent patches will continue this work until tsttest() no longer
exists.
2014-04-19 15:19:28 -07:00
Gregory Szorc
4018f371bc run-tests: roll pytest() into PythonTest._run()
Python was the old runner function. It no longer needs to exist since
the PythonTest class took its job.
2014-04-19 14:54:04 -07:00
Gregory Szorc
bd0b5555d2 run-tests: remove threadtmp in Test.cleanup()
threadtmp is an implementation detail. We move the cleanup of this
directory to Test.cleanup() and make the variable internal. The
cleanup function will eventually disappear into unittest machinery.
2014-04-19 14:51:43 -07:00
Gregory Szorc
5b6c781b5d run-tests: allow Test.run() to run multiple times
Test.run() can now be executed multiple times on the same Test instance.
This feature is currently unused and there are no plans to implement it.
The main reason for this work was to refactor testtmp, replacements, and
env to be run-time specific as opposed to Test instance specific.
2014-04-19 14:47:34 -07:00
Gregory Szorc
d9fcd5b2f9 run-tests: capture reference output in TestResult class 2014-04-19 14:09:46 -07:00
Gregory Szorc
c1c96a878a run-tests: give TestResult a skipped attribute 2014-04-19 14:01:18 -07:00
Gregory Szorc
d1e8b83b37 run-tests: pass TestResult into run() 2014-04-19 18:31:22 -07:00
Gregory Szorc
ce51eb2ab0 run-tests: capture execution results in a TestResult class
Some implementation details of test execution still live outside of
Test. These include determining what a result means and cleaning up
after the test.

To move to the world where more of this logic can live inside Test or a
derived object, the logic for test execution needs to be refactored.
Specifically, exception trapping and opportunities for result processing
need to be moved into Test.

This patch starts the process by establishing a TestResult class for
holding the results of a test execution. In order to actually use this
class, exception trapping and execution time recording needed to be
moved into Test.run().
2014-04-19 13:50:25 -07:00
Gregory Szorc
03c657bc26 run-tests: clean up temp directory variables
testtmp is an implementation detail. It didn't need to be exposed to the
world.

threadtmp is derived from count. It is now created as part of the
constructor and mostly hidden from the outside world.
2014-04-19 13:29:26 -07:00
Gregory Szorc
b3a4d844b0 run-tests: move env into Test
Environment variables are an implementation detail of how tests are
executed. This patch moves environment variable logic into Test and
completely hides it from the outside.

With this patch, a Test can be executed with two lines: init + run().
Tests are still single-use and take a more arguments to the constructor
than likely necessary. These will get addressed in subsequent patches.
2014-04-19 13:26:12 -07:00
Gregory Szorc
d49f5e6aff run-tests: move killdaemons into Test.run()
killdaemons() was the only part of runone() looking at env variables. We
move killdaemons() into Test.run() to enable us to fully move env into
Test.
2014-04-19 13:22:52 -07:00
Gregory Szorc
f33e67ce74 run-tests: move replacements and port management into Test
replacements and ports are really implementation details of a Test. They
have been moved to instance variables.
2014-04-19 13:18:55 -07:00
Gregory Szorc
4a6575aeb5 run-tests: move createhgrc() call into Test.run()
createhgrc() is an implementation detail of how tests are run. It makes
sense to move it into Test.run().

Note that this will cause the test execution time to include the
creation of hgrc. The author does not believe this is a significant
change worth worrying about.
2014-04-19 13:11:49 -07:00
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