Commit Graph

56 Commits

Author SHA1 Message Date
Gregory Szorc
918575b5f2 run-tests: wait for test threads after first error
The test runner has the ability to stop on first error.

Tests are executed in new Python threads. The test runner starts new
threads when it has capacity to do so. Before this patch, the "stop on
first error" logic would return immediately from the "run tests"
function, without waiting on test threads to complete. There was thus
a race between the test runner thread doing cleanup work and the test
thread performing activity. For example, the test thread could be in
the middle of executing a test shell script and the test runner
could remove the test's temporary directory. Depending on timing, this
could result in any number of output from the test runner.

This patch eliminates the race condition by having the test runner
explicitly wait for test threads to complete before continuing.

I discovered this issue as I modified the test harness in a subsequent
patch and was reliably able to tickle the race condition.
2015-03-28 19:39:03 -07:00
Gregory Szorc
01447cbf3e run-tests: explicitly handle unicode when writing xunit file
The xunit writer was passing a str to a minidom API. An implicit
.decode('ascii') was performed somewhere, causing UnicodeDecodeError
if test output contained non-ascii sequences.

This patch converts test output to utf-8 before passing it to minidom.
We use the "replace" strategy to ensure invalid utf-8 sequences get
munged into �.
2015-03-29 10:41:23 -07:00
FUJIWARA Katsunori
7162b6792b run-tests.py: inherit --pure option from outer run-tests.py execution
Before this patch, "test-run-tests.t" doesn't test "run-tests.py" with
"--pure", even if outer "run-tests.py" is executed with it.

This patch uses not "HG_RUN_TESTS_PURE" but "HGTEST_RUN_TESTS_PURE",
because "HG_" prefixed environments are forcibly dropped in "_getenv()".

This is also useful to run "run-tests.py" successfully by
"run-tests.py --pure" on Windows without any compilation tools (like
VisualStudio).
2015-01-22 00:07:06 +09:00
Mads Kiilerich
7ebc1609d6 run-tests: automatically add (glob) to "saved backup bundle to" lines
Avoid spending too much time adding (glob) after running run-tests -i. This
doesn't handle all cases but it helps.

The run-tests tests add a bit of escaping of trailing (glob) in the output to
avoid interference from the outer test runner.

The regexp for matching the output lines contains a group for making multiline
substitute in a way that works with Python before 2.7.
2014-11-27 02:04:30 +01:00
Thomas Klausner
57f4b24f7a tests: adapt glob pattern to fix test with NetBSD's sh(1) (issue4484) 2014-12-28 23:50:08 +01:00
Matt Harbison
d1e1ea0e07 tests: fix globs for Windows
test-largefiles-update.t, test-subrepo.t, test-tag.t, and
test-rename-dir-merge.t still warn about no result returned because of
unnecessary globs that test-check-code-hg.t wants, relating to output for
pushing to, pulling from and moving X to Y.
2014-11-16 16:26:15 -05:00
Augie Fackler
11da8b36af test-run-tests: accept more levels of precision and trailing ws (issue4440)
simplejson produces slightly different output from the built-in json
module, specifically:
  * It uses 0.000 instead of 0.0000
  * It likes to put a trailing space after a comma

This change works around both of those variations.
2014-11-06 10:57:13 -05:00
Matt Mackall
66c843c0a1 tests: silence output race in test-run-tests.t 2014-10-30 17:52:01 -05:00
Augie Fackler
a90f2cdd55 test-run-tests: add a test for detection of failure to start a server
This also highlights a bug: right now we print "2 failed" but we only
ran one test.
2014-10-10 10:34:52 -04:00
Augie Fackler
dcb03fe445 run-tests: handle --jobs and --first gracefully
Without this change, --first causes currently-running tests to explode
in violent and surprising ways when their temporary directory gets
cleaned up. Now we just suppress failure messages from non-first
failures when running in --first mode.
2014-10-09 15:10:40 -04:00
Pierre-Yves David
65dc6712bd test: protect the run-tests.py --json test behind an hghave rule
We add a rules to detect availability of a json module and skip if json is not
available.
2014-09-18 11:43:47 -07:00
anuraggoel
7937672970 run-tests: added 'cuser', 'csys' time info in report.json file
This patch adds up a 'cuser' and 'csys'(cputime) info in report.json file
which generated when --json is enabled while testing.

Now the new format of report.json file is as below.

testreport ={
    "test-success.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "success",
        "time": "2.041"
    }
    "test-failure.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "failure",
        "time": "4.430"
    }
    "test-skip.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "skip",
        "time": "3.754"
    }
}
2014-09-19 07:23:10 +05:30
anuraggoel
98bc0018a9 run-tests: added '--json' functionality to store test result in json file
This patch added a new functionality '--json'. While testing, if '--json'
is enabled then test result data gets stored in newly created "report.json"
file in the following format.

testreport ={
    "test-success.t": {
        "result": "success",
        "time": "2.041"
    }
    "test-failure.t": {
        "result": "failure",
        "time": "4.430"
    }
    "test-skip.t": {
        "result": "skip"
            "time": "3.754"
    }
}

Otherwise, if '--json' is enabled but json module was not installed then it
will raise an error "json module not installed".

This "report.json" file will further accessed by html/javascript file for
graph usage.
2014-09-08 16:41:00 +02:00
Gregory Szorc
6f5ee93aca run-tests: make --interactive work with --view 2014-08-31 12:22:44 +02:00
Mads Kiilerich
33397f4828 run-tests: report skipped tests as "skipped" - they might still be "relevant" 2014-08-26 22:03:30 +02:00
Matt Mackall
57de8037d2 merge with stable 2014-08-14 16:25:47 -05:00
Matt Mackall
24638bb76c test-run-tests: fix up slash/backslash on diff chunks for Windows 2014-08-14 16:18:45 -05:00
Matt Mackall
28afeddddf test-run-tests: fix stdout/stderr io ordering 2014-08-13 14:05:08 -05:00
Matt Mackall
696a2d25ed test-run-tests: filter pwd alias for Windows 2014-08-12 11:10:57 -05:00
Matt Mackall
6c5b3c4a4c merge with stable 2014-08-13 15:06:58 -05:00
Matt Mackall
ee564a47d4 merge with stable 2014-08-12 17:22:57 -05:00
Matt Mackall
e596a535b4 test-run-tests: test --view 2014-08-12 00:40:24 -05:00
Matt Mackall
a9cc11268b run-tests: don't show 'i' for tests that don't match a keyword 2014-08-12 00:33:48 -05:00
Matt Mackall
99b86fb9bf run-tests: add #require to abort full test
This allows nuking a bunch of ugly hghave || exit 80 lines.
2014-08-06 10:34:54 -05:00
Augie Fackler
00009ae554 run-tests: add support for xunit test reports
The Jenkins CI system understands xunit reports natively, so this will
be helpful for anyone that wants to use Jenkins for testing hg or
extensions that use run-tests.py for their testing.
2014-08-05 21:17:11 -04:00
Augie Fackler
292ddbefc0 run-tests: fix test result counts with --keyword specified or skips occurring
This preserves the current behavior that excludes ignored or skipped
tests from the number of tests run, except when tests are ignored due
to the --retest flag.
2014-07-28 19:48:59 -04:00
Augie Fackler
6be20ecce2 test-run-tests.t: add tests for skips
This will make some minor behavior changes in a future patch more obvious.
2014-07-29 22:35:59 -04:00
Augie Fackler
cad4706d78 test-run-tests.t: add extra data to tests for keyword tests
This adds a fair amount of overall instability in the enclosing .t. As
such, this is performed in its own commit, and a test for --keyword on
run-tests.t will be added in a followup change.
2014-07-28 20:54:14 -04:00
anuraggoel
0a9b451708 run-tests: '--time' option provide more details to Linux users
As our tests execute in child processes, this patch uses os.times()
module in replace of time.time() module to provide additional info like
user time and system time spent by child's processes along with real elapsed
time taken by a process.

There is one limitation of this patch. It can work only for Linux users and
not for Windows.

"os.times" module returns a 5-tuple of a floaing point numbers.
1) User time
2) System time
3) Child's user time
4) Child's system time
5) Ellapsed real time

On Windows, only the first two items are filled, the others are zero.
Therefore, below test cases does not break on Windows but instead gives the
zero value.
2014-06-26 01:22:50 +05:30
Matt Mackall
e5948a69d1 run-tests: hold iolock across diff/prompt when interactive
Otherwise diff may get separated from the corresponding prompt by
other threads. This required moving the interactive prompting from one
helper method to another.
2014-06-18 20:51:49 -05:00
Pierre-Yves David
d5bb6cb3eb test-run-tests.t: test the --nodiff option 2014-05-30 12:57:58 -07:00
Pierre-Yves David
c90f87b7e5 test-run-tests.t: test the --interactive option 2014-05-30 12:12:12 -07:00
Pierre-Yves David
4732464f1e test-run-tests.t: tests --jobs option 2014-05-30 12:12:03 -07:00
Pierre-Yves David
1889819d1f test-run-tests.t: test --debug option 2014-05-30 12:11:51 -07:00
Pierre-Yves David
411c323ef1 test-run-tests.t: test selection of testfile from the command line 2014-05-30 12:11:39 -07:00
Pierre-Yves David
336693de0b test-run-tests.t: tests the --retest option 2014-05-30 12:11:17 -07:00
Pierre-Yves David
61ff88f87e test-run-tests.t: test running a failing test 2014-05-30 12:10:56 -07:00
Pierre-Yves David
f314702217 test-run-tests.t: test running a passing test 2014-05-30 12:10:19 -07:00
Pierre-Yves David
dce829ed70 test: introduce test-run-tests.t
This testfile tests the test runner itself. There were multiple regressions in the
last few weeks. Having tests would prevent this in the future.
2014-05-30 12:09:49 -07:00
Pierre-Yves David
b65b8117ce tests: rename `test-run-tests.t to test-unified-test.t`
This ``test-run-tests.y`` is testing the unified test (.t) syntax
interpretation, not really the run-tests.py command tool itself.
2014-05-30 11:35:45 -07:00
Simon Heimberg
6ae309cc92 tests: glob match has a glob character for not getting a warning on windows
When / matches on / on windows, and there is no other glob character, this
results in a warning. Avoid this by using an other glob character.
2014-02-14 00:36:44 +01:00
Mads Kiilerich
0b618576fd test-run-tests.t: fix wrong test case for cr handling on Windows
An incorrect and failing test case was introduced in a55b74d8de3a.
2012-10-18 00:33:26 +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
Mads Kiilerich
9cddfd19ab check-code: fix check for trailing whitespace on sh command lines
The $ has been without necessary escaping since introduced in c4ecbbd282fe.
2012-08-08 18:10:16 +02:00
Adrian Buehlmann
d75f30dfcb test-run-tests: add tests for "#if no-false" and no-true 2012-06-11 14:09:35 +02:00
Adrian Buehlmann
6e5f4815b5 tests/hghave: implement #if true / #if false
For unconditionally testing / skipping a section. Useful for testing the test
infrastructure in test-run-tests.t and for debugging/developing tests.
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
Mads Kiilerich
bec2d3c22e tests: don't rely on 'false' exit code in test-run-tests.t
On Solaris:
$ sh -c 'false ; echo $?'
255
2012-01-27 03:00:32 +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