Commit Graph

91 Commits

Author SHA1 Message Date
Kyle Lippincott
9d816ecc30 tests: hint how to run slow tests when rejecting 2017-05-26 14:52:54 -07:00
Martin von Zweigbergk
09d53c160b merge with stable 2017-05-12 11:20:25 -07:00
Pierre-Yves David
970619c327 hghave: prefill more version of Mercurial
The previous code was unable to go above version 4.0.
2017-05-09 15:08:47 +02:00
Gregory Szorc
23a56c76db hghave: remove py27+ capability
It is now unused. And we require Python 2.7+ now so this check is not
necessary.
2017-05-08 15:31:34 -07:00
Bryan O'Sullivan
cb19aa07d3 stdio: add Linux-specific tests for error checking 2017-04-11 14:54:12 -07:00
Yuya Nishihara
91f8f53f3a statfs: make getfstype() raise OSError
It's better for getfstype() function to not suppress an error. Callers can
handle it as necessary. Now "hg debugfsinfo" will report OSError.
2017-03-25 17:25:23 +09:00
Yuya Nishihara
aa4a627b31 hghave: use util.getfstype 2017-03-25 18:22:27 +09:00
Jun Wu
06da2c689d hghave: add a check about whitelisted filesystem that supports hardlink
This is needed for the test added by the next patch.
2017-03-12 00:26:20 -08:00
Pierre-Yves David
a51384137e test: add a basic 'test-check-pylint.t'
We add a minimal check using pylint for one case we knows we care about:
"mutable default" argument.

We'll likely extend this over time to cover other useful checks but this is a
good starting point.
2016-12-28 23:42:50 +01:00
Yuya Nishihara
1d44bd2bbb ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.

ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
2016-10-22 14:35:10 +09:00
Gregory Szorc
a002443acc hghave: add check for zstd support
Not all configurations will support zstd. Add a check so we can
conditionalize tests.
2016-11-10 23:38:41 -08:00
Yuya Nishihara
6aeed209ab hghave: check darcs version more strictly
test-convert-darcs.t suddenly started failing on my Debian sid machine. The
reason was Darcs was upgraded from 2.12.0 to 2.12.4 so the original pattern
got to match the last two digits. Fix the pattern to match 2.2+.
2016-11-05 13:20:53 +09:00
Yuya Nishihara
26d053eede hghave: fix 'rmcwd' to ensure temporary directory is removed
On platforms where cwd can't be removed, it should try rmdir() after chdir
to the original cwd.
2016-11-01 21:14:33 +09:00
Yuya Nishihara
85c5af29fa tests: run "cwd was removed" test only if cwd can actually be removed
On some platforms, cwd can't be removed. In which case, util.unlinkpath()
continues with no error since the failure of directory removal isn't critical.
So it doesn't make sense to run the test added by 6395630fdfdc on those
platforms. OTOH, we need to run the test in test-rebase-scenario-global.t
since the repository is referenced after that.
2016-10-26 22:50:06 +09:00
Yuya Nishihara
9acdc7a967 hghave: fix has_bzr() to not try to import RevisionSpec as module
Since RevisionSpec isn't a module, "import bzrlib.revisionspec.RevisionSpec"
would always raise ImportError.
2016-09-04 17:19:44 +09:00
Yuya Nishihara
64a2940225 test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Danek Duvall found that gpg-connect-agent of GnuPG 2.0 never starts gpg-agent
daemon. The 2.1 way is documented as "gpg-coonect-agent /bye" [1], which
appears to be different from the 2.0 way [2].

 [1]: https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html
 [2]: https://www.gnupg.org/documentation/manuals/gnupg-2.0/Invoking-GPG_002dAGENT.html

Since "gpg-agent --daemon" of GnuPG 2.1 never prints environment variables,
"eval $(gpg-agent --daemon)" would be valid only for GnuPG < 2.1, and we'll
need a different workaround for 2.0. I have no 2.0 environment, I won't
implement it.
2016-08-29 22:59:39 +09:00
timeless
eab7889a37 hghave: add demandimport checking 2016-08-25 22:30:35 +00:00
timeless
1e21e7a9f5 hghave: make bzr checks stricter
My bzr does not have bzrlib.revisionspec.RevisionSpec,
and thus tests were failing because convert refused to believe in bzr,
but hghave without this change thought it was available.
2016-08-25 22:51:39 +00:00
Augie Fackler
51a50cbe97 hghave: add a check for unzip(1) that understands symlinks
unzip(1) from the FreeBSD base system does not understand symlinks, so
test-archive-symlinks is busted.
2016-08-25 01:25:52 -04:00
Yuya Nishihara
41507deea4 py3: have check-py3-compat require pygments to get stable result 2016-08-17 20:52:50 +09:00
Yuya Nishihara
7f925d7d30 test-gpg: start gpg-agent under control of the test runner
GnuPG v2 automatically starts gpg-agent. We should kill the daemon process.
2016-08-14 17:01:33 +09:00
Yuya Nishihara
6e8614df57 hghave: fix typo of sslutil.supportedprotocols 2016-07-19 21:16:44 +09:00
Gregory Szorc
6ba507acfc sslutil: more robustly detect protocol support
The Python ssl module conditionally sets the TLS 1.1 and TLS 1.2
constants depending on whether HAVE_TLSv1_2 is defined. Yes, these
are both tied to the same constant (I would think there would be
separate constants for each version). Perhaps support for TLS 1.1
and 1.2 were added at the same time and the assumption is that
OpenSSL either has neither or both. I don't know.

As part of developing this patch, it was discovered that Apple's
/usr/bin/python2.7 does not support TLS 1.1 and 1.2 (only TLS 1.0)!
On OS X 10.11, Apple Python has the modern ssl module including
SSLContext, but it doesn't appear to negotiate TLS 1.1+ nor does
it expose the constants related to TLS 1.1+. Since this code is
doing more robust feature detection (and not assuming modern ssl
implies TLS 1.1+ support), we now get TLS 1.0 warnings when running
on Apple Python. Hence the test changes.

I'm not super thrilled about shipping a Mercurial that always
whines about TLS 1.0 on OS X. We may want a follow-up patch to
suppress this warning.
2016-07-18 11:27:27 -07:00
Gregory Szorc
3601cf654f hghave: add test for Python 2.7+
Setting ciphers in the ssl module requires Python 2.7. Surprisingly,
we didn't have a test for running on Python 2.7.
2016-07-17 10:50:51 -07:00
Gregory Szorc
73bc04ad9d sslutil: pass ui to _defaultcacerts
We'll use this shortly.
2016-07-01 19:04:39 -07:00
Gregory Szorc
2121e65956 tests: better testing of loaded certificates
Tests were failing on systems like RHEL 7 where loading the system
certificates results in CA certs being reported to Python. We add
a feature that detects when we're able to load *and detect* the
loading of system certificates. We update the tests to cover the
3 scenarios:

1) system CAs are loadable and detected
2) system CAs are loadable but not detected
3) system CAs aren't loadable
2016-07-01 19:27:34 -07:00
timeless
223ed96d6d hghave: matchoutput needs to use bytes for regexp
file output is bytes in py3, so we need each regexp to be bytes
2016-05-05 09:07:01 +00:00
Gregory Szorc
051832cb8b sslutil: move code examining _canloaddefaultcerts out of _defaultcacerts
Before, the return of _defaultcacerts() was 1 of 3 types. This was
difficult to read. Make it return a path or None.

We had to update hghave.py in the same patch because it was also
looking at this internal function. I wasted dozens of minutes
trying to figure out why tests were failing until I found the
code in hghave.py...
2016-05-04 23:38:34 -07:00
Kevin Bullock
5296280949 hghave: remove unused check for bdist_mpkg 2016-04-29 14:14:00 -05:00
Augie Fackler
5b68eb5b4f hghave: add check for OS X packaging tools 2016-04-27 11:45:55 -04:00
Augie Fackler
2f69b1cab6 hghave: add check for bdist_mpkg 2016-04-18 23:55:58 -04:00
Sean Farley
51cd78fbe1 tests: relax pattern matching for newer docker 2016-04-15 14:47:32 -07: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
80a5c496d9 hghave: add cvsnt
cvsnt is a maintained commercial fork of cvs
https://en.wikipedia.org/wiki/CVSNT

It is possible to build a version of it from sources (github),
it requires libpcre and libltdl (libtool).

We already have a test that relates to cvsnt:
test-convert-cvsnt-mergepoints.t

cvsnt installs: cvs, cvslockd, cvsnt, cvsscript

I think we should definitely have a check for cvsnt because it makes
the version checks for cvs make a lot more sense.

When I use the version I built, cvs --version says:

"""
Concurrent Versions System (CVSNT) 2.5.05 (Gan) Build 3744 (Suite) (client/server)

CVSNT 2.5.05 (Apr  4 2016) Copyright (c) 2008 March Hare Software Ltd.
see http://www.march-hare.com/cvspro


CVS Copyright (c) 1989-2001 Brian Berliner, david d `zoo' zuhn,

Jeff Polk, and other authors
CVSNT Copyright (c) 1999-2008 Tony Hoyle and others
see http://www.cvsnt.org

Commercial support and training provided by March Hare Software Ltd.
see http://www.march-hare.com/cvspro

CVSNT may be copied only under the terms of the GNU General Public License v2,
a copy of which can be found with the CVS distribution.

The CVSNT Application API is licensed under the terms of the
GNU Library (or Lesser) General Public License.

Specify the --help option for further information about CVS
"""
2016-04-04 06:27:12 +00:00
Yuya Nishihara
bd8b8c2e65 hghave: replace relative import of docutils.core 2016-04-03 19:47:29 +09:00
timeless
f5cd960a9a hghave: add hg06..hg39
hg output varies by version, this helps the hgbook

hg 0.6 did not have a version command, so special case it...
hg 0.7-0.8 had a version command which returned unknown...
hg 0.8 added a --date flag to annotate
hg 0.9 had a working version command!
2016-04-01 13:20:47 +00:00
timeless
6d4cf8d156 hghave: use checkvers for bzr114 2016-04-01 13:19:29 +00:00
timeless
620c0a80fe hghave: replace has_svn13/has_svn15 with checkvers
This would make it possible to easily add a svn14 or svn16 or...
2016-04-01 13:04:41 +00:00
timeless
048ac3436b hghave: add checkvers function 2016-04-01 13:04:16 +00:00
timeless
054ef1ce74 hghave: add docstring for check 2016-04-04 02:17:36 +00:00
timeless
940756392c hghave: update cvs112 description
Classic cvs stopped at 1.11.
There was a beta version 1.12 that never had a final release.
CVS NT is a fork which starts with versions numbered 2.0+.

We should have an hg have cvsnt, but to test that requires getting
cvsnt, and it's commercial / its older source versions are
hard to find.
2016-04-01 13:19:58 +00:00
Gregory Szorc
0bbaa7c0a3 hghave: change ssl check to just check ssl module
Previously, the "ssl" check effectively looked for PyOpenSSL
or Python 2.7.9. After this patch, we simply look for just the
"ssl" module.

After b93c7184b1ea, there have been no references to PyOpenSSL in
the tree (the previous usage of PyOpenSSL was to implement ssl
support on old, no longer supported Python versions that didn't
have an ssl module (e.g. Python 2.4). So, the check for PyOpenSSL
served no purpose.

Pythons we support ship with the ssl module. Although it may not be
available in all installations. So, we still need the check for
whether the ssl module imports, hence the hghave check.

The main side-effect of this change is that we now run test-https.t
(the only test requiring the "ssl" hghave feature) on Python <2.7.9
when PyOpenSSL is not installed (which is probably most installations)
and the ssl module is available. Before, we wouldn't run this test
on these older Python versions.

I confirmed that test-https.t passes with Python 2.6.9 and 2.7.8 on
OS X 10.11.
2016-03-19 13:51:00 -07: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
dd989dbe5f hghave: improve description of Hypothesis 2016-03-08 14:32:03 +00: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
timeless
16cc66dbc7 hghave: support HGMODULEPOLICY for pure
HGMODULEPOLICY was introduced in 78e8dae3a240
2016-01-11 23:13:34 +00:00
Gregory Szorc
dd5b65b197 tests: use absolute_import in hghave.py 2015-12-06 22:27:18 -08:00
timeless
9b03525e5c hghave.py: fix matchoutput documentation 2015-11-24 22:31:56 +00:00
timeless
90609ddfb2 hghave.py: remove execute bit 2015-11-24 22:26:43 +00:00
David R. MacIver
ffbcb6c497 testing: add hypothesis fuzz testing
Hypothesis a library for adding fuzzing over a range of structure
data to your test suite: http://hypothesis.readthedocs.org/en/latest/

This adds the ability to build tests using Hypothesis within the Mercurial test
suite. New tests and fixes using this helpers comes in later changesets.
2015-10-24 12:46:03 +01:00