Commit Graph

738 Commits

Author SHA1 Message Date
Gregory Szorc
5d72ba5d0e run-tests: move string escaping to TTest
With this patch, TTest is almost fully self-contained and extractable.
Only logging functions remain outside of its class.
2014-04-20 10:34:52 -07:00
Gregory Szorc
29c42e357d run-tests: add some docstrings 2014-04-20 10:28:35 -07:00
Gregory Szorc
5be656d402 run-tests: move createhgrc into Test 2014-04-20 10:24:00 -07:00
Gregory Szorc
f91c5a5105 run-tests: move SKIPPED_PREFIX and FAILED_PREFIX into TTest 2014-04-20 10:19:58 -07:00
Gregory Szorc
a67c76a563 run-tests: move SKIPPED_STATUS into Test class 2014-04-20 10:16:36 -07:00
Gregory Szorc
3cae671831 run-tests: move parsehghaveoutput() into TTest
This patch starts a sequence of patches that will try to isolate
everything related to t tests into the TTest class.
2014-04-20 10:14:25 -07:00
Gregory Szorc
8d7902d08f run-tests: make some methods of TestRunner internal 2014-04-20 10:11:46 -07:00
Gregory Szorc
77377eb9f9 run-tests: eliminate main() 2014-04-20 10:09:23 -07:00
Gregory Szorc
f77a2632fd run-tests: move option parser logic to TestRunner.run() 2014-04-20 10:08:33 -07:00
Gregory Szorc
e8679e7082 run-tests: move umask into TestRunner.run()
We now properly restore the umask as well, since run() tries to clean up
after itself.
2014-04-20 10:06:19 -07:00
Gregory Szorc
1a7b678d41 run-tests: move checktools into TestRunner.run() 2014-04-20 10:05:00 -07:00
Gregory Szorc
9b509906ec run-tests: move test discovery into TestRunner.run() 2014-04-20 10:04:15 -07:00
Gregory Szorc
015f85c261 run-tests: move test shuffling and sorting into TestRunner 2014-04-20 10:03:08 -07:00
Gregory Szorc
6b2b768e30 run-tests: assign testdir in TestRunner 2014-04-20 10:00:59 -07:00
Gregory Szorc
f10ceaaa22 run-tests: move hash seed logic to TestRunner 2014-04-20 09:59:01 -07:00
Gregory Szorc
c5b81eb209 run-tests: move tmpdir calculations into TestRunner 2014-04-20 09:58:26 -07:00
Gregory Szorc
3a9dcd2480 run-tests: move more path calculations into TestRunner 2014-04-20 09:57:02 -07:00
Gregory Szorc
c63c3fe0f7 run-tests: move pypath manipulation into TestRunner 2014-04-20 09:54:28 -07:00
Gregory Szorc
d8efe9acf0 run-tests: establish TestRunner.run()
(amended by mpm to remove environ cleanup - unrelated change that
breaks on Solaris)
2014-04-20 09:49:33 -07:00
Gregory Szorc
e9f87a494b run-tests: move program searching into TestRunner 2014-04-20 09:44:39 -07:00
Gregory Szorc
85852466ca run-tests: allow TestRunner to be passed into main()
This allows 3rd parties to specify a custom TestRunner. This is useful
for providing your own test discovery mechanism, for example.
2014-04-20 09:40:27 -07:00
Gregory Szorc
8b959d83f2 run-tests: move test discovery logic into a function
The new function is easily monkeypatchable. This facilitates more
advanced test discovery by 3rd parties such as extensions.
2014-04-20 00:23:06 -07:00
Gregory Szorc
27d037f441 run-tests: move scheduletests() into TestRunner 2014-04-20 00:12:26 -07:00
Gregory Szorc
eec6cde13e run-tests: move abort global to TestRunner 2014-04-20 00:10:06 -07:00
Gregory Szorc
25b7330a18 run-tests: move runtests() into TestRunner 2014-04-20 00:06:30 -07:00
Gregory Szorc
e57adc8c20 run-tests: move results global into TestRunner 2014-04-20 00:03:32 -07:00
Gregory Szorc
ff5048b39c run-tests: move times global into TestRunner 2014-04-19 23:59:06 -07:00
Gregory Szorc
1b4a48f3dc run-tests: move gettest() into TestRunner 2014-04-19 23:53:23 -07:00
Gregory Szorc
2703caf446 run-tests: move outputcoverage() into TestRunner 2014-04-19 23:49:23 -07:00
Gregory Szorc
49cdc11656 run-tests: move outputtimes() into TestRunner 2014-04-19 23:47:59 -07:00
Gregory Szorc
f60ca60f88 run-tests: move checkhglib into TestRunner 2014-04-19 23:44:56 -07:00
Gregory Szorc
105c9c2fc1 run-tests: move installhg() into TestRunner 2014-04-19 23:43:00 -07:00
Gregory Szorc
023fa479ff run-tests: move createdfiles out of a global and into TestRunner 2014-04-19 23:39:38 -07:00
Gregory Szorc
a24163eef4 run-tests: move usecorrectpython() into TestRunner 2014-04-19 23:38:10 -07:00
Gregory Szorc
88e6be733b run-tests: move cleanup() into TestRunner 2014-04-19 23:35:27 -07:00
Gregory Szorc
e74d6a9170 run-tests: add options to runner 2014-04-19 23:33:44 -07:00
Gregory Szorc
691c3d4a63 run-tests: add options to runner 2014-04-19 23:28:59 -07:00
Gregory Szorc
fbb4e07860 run-tests: move COVERAGE_FILE out of a global 2014-04-19 23:27:11 -07:00
Gregory Szorc
cb55575cbf run-tests: move PYTHONDIR out of a global 2014-04-19 23:26:15 -07:00
Gregory Szorc
cd540cf8ab run-tests: move TMPBINDIR out of a global 2014-04-19 23:24:39 -07:00
Gregory Szorc
0b30c04fca run-tests: move BINDIR out of a global 2014-04-19 23:22:47 -07:00
Gregory Szorc
e4684a44f0 run-tests: move INST out of a global 2014-04-19 23:20:42 -07:00
Gregory Szorc
985af7905a run-tests: move HGTMP out of a global 2014-04-19 23:19:23 -07:00
Gregory Szorc
43a68f701f run-tests: move TESTDIR out of a global
This patch starts the process of removing global variables from
run-tests.py. The goal of this is to make it easier to run tests
differently without having to concern yourself with global state.
2014-04-19 23:15:24 -07:00
Gregory Szorc
6ac2fa2ac5 run-tests: establish a class to hold testing state 2014-04-19 23:07:17 -07:00
Gregory Szorc
a557fd6847 run-tests: refactor runone() into gettest() and scheduletests()
runone() has been removed. Replacing it are gettest() (which returns a
Test instance) and a small amount of boilerplate in scheduletests().
2014-04-19 22:02:55 -07:00
Gregory Szorc
cf638dcc58 run-tests: move computation of test paths into Test.__init__ 2014-04-19 21:53:15 -07:00
Gregory Szorc
2c78c23435 run-tests: move logging of test start into Test.run() 2014-04-19 21:50:23 -07:00
Gregory Szorc
0e7ab8a4df run-tests: remove remaining uses of TestResult 2014-04-19 21:21:57 -07:00
Gregory Szorc
a9a228cd32 run-tests: move output writing to Test.run() 2014-04-19 21:17:39 -07:00
Gregory Szorc
23754a084d run-tests: move err file saving to Test.run() 2014-04-19 21:14:31 -07:00
Gregory Szorc
d8e59715bf run-tests: emit exception failure result from Test.run() 2014-04-19 21:10:22 -07:00
Gregory Szorc
ac40d2296a run-tests: move test name filter to Test.run() 2014-04-19 21:08:03 -07:00
Gregory Szorc
266111b2d1 run-tests: move keyword processing into Test.run() 2014-04-19 21:05:50 -07:00
Gregory Szorc
d1cef4a6a1 run-tests: move retesting result to Test.run() 2014-04-19 21:04:08 -07:00
Gregory Szorc
e8004cbf37 run-tests: move blacklist skipping to Test.run() 2014-04-19 21:02:51 -07:00
Gregory Szorc
29ec1e08f4 run-tests: check for test file existence in Test.run()
We delay this a little bit. But it shouldn't really matter when the
check is performed.
2014-04-19 21:00:24 -07:00
Gregory Szorc
54e9611a41 run-tests: move remaining result processing to Test.run() 2014-04-19 20:53:45 -07:00
Gregory Szorc
49fbb46418 run-tests: move output difference processing to Test.run() 2014-04-19 20:52:58 -07:00
Gregory Szorc
fe13f7598d run-tests: generate timeout result in Test.run() 2014-04-19 20:48:16 -07:00
Gregory Szorc
3573cbd388 run-tests: add skip processing to Test 2014-04-19 20:47:14 -07:00
Gregory Szorc
d792278ce6 run-tests: move fail() into Test
The code was changed slightly as part of the migration to make use of
appropriate variables and modern Python conventions.
2014-04-19 20:41:08 -07:00
Gregory Szorc
42a72930a7 run-tests: move success() into Test 2014-04-19 20:35:54 -07:00
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
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
Matt Mackall
14f333f579 run-tests: patch over py2.4 proc.wait() race 2013-07-16 12:44:11 -05:00
Simon Heimberg
8a32578a00 cleanup: remove unused imports
detected by pyflakes
2013-06-13 01:36:58 +02:00
simon@laptop-tosh
e5622bbc0e run-tests: sort missing files first instead of raising an error
sort first for early telling typos in test names
2013-06-11 23:39:48 +02:00
simon@laptop-tosh
975f5dea4c run-tests: call Threads constructor with keyword arguments
This is suggested in the python documentation
(on http://docs.python.org/2/library/threading.html#thread-objects)
2013-06-09 16:49:08 +02:00
simon@laptop-tosh
400b5ef2b9 run-tests: ignoring tests works again
running with --retest did not work anymore because runone still returned None
for this case. But this is not allowed since a204317f039b.
2013-06-09 16:42:55 +02:00
Matt Mackall
2a02cc28af run-tests: simplify interrupted message 2013-06-07 16:04:11 -05:00
Matt Mackall
df0aab998a run-tests: remove spurious disable of --time with --debug 2013-06-07 15:58:14 -05:00
Matt Mackall
5a359facfe run-tests: always gather runtimes 2013-06-07 15:56:16 -05:00
Simon Heimberg
cbe95e49e5 run-tests: when interrupted report time in failure message
When --time is specified, the interruption message of an interrupted test is
extended with the time the test has run

INTERRUPTED: /path/to/tests/test-example.t (after 513 seconds)
2013-06-05 22:05:29 +02:00
Simon Heimberg
3d444f656b run-tests: report interrupted tests
When the test run is aborted, a message is printed for each interrupted test.
This is helpful when a test is hanging.

example failure message:
INTERRUPTED: /path/to/tests/test-example.t

The message can appear before or after the line with the number of tests
2013-06-05 22:05:02 +02:00
Simon Heimberg
43548443c6 run-tests: open hgrc file only for writing
The file is not read here. Opening with "w+" is unnecessary.
2013-06-05 22:42:43 +02:00
Matt Mackall
bf221e220d run-tests: make --noskips work 2013-06-06 14:40:26 -05:00
Matt Mackall
4ee271c45d run-tests: add --loop support
This makes it easy to run tests repeatedly at high loads to look for test failures.
2013-06-02 18:09:06 -05:00
Matt Mackall
177f6f2cb0 run-tests: --interactive and --jobs no longer conflict 2013-06-02 17:58:51 -05:00
Matt Mackall
c5fd75f600 run-tests: sort certain slow tests earlier by keyword
There are a few tests that evade the size heuristic
2013-06-02 17:58:49 -05:00
Matt Mackall
8481b7ff76 run-tests: drop unused resultslock 2013-06-02 17:57:37 -05:00
Matt Mackall
438cc52b80 run-tests: drop options.child and users 2013-06-02 17:57:36 -05:00
Matt Mackall
66a2eb9cb9 run-tests: remove runchildren, now unused 2013-06-02 17:56:53 -05:00
Matt Mackall
9f730ea353 run-tests: schedule largest tests first 2013-06-02 17:56:51 -05:00
Matt Mackall
3a93b9c7d3 run-tests: introduce thread scheduler 2013-06-02 16:58:22 -05:00
Matt Mackall
532173d915 run-tests: use count to calculate port to use
This will keep threads from using the same server ports
2013-06-02 16:55:19 -05:00
Matt Mackall
8fbe5c7e8f run-tests: introduce threadtmp directory 2013-06-02 16:38:15 -05:00
Matt Mackall
c9da438759 run-tests: add abort flag
This will be used to help threads clean up gracefully
2013-06-02 16:29:35 -05:00
Matt Mackall
cc7f14311d run-tests: move more variables to env 2013-06-02 16:29:22 -05:00
Matt Mackall
fc271a759c run-tests: simplify env deletion 2013-06-02 16:29:20 -05:00
Matt Mackall
488a78e3ca run-tests: move most of remaining environment tweaks 2013-06-02 16:22:51 -05:00
Matt Mackall
95e4c8b6bf run-tests: move environment creation to a separate function 2013-06-02 16:22:51 -05:00
Matt Mackall
19ab24f165 run-tests: move HGRCPATH to env 2013-06-02 16:22:51 -05:00
Matt Mackall
5fc51a32ce run-tests: move DAEMON_PIDS to env 2013-06-02 16:22:51 -05:00
Matt Mackall
8c77edfd66 run-tests: move HGPORT setting to env 2013-06-02 16:22:34 -05:00
Matt Mackall
f3e5fe5277 run-tests: write tmp paths into env copy 2013-06-02 15:33:41 -05:00
Matt Mackall
5417598833 run-tests: use env dict to kill daemons 2013-06-02 14:04:55 -05:00
Matt Mackall
fc7662fd0d run-tests: add env dict to isolate test environment 2013-06-02 13:45:08 -05:00
Matt Mackall
38303ad1d7 run-tests: remove some unnecessary globals 2013-05-27 15:24:19 -05:00
Matt Mackall
65bbf02e19 run-tests: add a log function 2013-05-24 14:30:43 -05:00
Matt Mackall
0bef60f271 run-tests: make vlog a proper function 2013-05-24 14:30:43 -05:00
Matt Mackall
60b62579bb run-tests: unify marks and result codes 2013-05-24 14:30:43 -05:00
Matt Mackall
c97fde7db9 run-tests: change return code of runone 2013-05-24 14:30:35 -05:00
Matt Mackall
9dccd87998 run-tests: regroup some initialization checks 2013-05-24 13:53:56 -05:00
Matt Mackall
fde01215f9 run-tests: fix a path existence check 2013-05-24 13:52:05 -05:00
Matt Mackall
8bd32fc6fa run-tests: regroup some variable initialization 2013-05-24 13:51:20 -05:00
Matt Mackall
037d2bf78a run-tests: regroup nested functions 2013-05-24 13:48:25 -05:00
Matt Mackall
f100d35303 run-tests: regroup temp dir creation 2013-05-24 13:47:17 -05:00
Matt Mackall
2180875dae run-tests: pull hgrc creation out as function 2013-05-24 13:41:20 -05:00
Matt Mackall
027e99d223 tests: simplify handling of unknown test types 2013-05-24 13:34:22 -05:00
Matt Mackall
506ab062fd run-tests: filter out non-tests from default list 2013-05-24 13:31:44 -05:00
Matt Mackall
a7060ace56 run-tests: make a table of test types 2013-05-24 13:23:19 -05:00
Matt Mackall
8448d1f531 run-tests: don't need to test shebang any more 2013-05-24 13:02:00 -05:00
Siddharth Agarwal
ff171329ff run-tests: when running in parallel, delete tmpdirs immediately
This is especially important if extensions that use inotify are enabled,
because it's very easy to hit the inotify max_user_instances limit without
this.
2013-05-03 15:18:21 -07:00
Mads Kiilerich
048869f652 run-tests: introduce --random for running tests in random error
This is convenient when investigating failures one by one to avoid running the
same fixed tests first every time.
2013-04-17 03:41:34 +02:00
Simon Heimberg
b13fb73963 run-tests: only sort files when not given as argument
os.listdir returns the files in any order. This has to be sorted.
But when given as argument, the user should be allowed to set any order.

This restores the behaviour before 9848a94e2a.
2013-03-21 08:56:21 +01:00
Durham Goode
47346e366e tests: fix test-profile to not depend on HGPROF environment variable
The test-profile test would fail if the user had HGPROF set to another
profiler in their environment.  This fix makes the test independent of
that environment variable.

Reverts the previous attempt to fix this, which was not cross platoform.
2013-03-12 10:37:48 -07:00
Simon Heimberg
bf363c5722 tests: inform on Windows about unnecessary glob lines
When glob lines directly match on windows, "/" (and not "\") was output in the
path on the line. No glob matching is necessary in this case.

The test output will look like this (when 5 tests have passed and no 4 has an
unnecessary glob):
...
Info, unnecessary glob: info about some/thing (glob)
..
2012-10-15 23:28:45 +02:00
Simon Heimberg
5a3ca8f2da tests: quickly check if the glob line already matches the output
This happens when a path with "/" as only glob char is matched on a non windows
platform. (Currently one third of all glob matches.)
The slowdown on windows and the speedup on other os are neglectable.
2013-02-13 21:58:52 +01:00
Pierre-Yves David
f22102a0c8 test: display used python hash seed
We keep using a random seed for each run, but we "compute" it ourself to be able
to reproduce a failed test run.
2013-01-30 01:24:04 +01:00
Simon Heimberg
246a2ad9d9 run-tests: do not fail on empty tsttest file
Initialize n for not failing on empty tsttest files.
2012-10-24 23:09:31 +02:00
Mads Kiilerich
e8e2c1e1fe run-tests.py: inherit PYTHONHASHSEED from environment if set
This makes it possible to fix the seed by using for instance
  PYTHONHASHSEED=7 ./run-tests.py ...

This can be very convenient when trying to debug problems that are influenced
by hash values. Try different seed values until you find one that triggers the
bad behaviour and then keep that while debugging.

The value 0 will restore default Python behavior and disable randomization.
2013-01-29 20:03:51 +01:00
Mads Kiilerich
77be3a8c23 run-tests.py: don't let hg run interactively in debug mode
In normal test mode stdin is closed and hg is thus not interactive. In --debug
mode stdin is inherited from the running console and to the tests, and hg could
thus wait in prompts when running on Windows.

See http://selenic.com/pipermail/mercurial-devel/2013-January/047548.html .

Instead set ui.interactive=False to make Mercurial non-interactive. Other
commands might still work differently in the --debug environment.

This should solve the problem with hg waiting for input but still make it
possible to add --debugger to hg in a test and run run-tests.py with --debug.
2013-01-18 01:23:51 +01:00
Mads Kiilerich
bc377e8673 run-tests.py: backout "don't use console for stdin when running in debug mode"
3951b91555f7 caused that some kind of interactive debugging no longer was
possible - such as running hg with --debugger in a test run with run-tests.py
--debug .
2013-01-18 01:16:16 +01:00
Mads Kiilerich
8a6ac13827 tests: run with PYTHONHASHSEED=random
Python set and dict iteration order is in principle undefined but usually
'quite stable'. Setting PYTHONHASHSEED=random will make the iteration order
more random in Python 2.6.8 and 2.7.3 and where it has been backported. This
can thus help spot dependencies on undefined behaviour and prevent future
problems.
2013-01-15 23:30:10 +01:00
Bryan O'Sullivan
a6ed57115c run-tests: exit cleanly if parallel run is interrupted
If interrupted while running with "--jobs N", run-tests asynchronously
spewed a bunch of output and backtraces from both the master and
slave processes, leaving the terminal full of goop. This patch makes
it behave more sensibly.
2013-01-15 13:33:28 -08:00
Mads Kiilerich
1c79de5503 run-tests.py: fix handling of symlink to the right python
Before: a symlink for python in BINDIR was sometimes created, but it was never
updated when a different Python was used and it was never removed. An invalid
python could thus be left around and used when testing with --local.

Now: the symlink is removed when wrong and created when necessary.

The mechanism for finding the right name (python or python.exe) also had to be
simplified and made more explicit.
2013-01-07 02:14:41 +01:00
Mads Kiilerich
6298fa2cbc run-tests.py: don't use console for stdin when running in debug mode
Tests would wait for input instead of using non-interactive mode.
2013-01-07 02:00:43 +01:00
Mads Kiilerich
d68f8e1916 tests: make hghave and run-tests exit on unknown feature requirements 2013-01-07 02:00:43 +01:00
Bryan O'Sullivan
b9868468a6 run-tests: fix whitespace nonsense 2012-12-12 15:17:18 -08:00
Bryan O'Sullivan
d3fb3d216e merge with mpm 2012-12-12 15:12:28 -08:00
Bryan O'Sullivan
5b99de5a51 run-tests: on windows, put correct python at front of PATH
The older approach of trying to copy the python executable into the test
directory was doomed to fail.

There remains one weakness with this approach: if you've run "make local",
tests may pick up the wrong extension DLLs from inside the source tree. I
don't know why this happens.

A reasonable workaround for now is to test either using --local or with
a working directory that does not contain built DLLs.
2012-12-12 14:52:58 -08:00
Siddharth Agarwal
7451427eba run-tests: fix exename on Windows 2012-12-11 15:38:42 -08:00
Bryan O'Sullivan
9547883e85 run-tests: support running tests in parallel on windows
Previously, we used os.spawnvp, which doesn't exist on Windows, and
isn't needed anyway (the command line begins with an absolute path).

We also need a slightly more convoluted way to wait for processes
without specifying an order on Windows, as it lacks os.wait.
2012-12-11 15:13:23 -08:00
Bryan O'Sullivan
f09ee98abc run-tests: use correct python safely under --jobs 2012-12-10 12:14:55 -08:00
Bryan O'Sullivan
1fda6e9b5e run-tests: check for the correct python when starting 2012-12-10 12:09:02 -08:00
Bryan O'Sullivan
ae96fc1e0d run-tests: use correct python when run with --local 2012-12-10 12:07:42 -08:00
Mads Kiilerich
eb895c5533 tests: kill daemons early, making breaking at "Accept" prompt safe 2012-12-09 23:33:16 +01:00
Bryan O'Sullivan
ad58c7ca08 run-tests: fix an unnoticed check-code violation 2012-11-27 13:09:05 -08:00
Bryan O'Sullivan
d0279e495a run-tests: add a --compiler option
Without this option, it is not possible to run the test suite on Windows
using mingw's gcc as the compiler.
2012-11-27 11:18:33 -08:00
Bryan O'Sullivan
6fbbd59476 run-tests: make build command line less intimidating
Use a dict for parameters to the format string, instead of a
ridiculous number of positional parameters.
2012-11-27 11:18:31 -08:00
Matt Mackall
0dddda7cc8 run-tests: backout b3100dcfd155
This deleted work in progress to eliminate child processes for -j.
2012-11-14 18:08:39 -06:00
Siddharth Agarwal
e710e102e4 run-tests.py: remove runqueue's results parameter since it is now a global 2012-11-08 14:10:04 -08:00
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
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
Martin Geisler
d899298b13 run-tests: remove check on --shell argument
No shell is needed when executing Python tests and finding a good
shell might be difficult/impossible on some platforms (e.g., Windows).
2011-05-09 17:20:15 +02:00
Idan Kamara
cc5617ae4e run-tests: take the basepath when constructing the test temp dir
so it's possible to run tests that are outside the test/ dir
2011-05-07 21:01:15 +03:00
Idan Kamara
382db50197 run-tests: compare absolute paths in _checkhglib 2011-05-07 20:56:43 +03:00
Martin Geisler
4a2bc65e8a run-tests: add --shell command line flag
This makes it easy to test with, say, both /bin/bash and /bin/dash
instead of changing the system-wide /bin/sh.
2011-05-05 20:04:49 +02:00
Martin Geisler
027d8985b0 run-tests: use type of default to convert environment variable
Before, defaults could only be integers, they can now also be strings,
floats and what have you.
2011-05-05 20:03:43 +02:00
Augie Fackler
c62bb34caf run-tests.py: correctly handle list options with parallel tasks 2011-05-04 10:39:10 -05:00
Augie Fackler
3d09b5a236 run-tests: add flag to provide extra hgrc options for test runs 2011-05-01 08:00:25 -05:00
Idan Kamara
b6a9ab1966 run-tests: print a new line before writing the diff 2011-04-30 15:20:27 +03:00
Idan Kamara
56c14a6116 run-tests: don't count test as succeeded if it failed
regressed around 96f44260c0a0
2011-04-29 20:29:22 +03:00
Matt Mackall
390ca3b942 run-tests: do chdir for tests under a lock for thread safety 2011-04-25 17:01:34 -05:00
Matt Mackall
8e4d999508 run-tests: add iolock to vlog 2011-04-25 16:17:08 -05:00
Patrick Mezard
6be95e16f7 run-tests: display diff before prompting with --interactive 2011-04-25 18:42:31 +02:00
Matt Mackall
b173caf66d run-tests: fix some missing i/o locks 2011-04-24 17:52:46 -05:00
Matt Mackall
ec6c0b4dd8 run-tests: add a lock for console I/O 2011-04-24 16:46:37 -05:00
Matt Mackall
ffa2bfc870 run-tests: switch timeout handling from alarm to helper thread
This should be slightly more portable than signals and be compatible
with threaded dispatch.
2011-04-24 16:42:15 -05:00
Matt Mackall
991f15b761 run-tests: add locking on results struct 2011-04-24 16:42:11 -05:00
Patrick Mezard
35a92ea64b run-tests: fix --interactive (after 6f977fba3d04)
- Do not prompt if there is no .err file
- Fix source and target paths
2011-04-24 23:33:48 +02:00
Matt Mackall
15f893d8b4 run-tests: move test loop into a helper function 2011-04-22 14:04:34 -05:00
Matt Mackall
00e494b835 run-tests: use a results dict 2011-04-22 12:24:22 -05:00
Matt Mackall
1d9ec246c2 run-tests: move blacklist and retest filtering to runone 2011-04-22 11:36:40 -05:00
Matt Mackall
b8baa5e84b run-tests: keep a list of passed tests 2011-04-22 11:32:05 -05:00
Matt Mackall
05c203e160 run-tests: move keyword checking into runone 2011-04-22 11:24:27 -05:00