Commit Graph

760 Commits

Author SHA1 Message Date
Augie Fackler
edf8ac03be run-tests: forward Python USER_BASE from site (issue5425)
We do this so that any linters installed via pip install --user don't
break. See https://docs.python.org/2/library/site.html#site.USER_BASE
for a description of what this nonsense is all about.

An alternative would be to not set HOME, but that'll cause other
problems (see issue2707), or to forward every single path entry from
sys.path in PYTHONPATH (which seems sketchy in its own way).
2016-11-10 16:07:24 -05:00
Jun Wu
646ab80437 run-tests: make --local set --with-chg if --chg is used
--local should work with chg as well.
2016-07-18 08:55:30 +01:00
Jun Wu
5135dc6d30 run-tests: allow --local to set multiple attributes
This is to make the next patch easier to review. It does not change logic.
2016-07-18 08:45:46 +01:00
Augie Fackler
2356a5286e run-tests: add support for using 127.0.0.1 as a glob
Some systems don't have a 127/8 address for localhost (I noticed this
on a FreeBSD jail). In order to work around this, use 127.0.0.1 as a
glob pattern. A future commit will update needed output lines and add
a requirement to check-code.py.
2016-07-09 23:01:02 -04:00
Pulkit Goyal
aef2bdd39a py3: make files use absolute_import and print_function
This patch includes addition of absolute_import and print_function to the
 files where they are missing. The modern importing conventions are also followed.
2016-07-03 22:28:24 +05:30
timeless
5729cecafc run-tests: add support for RTUNICODEPEDANTRY environment variable
based on d0a46e6f1fd7
2016-04-05 01:35:58 +00:00
timeless
02e1db6099 run-tests: use json.dumps(separators=)
Followup to eb3e07c0bd4b per Martijn Pieters
2016-05-26 02:35:44 +00:00
timeless
64b3f40be2 run-tests: handle json.dumps divergence
In py2, json.dumps includes a trailing space after a comma at the
end of lines. The py3 behavior which omits the trailing space is
preferable, so we're going to strip it.
2016-05-05 23:17:19 +00:00
timeless
13f6bf6c8e run-tests: set HGMODULEPOLICY for --pure
Without this, my python 2.6 virtualenv test run with --pure and
--local fails with:

+  ImportError: Python minor version mismatch: The Mercurial extension modules were compiled with Python 2.7.8, but Mercurial is currently using Python with sys.hexversion=33950192: Python 2.6.9 (unknown, Apr 13 2016, 12:40:12)
+  [GCC 4.9.2 20141101 (Red Hat 4.9.2-1)]
+   at: ~/hg/py26/bin/python
2016-04-13 13:51:39 +00:00
Yuya Nishihara
87bcd87c28 hghave: add "chg" flag to skip tests that can't be compatible with chg
Several tests fail with chg for several reasons such as loaded chgserver
extension, running uisetup() per server instead of per runcommand, etc.
Since these tests can't/shouldn't be changed to be chg friendly, we need
a flag to skip them.

This patch explicitly drops CHGHG environment if chg isn't involved. This
way, hghave can just check if CHGHG exists.
2016-03-20 14:55:56 -07:00
timeless
78312b6131 run-tests: move install.err into test area
Without this, sometimes installerrs generated errors
about no such file. It also did not work well when you
had multiple tests runners running around.

It also did not make sense to pollute the repository test
directory with the log file.
2016-04-07 11:11:55 +00:00
Augie Fackler
e02a696ec8 run-tests: fix broken regular expression
The regular expression in use passed tests because the test repo only
has single-digit changesets present. When I tried to use this for real
today, it broke, because the regular expression would only match a
single digit.

https://xkcd.com/1171/, or something like that.
2016-04-06 22:26:47 -04:00
timeless
2493adae19 run-tests: handle empty tests 2016-04-05 04:26:20 +00:00
timeless
ac72d955ec run-tests: make _processoutput picky about optional globs
72b40f92c680 enabled lines that were not matched to be found later in cases of jitter.

Unfortunately, in this model an optional line would always jitter to the end when
it is not present. That is not ideal.

It would be possible to do better, by queuing all writes until the end in case
an optional line jitters, but for now, it is simpler to assume optional lines
have a fixed place in the stream.
2016-03-30 09:13:47 +00:00
timeless
8e8201d525 py3: convert hghave output to text
Before this, Python3 generated:
b'skipped: unknown feature: not-py3k\n'
2016-03-30 08:02:34 +00:00
timeless
efbcb6a1c1 py3: convert prereq bytes to string in run-tests
Without this, run-tests would generate:
WARNING: Did not find prerequisite tool: b'python3.5'
2016-03-30 05:26:51 +00:00
timeless
d3e5492366 run-tests: use canonpath for with-python3 2016-03-28 04:02:07 +00:00
timeless
1a1c265a54 run-tests: add canonpath function
consistently use realpath+expanduser
2016-03-28 04:01:21 +00:00
Jun Wu
d252746940 run-tests: use different chg socket directories for different tests
Before this patch, if --chg or --with-chg is specified, all tests are using
the same chgserver socket. Since the chg client holds a lock when it starts a
new server, and every test needs at least a new chg server due to different
HGRCPATH affecting the confighash, the result is a lot of tests will be
timed out if -j is large (for example, 50 or 100).

This patch solves the issue by using different chg socket directories for
different tests.
2016-03-20 17:18:06 -07:00
Augie Fackler
b15267eb94 run-tests: add support for automatically bisecting test failures 2016-03-19 14:26:10 -04:00
Gregory Szorc
464bf4c7e9 run-tests: add --with-python3 to define a Python 3 interpreter
Currently, very few parts of Mercurial run under Python 3, notably the
test harness.

We want to write tests that run Python 3. For example, we want to
extend test-check-py3-compat.t to parse and load Python files.
However, we have a problem: finding appropriate files requires
running `hg files` and this requires Python 2 until `hg` works
with Python 3.

As a temporary workaround, we add --with-python3 to the test harness
to allow us to define the path to a Python 3 interpreter. This
interpreter is made available to the test environment via $PYTHON3 so
tests can run things with Python 3 while the test harness and `hg`
invocations continue to run from Python 2. To round out the feature,
a "py3exe" hghave check has been added.
2016-03-18 16:17:56 -07:00
timeless
6c36b542b4 run-tests: teach _processoutput to handle multiple lines of churn
Instead of treating expected output as happening in a precise order,
and assuming that if a line is missing it will never happen,
assume that expected output is a prioritized list of likely matching
lines.

This means that if:

 foo/bar (glob)
 baz/bad (glob)

changes to:

 baz/bad
 foo/bar

instead of generating:

 baz/bad
 foo/bar

For which we've lost both (glob) markers,
we will match both lines and generate:

 baz/bad (glob)
 foo/bar (glob)

This retains any special annotations we have for lines.
2016-03-17 20:52:06 +00:00
timeless
7d5e3a8dc0 run-tests: indent _processoutput to aid readability for next patch
The next commit will loop over the expected[pos] list, this change
makes that change easier to review.
2016-03-17 20:54:36 +00:00
Jun Wu
10d32ae3a0 chg: do not write pidfile
Current pidfile logic will only keep the pid of the newest server, which is
not very useful if we want to kill all servers, and will become outdated if
the server auto exits after being idle for too long.

Besides, the server-side pidfile writing logic runs before chgserver gets
confighash so it's not trivial to append confighash to pidfile basename like
we did for socket file.

This patch removes --pidfile from the command starting chgserver and switches
to an alternative way (unlink socket file) to stop the server.
2016-03-10 00:19:55 +00:00
Gregory Szorc
426b834415 run-tests: remove 2to3 support
Our goal is to have 1 code base that works on 2.6, 2.7, and 3.5+.
2to3 won't be used. Stop passing it to setup.py.
2016-02-27 21:08:37 -08:00
Matt Harbison
f0863290ab run-tests: defer leftover (?) cleanup until after all output is exhausted
Previously, after matching a single line, any contiguous subsequent lines ending
with (?) would be added to the output and removed from the expected output.
This is a problem if the subsequent test output would have matched the consumed
(?) line, because it kept the optional line and then added a duplicate without
the (?) [1].  Instead, wait until there is nothing more to match before handling
the leftovers.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-February/080197.html
2016-02-28 23:21:28 -05:00
Gregory Szorc
9068a821f3 run-tests: fix Python 3 incompatibilities
At one point run-tests.py and test-run-tests.t worked and passed
under Python 3.5. Various changes to run-tests.py over the past
several months appear to have broken Python 3.5 compatibility.

This patch implements various fixes (all related to str/bytes type
coercion) to make run-tests.py and test-run-tests.t mostly work
again. There are still a few failures in test-run-tests.t due to
issues importing mercurial.* modules. But at least run-tests.py
seems to work under 3.5 again.
2016-02-27 21:29:42 -08:00
David R. MacIver
3ebd7298a9 run-tests: allow run-tests.py to run tests outside current directory
When reloading tests, run-tests.py was assuming that it could look
up the test by the basename, which only works if you are running
tests which are in the current directory.

This patch changes that lookup to use the full path. This is all
that was needed, and does not appear to cause any problems for
any of the existing testing work flows based on running the
suggested commands at the top of run-tests.py.

Motivation: In order to test Mercurial with Hypothesis (according
to https://www.mercurial-scm.org/wiki/HypothesisPlan) it is
useful to be able to generate temporary test files and execute
them. Generating temporary files in the tests/ directory leads to
a lot of suboptimal clutter.
2016-02-18 08:52:15 +00:00
timeless
8a0d103caa run-tests: stop allocating HGPORT3+HGPORT4
The only consumer was test-treemanifest.t, which has been fixed.

In general, you should be able to use killdaemons.py to recycle
ports instead of going over 3 ports (HGPORT, HGPORT1, HGPORT2).

In the future, if you want to add a port, be sure to change
portneeded in _getport.
2016-02-17 19:38:44 +00:00
timeless
7b4d0e1e16 run-tests: refactor port allocation into functions
Adding a port reservation was too hard and someone did it wrong.
By refactoring, such reservations can be managed more safely.

This also adds documentation so that the next person who tries
is more likely to update all the places correctly.

Note that in this commit the reservation and consumers do not
match, that will be fixed in the next commit.
2016-02-17 19:36:32 +00:00
Yuya Nishihara
dd5e0b4899 run-tests: add --chg option to install and run tests using chg
Because the temporary installation directory is shared between hg and chg,
--chg is not allowed if --with-hg option is specified. Also, --chg option
does not work on FreeBSD because "make" command is hard-coded. These
limitations can be improved later.

Almost all tests will fail with chg right now.
2016-02-07 18:08:59 +09:00
Yuya Nishihara
83ccd75532 run-tests: add --with-chg option to run tests using chg
Unlike --with-hg=/path/to/chg, this option allows us to start and clean up
command servers in isolated environment. And we can specify the hg command
as well as the chg command.
2016-02-07 16:34:12 +09:00
Yuya Nishihara
cf3e9474ef run-tests: remove useless "failed" flag from addOutputMismatch()
It never be set to True.
2016-01-09 13:22:26 +09:00
Yuya Nishihara
ad2de493a5 tests: load json with no fallback
The json module should be available in Python 2.6 or newer.
2016-01-09 13:20:15 +09:00
Yuya Nishihara
cd561eb91a run-tests: allow to specify executable of any name by --with-hg
If the executable is not named as "hg", TTest runner inserts alias. This
way, we can run tests with chg. But it is still warned because the alias
does not always work. We do "$BINDIR"/hg in a few places.
2016-02-07 15:21:39 +09:00
Yuya Nishihara
3ba5dbc55e run-tests: drop redundant assignment to BINDIR
We do it a few lines after.
2016-02-07 16:02:41 +09:00
Yuya Nishihara
0d8272a88a run-tests: cast --with-hg option to bytes consistently at parseargs()
parseargs() sets bytes to options.with_hg if --local is specified, so do
the same for --with-hg.
2016-02-07 16:00:05 +09:00
Yuya Nishihara
fd68b16ac6 run-tests: do not compare bytes with str while ordering tests
It failed on Python 3.
2016-02-07 15:53:02 +09:00
timeless
64b5aa82c1 run-tests: factor out _escapepath 2016-01-29 14:35:34 +00:00
timeless
e09049f8f5 run-tests: warn about symlinks to non hg scripts
If you symlink /usr/bin/true to /something/hg and try to run
--with-hg=/something/hg, run-tests will end up running /usr/bin/hg,
not /usr/bin/true.
2016-02-08 22:50:19 +00:00
Martin von Zweigbergk
e50c296659 treemanifests: fix streaming clone
Similar to the previous patch, the .hg/store/meta/ directory does not
get copied when when using "hg clone --uncompressed". Fix by including
"meta/" in store.datafiles(). This seems safe to do, as there are only
a few users of this method. "hg manifest" already filters the paths by
"data/" prefix. The calls from largefiles also seem safe. The use in
verify needs updating to prevent it from mistaking dirlogs for
orphaned filelogs. That change is included in this patch.

Since the dirlogs will now be in the fncache when using fncachestore,
let's also update debugrebuildfncache(). That will also allow any
existing treemanifest repos to get their dirlogs into the fncache.

Also update test-treemanifest.t to use an a directory name that
requires dot-encoding and uppercase-encoding so we test that the path
encoding works.
2016-02-04 08:34:07 -08:00
Bryan O'Sullivan
95a960a422 run-tests: "fix" race condition in race condition fix
Laurent's commit 56cdfddbd2ed still suffers from a race: by the
time the "job" function tries to assign to channels[channel], that
list has been truncated to empty.  The result is that every job
thread raises an IndexError.

Earlier, I tried an approach of correctly locking channels, but
that caused run-tests to hang on KeyboardInterrupt sometimes.

This approach is strictly hackier, but seems to actually work
reliably.
2016-01-22 11:00:13 -08:00
Laurent Charignon
bdac46ce5b run-tests: fix crash when --json and --blacklist are both used (issue5050)
This patch fixes a crash when both --json and --blacklist were given as
arguments of run-tests.py. Now, instead of crashing, we add an entry for
blacklisted tests in the json output to show that the tests were skipped.
2016-01-19 08:22:27 -08:00
Laurent Charignon
fb718d23a0 run-tests: fix race condition
Before this patch, it was possible for run-tests to crash on a race condition.
The race condition happens in the following case:
- the last test finishes and calls: done.put(None)
- the context switches to the main thread that clears the channels list
- the context switches to the last test mentioned above, it tries to access
channels[channel] and crashes
This happened to me while running run-tests.

This patch fixes the issue by clearing the channel before considering that the
test is done.
2016-01-21 12:37:12 -08:00
timeless
fafbbff385 run-tests: skip threading for a single test (issue5040)
This version backs out 69d5cadd84a0 and implements it in
a more consistent manner.
2016-01-14 04:14:50 +00:00
Bryan O'Sullivan
c54f58f09c run-tests: use a context manager for file I/O in TextTestRunner 2016-01-12 14:49:10 -08:00
Bryan O'Sullivan
100ad2a9c4 run-tests: use a context manager for file I/O 2016-01-12 14:29:57 -08:00
timeless
25686051e3 run-tests: skip threading for a single test
Threading is incompatible with most Python debuggers,
which makes debugging run-tests.py a real pain.

If there is only one test to run, skip using a thread for it.

Note that --debug is not compatible with debugging tests,
since it bypasses the output handling, which is where
much of the excitement is.
2015-12-28 17:48:40 +00:00
Laurent Charignon
693c12d5a7 run-tests: add 'diff' entry in json report
This patch adds to the json report the "diff" between expected and observed
result. This diff can be useful for automatically filing bug report on failing
tests.
2016-01-05 13:33:09 -08:00
timeless
ebb1d48658 cleanup: remove superfluous space after space after equals (python) 2015-12-31 08:16:59 +00:00