Commit Graph

72 Commits

Author SHA1 Message Date
Matt Harbison
31dd910b50 test-run-tests: add globs for Windows
There are two other unrelated failures in this test.  For some reason child1 has
a space after it, thus 2 spaces before the glob, otherwise the glob is ignored
and removed.
2015-10-01 22:14:11 -04:00
timeless@mozdev.org
dba46baf88 run-tests: report paths saved by --keep-tmpdir 2015-09-30 16:01:19 -04:00
timeless@mozdev.org
20963e1f94 run-tests: use $HGTEST_RUN_TESTS_PURE
test-run-tests and test-hghave call run-tests;
if you don't have a working build environment, and you are trying
to use --pure, then if they don't use --pure or --with-hg,
they'll break.
2015-09-02 15:19:05 -04:00
Augie Fackler
cd6222a983 run-tests: add support for marking tests as very slow
I want to add tests for our packaging rules, but those necessarily run
a whole build, or possibly two if both native packaging and docker are
available. This lets us flag such tests with a `#require slow` so that
they don't unnecessarily slow down normal test runs.
2015-08-24 22:23:45 -04:00
FUJIWARA Katsunori
4a75be9bfa run-tests.py: add TESTDIR to PATH if it differs from RUNTESTDIR
Before this patch, `RUNTESTDIR` is added to `PATH`, but `TESTDIR`
isn't.

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

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

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

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

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

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

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

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

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

This is a one of preparations for issue4677.
2015-07-03 06:56:03 +09:00
Matt Mackall
3ad28905f6 tests: drop explicit $TESTDIR from executables
$TESTDIR is added to the path, so this is superfluous. Also,
inconsistent use of quotes means we might have broken on tests with
paths containing spaces.
2015-06-08 14:44:30 -05:00
Matt Mackall
b597cb9caa tests: add (?) flag for optional lines
When the test engine fails to match output on a line marked with (?),
it will simply continue to the next expected line and try again. This
allows simplifying tests that have either version-specific or
non-fixed behavior, for instance:

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

(There's no form of back-tracking attempted, so optional matches
should be specific.)
2015-05-31 16:59:34 -05:00
Pierre-Yves David
bffec7e365 run-tests: include 'start' and 'end' in --time output
This is useful information to understand what is taking time in tests. Both are
included because I can see myself sorting this output using shell script. Having
both data makes it much easier than extracting 'start'+'real'.
2015-05-07 23:40:29 -07:00
Pierre-Yves David
bd7f28d558 run-tests: track start and end time of tests
We currently have information about how long each test took, but we have no data
about their actual scheduling. So we now track when a test started and stopped
(in the referential of the whole tests run) to expose this information.

The data is currently in the json only because the json output is meant to be
extensible. Later changeset will includes this data in the text output and we
will be happy to bikeshed its formating there.

Yes, "end" is actually just "start" + "time", but computing it an including it
in the output is simple, cheap and convenient.
2015-05-07 23:34:58 -07:00
Augie Fackler
6ea86f31bb test-run-tests.t: work around file.write() returning an int
In Python 3.5, file.write() returns the number of bytes it wrote
instead of None.
2015-04-13 16:37:53 -04:00
Matt Mackall
82d521ccc3 merge with stable 2015-05-10 14:45:13 -05:00
Pierre-Yves David
0cae7109a3 test-run-test: unset run-test specific environment variables
Otherwise variable set for the real test run interfere with the test runner
tests.
2015-05-08 11:32:24 -07:00
Pierre-Yves David
9f318745fd run-test: add a test for json output when -i is used
The -i can apparently confused some internal data structure, we want to make
sure we do not regress.
2015-05-08 19:32:11 -07:00
Gregory Szorc
704132c0a7 run-tests: don't error when glob matched line ends with backslash
As part of writing another test, I triggered an array index error in
glob match processing code by having a (glob) line end in a single
backslash (which is the escape character).

Adding a simple bounds check prevents the error in run-tests.py.
2015-04-17 14:12:01 -07:00
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