Commit Graph

694 Commits

Author SHA1 Message Date
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
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
b1a2babd78 devel: rename 'all' to 'all-warnings' (BC)
We have started to isolate extra usecases for developer-only output
that is not a warning. As the section has the fairly generic name
'devel' it makes sense to tuck them there. As a result, 'all' becomes
a bit misleading so we rename it to 'all-warnings'. This will break
some developer setups but the tests are still fine and developers will
likely spot this change.
2015-05-26 14:14:36 -07:00
Augie Fackler
10487ffdd9 run-tests: python3.5 now supports mkdtemp using bytes for paths
Now that http://bugs.python.org/issue24230 is fixed (thanks to Gregory
Smith for that quick response!) we can drop one more ugly hack around
path handling. Tests still pass in 3.5 with this cleaner version, as
well as in 2.6.
2015-05-22 21:19:08 -04:00
Augie Fackler
ab57fc9f4c run-tests: use items() instead of iteritems()
This fixes the python3.5 build. We'll presumably want to build our own
helper function or use 2to3 for this on the main source tree, but for
run-tests we want a single-source version that works in 2.6 and 3.5.
2015-05-22 21:15:52 -04:00
Matt Harbison
ff93ed30c4 run-tests: resurrect the wifexited polyfill (backout afc1c96d7d8c)
Python 2.7.3 on Windows doesn't have os.WIFEXITED, and the test output looked
like this before I interrupted it.

    $ ./run-tests.py --local -j2 -t700
    EEEEEEEEEEEEEEEEEEEEEE
2015-05-18 15:34:42 -04:00
Augie Fackler
5c9b102436 run-tests: replace open-coded .decode()s on paths with a helper (issue4667)
This also cleans up the mkdtemp code mentioned in the previous patch.

At this point, the remaining callsites of .{en,de)code() are in the
following categories:

Handling escaped lines in .t files
-----------------------------------

It seems eminently reasonable to me for us to declare that .t files
are valid utf-8, and that any escape sequences we see in .t files
should be valid unicode_escape sequences.


Making error text safe for cdata blocks for xml error reports
-------------------------------------------------------------

This is a point where we're already basically screwed, and we're
simply trying to do something "good enough" that the xml output will
be vaguely useful to the user. Punting here seems fine, and we should
probably stick to the same encoding here that we used in the previous
section.
2015-05-17 21:47:18 -04:00
Augie Fackler
ae9dde628a run-tests: move unicode-to-bytes operations on paths to a helper (issue4667)
This doesn't fix the probably-wrong utf-8 encoding choice, it just
starts the process of encapsulating all the path handling in run-tests
in a single place.

One known-path use of .encode() remains: it's related to use of
mkdtemp, and it will be fixed in a followup patch once we have a
companion _strpath() helper function to go from bytes to a str, as we
need to file a bug about mkdtemp upstream.
2015-05-17 21:40:12 -04:00
Augie Fackler
62a6d278f5 run-tests: insist that if people use Python 3, they use 3.5.x
We depend on both stdlib functionality (difflib.diff_bytes) and
language behavior (bytes formatting) introduced in 3.5, so let's try
and prevent some useless bug reports before they happen.
2015-05-17 21:26:04 -04:00
Augie Fackler
1e68f5c6ca run-tests: move all open-coded sys.version_info checks to PYTHON3 (issue4668)
This consolidates all version checking in a single place and helps the
code read more obviously.
2015-05-17 21:18:56 -04:00
Augie Fackler
e51d6f1899 run-tests: prefer PYTHON3 constant to many version_info checks (issue4668)
We only support Python 2.6, 2.7, and 3.5 here, so we can simplify the
code and improve the warning.
2015-05-17 21:17:13 -04:00
Augie Fackler
b4a58c425e run-tests: introduce PYTHON3 boolean constant (issue4668)
This will avoid open-coding lots of version_info checks later in the
file.
2015-05-17 21:12:33 -04:00
Augie Fackler
f4891c885e run-tests: drop subprocess _cleanup monkeypatch
This was working around a defect in subprocess in Python 2.5, which we
no longer need to worry about.
2015-05-17 21:15:45 -04:00
Augie Fackler
3493223980 run-tests: drop wifexited polyfill
os.WIFEXITED exists as of python 2.6 for me, so we no longer need this
polyfill.
2015-05-17 21:15:04 -04:00
Augie Fackler
03a9938c4e run-tests: add a --profile-runner option
While in the throes of a recent run-tests adventure, I found it useful
to have profiler output for the testrunner itself. Adding it was
simple enough and seems worth keeping around.
2015-05-13 11:22:06 -07: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
Pierre-Yves David
ef189e5641 run-test.py: greatly increase the priority of 'check-code' tests
As check-code is actually quite long to run for its file size, this prevent them
to be scheduled too late during the test run.

This reduces my typical test run from 107 seconds to 90 seconds
2015-05-08 15:00:07 -07:00
Pierre-Yves David
31d528dc85 run-tests: allow different extra weight for slow tests
The 'test-check-code-hg.t' file is not big enough to be prioritized properly.
As a result my tests run often spend about 15 seconds running only it at the
end of its tests run. We make the "slow" mechanism a bit smarter to adjust the
extra weight of each category independently in a future patch.
2015-05-08 00:04:07 -07:00
Augie Fackler
6935e3983d run-tests: make sure all script lines are bytes 2015-04-14 16:09:39 -04:00
Augie Fackler
68f94c8175 run-tests: fix checking a line to see if it needs globbing 2015-04-14 10:56:58 -04:00
Augie Fackler
486fea3478 run-tests: unblock running python tests in python 3
This makes it clear we need to ban os.popen, but we'll do that in a
later cleanup.
2015-04-14 10:14:49 -04:00
Augie Fackler
84dddeb523 run-tests: os.popen returns a string, make it bytes again 2015-04-13 18:07:40 -04:00
Augie Fackler
e64a6da7f4 run-tests: be more paranoid about os.system using bytes 2015-04-13 17:24:10 -04:00
Augie Fackler
e932ed0614 run-tests: blacklist entries are bytes, use bname to check blacklisting 2015-04-13 17:17:17 -04:00
Augie Fackler
0e64e5e285 run-tests: write bytes to the binary buffer on sys.{stdout,stderr} 2015-04-14 16:24:32 -04:00
Augie Fackler
431689beb7 run-tests: record faildata using bytes instead of str
lines is already bytes, so this is just fixing a bug on python 3.
2015-04-14 16:21:10 -04:00
Augie Fackler
4b472c4d53 run-tests: do cdata escaping using bytes instead of str 2015-04-14 16:18:11 -04:00
Augie Fackler
fa8492c100 run-tests: make sure keyword(s) are in bytes and not str 2015-04-13 16:33:12 -04:00
Augie Fackler
efb350b95a run-tests: use items instead of iteritems on dicts
This works the same-enough on 2.6 and 3.5 to be fine.
2015-04-13 16:31:19 -04:00
Augie Fackler
75c3d9ebc6 run-tests: refer to test.bname when sniffing for keywords 2015-04-13 16:30:40 -04:00
Augie Fackler
5eefdc92a3 run-tests: string-escape no longer exists in python 3, use unicode_escape 2015-04-13 15:57:10 -04:00
Augie Fackler
952af89c4f run-tests: switch all uses of iolock.acquire() to a context manager 2015-04-13 15:55:48 -04:00
Augie Fackler
a74a0844ac run-tests: use difflib.diff_bytes on Python 3
This method was introduced in Python 3.5 to satisfy our
diffing-strings-of-bytes needs.
2015-04-21 12:24:34 -04:00
Augie Fackler
5816747571 run-tests: fix installation of hg by bytesifying more constants 2015-04-12 16:14:07 -04:00
Augie Fackler
cf734aa52c run-tests: work around with_hg being bytes or string depending on provenance 2015-04-12 15:35:57 -04:00
Augie Fackler
61cdf43464 run-tests: even more bytestring annotations for Python 3 2015-04-14 16:03:04 -04:00
Augie Fackler
6e173310bf run-tests: write bytes to sys.stdout.buffer in python 3 2015-04-14 16:02:49 -04:00
Augie Fackler
cf6a74f39e run-tests: be more judicious about bytes vs string on test attrs
This introduces a bname attribute for when we need to use the test
name in a path, and retains name for when we need it as a
string. Sadly, we seem to need both of these.
2015-04-14 15:59:59 -04:00
Augie Fackler
4288fc8b03 run-tests: fix _findprogram to reliably return bytes 2015-04-14 15:56:44 -04:00
Augie Fackler
ebd29548f7 run-tests: introduce a name for os.environb
On python 2 this is just os.environ, but on python 3 we need to get to
os.environb in several places.
2015-04-14 15:54:13 -04:00
Augie Fackler
36659f92fa run-tests: work around chr() producing unicode in Python 3 2015-04-14 15:52:45 -04:00
Augie Fackler
a3a18d4564 run-tests: use bytes when constructing shell script 2015-04-11 18:28:32 -04:00
Augie Fackler
b38221d4c6 run-tests: use bytes explicitly for tmpdir and hgrc construction
We now get slightly further on Python 3. Python 2.6 still works.
2015-04-11 18:26:58 -04:00
Augie Fackler
cadeb14bd6 run-tests: work around the rename of xrange to range 2015-04-11 18:22:25 -04:00
Augie Fackler
02bdc3f67d python3: update killdaemons and run-tests print and exception syntax
test-run-tests.t still passes fine on Python 2.6. run-tests.py --local
no longer fails with syntax errors, and now fails looking for xrange.

Most changes done with

2to3 -w -f numliterals -f except -f print tests/run-tests.py tests/killdaemons.py

after which one import was fixed in run-tests and a __future__ import
was added.
2015-04-11 18:20:44 -04:00
Pierre-Yves David
f0df3e65f1 run-tests: spread and document the content of time tuple
The spreading will make future modification clearer. The documentation improve
code readability.
2015-05-07 23:25:13 -07:00
Pierre-Yves David
3e15bcde32 run-tests: when building json, get time data in the same order as elsewhere
The json code was changing the order of the time tuple for unclear reasons. We
now use the same order as everywhere else.
2015-05-07 23:16:57 -07:00