Summary: This makes the test runner compatible with the next change.
Reviewed By: singhsrb
Differential Revision: D17429690
fbshipit-source-id: 100d2c9f341cfc64be22137b7013f5b234005771
Summary:
The current error message is a bit noisy. Let's just get to the point about the
filename and line number that is interesting without tracebacks. This only
affects functions using the `autofix.eq` API, other kinds of exceptions will
have tracebacks as usual.
Before, run-tests.py (19 lines):
--- test-empty-t.py.out
+++ test-empty-t.py.err
@@ -0,0 +1,14 @@
+Traceback (most recent call last):
+ File "hg/tests/test-empty-t.py", line 71, in <module>
+ """
+ File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
+ autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
+ File "hg/tests/testutil/autofix.py", line 93, in eq
+ raise AssertionError("actual != expected\n%s" % diff)
+AssertionError: actual != expected
+--- expected
++++ actual
+@@ -1 +1 @@
+-someheads
++allheads
+
ERROR: test-empty-t.py output changed
Before, run directly via python (13 lines):
Traceback (most recent call last):
File "test-empty-t.py", line 71, in <module>
"""
File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
File "hg/tests/testutil/autofix.py", line 93, in eq
raise AssertionError("actual != expected\n%s" % diff)
AssertionError: actual != expected
--- expected
+++ actual
@@ -1 +1 @@
-someheads
+allheads
After, run-tests.py (8 lines):
--- test-empty-t.py:71 (expected)
+++ test-empty-t.py:71 (actual)
@@ -1 +1 @@
-someheads
+allheads
ERROR: test-empty-t.py output changed
After, run directly (5 lines):
% python test-empty-t.py
--- test-empty-t.py:71 (expected)
+++ test-empty-t.py:71 (actual)
@@ -1 +1 @@
-someheads
+allheads
Reviewed By: xavierd
Differential Revision: D17277286
fbshipit-source-id: a48d4d1e817f67e221a901977e0c0f8bdc1a62ab
Summary:
Previously `python --fix test-foo-t.py` is the only way to autofix the test.
That's a bit annoying because `run-tests.py` has more features (ex. run many
tests together).
This diff changes `run-tests.py` to pass `--fix` to Python `-t.py` tests so
the autofix works in a familiar way. `--fix` was added as an alias to
`--update-output` to make it consistent with the Python UX.
Reviewed By: xavierd
Differential Revision: D17277287
fbshipit-source-id: e815a79895161862d844de165710cc36d6709727
Summary:
Implement `hg root` in Rust with the `clidispatch` library as well as adding all current Python commands so that prefix matching still works as expected.
This diff does not remove `hg root` from Python or expose native command documentation to Python, which will be the next diff.
Reviewed By: quark-zju
Differential Revision: D16454053
fbshipit-source-id: 78a9c70aeefb9adbb85c77001b15eab652417b2c
Summary:
Testpilot can give us a lot of things for free, including the automatic
detection of flaky tests, disabling of them, re-enabling too, easy retries on
failure, timeouts, better tracking, and the list goes on.
At a first step, I'd like to make the testpilot runner the default in hgbuild
to get all the benefits listed above.
Reviewed By: quark-zju
Differential Revision: D16294182
fbshipit-source-id: aadfbac9eb05e9d64336daba7a50a6263e38c162
Summary:
As run-tests.py will be used with testpilot and at diff time, we do not
want to fail a run when all the tests were simply skipped. Let's make
that a success instead.
Reviewed By: quark-zju
Differential Revision: D16364297
fbshipit-source-id: ef8e912ddde91bd5be52784fceaf012857841eea
Summary:
PYTHONPATH is no longer a thing on Windows. Let's not rely on it
for our `heredoctest.py`-based tests
Reviewed By: mitrandir77
Differential Revision: D16028830
fbshipit-source-id: ae66d9cf194c7e3c15e44a81a18dfeeb4b68e281
Summary: This was causing `Popen` to crash, since `env` had non-strings (`NoneType`)
Reviewed By: mitrandir77
Differential Revision: D16009578
fbshipit-source-id: cbed384b7d773e3de23f9a8920d85296c5deec85
Summary: If `subprocess.Popen` crashes, the lock is never released.
Reviewed By: mitrandir77
Differential Revision: D16009579
fbshipit-source-id: e27137826ffb29aa1f497a3c4c85160b183f2a51
Summary: This updates `run-tests.py` to report times in milliseconds if we're running under TestPilot. This is useful because TestPilot diverges a bit from the JUnit spec in the sense that it expects time to be in milliseconds, not seconds.
Reviewed By: StanislavGlebik
Differential Revision: D15938672
fbshipit-source-id: a421b523931abfdf5da10e6702739cecf00a4cdd
Summary:
This just moves things around. So native and pure Python modules are split to
different Python packages. This makes it possible to use the standard zip
importer without hacks (ex. `hgdemandimport/embeddedimport`).
This diff is mostly about moving things. While `make local` still works,
it does break nupkg build, which will be fixed in a later diff.
Reviewed By: kulshrax
Differential Revision: D15798642
fbshipit-source-id: 5d83f17099aa198df0acd5b7a99667e2f35fe7b4
Summary:
Now that all our repos are treemanifest, let's enable the extension by
default in tests. Once we're certain no one needs it in production we'll also
make it the default in core Mercurial.
This diff includes a minor fix in treemanifest to be aware of always-enabled
extensions. It won't matter until we actually add treemanifest to the list of
default enabled extensions, but I caught this while testing things.
Reviewed By: ikostia
Differential Revision: D15030253
fbshipit-source-id: d8361f915928b6ad90665e6ed330c1df5c8d8d86
Summary:
We want to migrate the tests to run using treemanifest. As part of
that, we need remotefilelog reponame and cachepath to always be set. So let's
set that for all tests now.
Differential Revision: D15030250
fbshipit-source-id: 4147997ceebb1294deb322bdbef77b6caab18c44
Summary:
We want to migrate the tests to run using treemanifest. As part of
that, we want to first transition to using treemanifest without actually
changing the hash, so we can check that the tests still work first, then update
the hashes second.
This diff adds the flatcompat mode and enables it by default. A future diff will
start enabling treemanifest for existing tests.
Reviewed By: quark-zju
Differential Revision: D15030252
fbshipit-source-id: 06c82be749282d62f1d9cfb43246695c427f8165
Summary:
The tests for run-tests expect there to be no linewrapping control characters
output when there are no progress lines to print. Make sure they only get
printed if there are lines to print.
Reviewed By: DurhamG
Differential Revision: D14851271
fbshipit-source-id: 4004f848e2e205d36bd0dd107ced2fe9d69e31d8
Summary:
The progress indicator for run-tests.py disables terminal line wrapping at the
start of run-tests, and re-enables it at the end. This causes two problems:
* Diff output is not wrapped, so only the start of changed lines are visible.
* Sometimes run-tests.py exits without restoring line wrapping. In this case
the shell session is adversely affected.
Disabled line wrapping is only necessary when outputting the progress, so
restrict it to there.
Reviewed By: quark-zju
Differential Revision: D14834719
fbshipit-source-id: 2c0380e7e1a1d5be195b025c252c80208e83a545
Summary:
Add a `--update-output` flag to answer "yes" for all `-i` prompts.
Also add an "all" option for the `-i` prompt.
This is useful to apply changes to a large range of tests.
Reviewed By: DurhamG
Differential Revision: D14233452
fbshipit-source-id: ebfc5c9a897a7fc7fea779aefef538e420e1e197
Summary:
previously, unexpected output would cause the harness to
stack trace and not show the actual test failure.
This catches the error and treats it as a failed run, which causes
the test output to be displayed.
No more `ValueError: invalid literal for int() with base 10: '0\xe2\x90\x8a'`
Reviewed By: DurhamG
Differential Revision: D13995000
fbshipit-source-id: 5c1a9e8d6f8e81a924cdbf760fa75cdc0d33b74d
Summary:
D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`.
That has nasty problems if both `import mercurial` and
`import edenscm.mercurial` are used, because Python would think `mercurial.foo`
and `edenscm.mercurial.foo` are different modules so code like
`try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)`
would fail to handle the `edenscm.mercurial` version. There are also some
module-level states (ex. `extensions._extensions`) that would cause trouble if
they have multiple versions in a single process.
Change imports to use the `edenscm` so ideally the `mercurial` is no longer
imported at all. Add checks in extensions.py to catch unexpected extensions
importing modules from the old (wrong) locations when running tests.
Reviewed By: phillco
Differential Revision: D13868981
fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
Summary:
Tests don't close the child process stdout. On newer versions of Python, this
can lead to ResourceWarnings when the test runner thread terminates.
Reviewed By: HarveyHunt
Differential Revision: D13517425
fbshipit-source-id: 6cedf4f39efe1299c41dbde784daf8c159309640
Summary:
Some of the escape sequences in run-tests.py are invalid. These cause
DeprecationWarnings on newer versions of Python.
In both cases, there are `\` characters that need to be escaped as `\\`.
Reviewed By: HarveyHunt
Differential Revision: D13517137
fbshipit-source-id: a899c3c28d55210f5972a515474a2fa69d051671
Summary: Since we are using `hg.rust` with everything, we should also test it.
Differential Revision: D13121588
fbshipit-source-id: 3a4e07c1d70c279f008812d026bf9a7c74aa3b2e
Summary: Now that `chg` is embedded into `hg.rust`, we need to explicitly disable it while tests run.
Reviewed By: quark-zju
Differential Revision: D13021560
fbshipit-source-id: 843045f3bc9d9866e421f0bf0aa132849e5b338f
Summary:
The Rust implemenation has a smaller chance to have deadlock issues when
interruptted.
Reviewed By: markbt
Differential Revision: D10843400
fbshipit-source-id: af5614b9992577bde74cf54c5760d15d050aafbf
Summary: Reformat all opted-in python code with version `18.9b0` of Black.
Reviewed By: ambv
Differential Revision: D10126605
fbshipit-source-id: 82af0d645dd411ce8ae6b8d239e151b3730cd789
Summary:
Write a test that hangs forever, like:
$ hg init
$ hg serve -p 0
`run-tests.py --timeout 3` cannot handle it (on both Windows and Linux). It
only tries to kill the bash process, and the `hg serve` process stays running.
For some reason, existing tests are more likely hang on Windows. Therefore we
need a way to reliably kill processes and their descendants. Windows provides
Job Object [1] which reliably solves the problem.
On POSIX, process group is used. It's less reliable because processes can
escape from the group by using setpgid, etc. But it's already better than
before.
[1]: https://docs.microsoft.com/en-us/windows/desktop/procthread/job-objects#managing-processes-in-jobs
Reviewed By: phillco
Differential Revision: D9516042
fbshipit-source-id: 970fce7ba24d0e9bafd66438354de2e6df761edf
Summary:
Similar to buck. Show progress for running tests.
This also improves Ctrl+C handling. It's now more
responsive since we no longer wait for the entire
output.
Reviewed By: phillco
Differential Revision: D9516040
fbshipit-source-id: 98b29228177510855e29da341198697da940884c
Summary:
`.t` tests are stateful. This means if some early parts do not execute
as the test expect, the the remaining parts can break in funny ways,
and generate lots of uninteresting output.
Limit the length of the diff output so the "likely" boring parts won't show
up by default. The change can be overridden by `--maxdifflines`.
Reviewed By: phillco
Differential Revision: D9516041
fbshipit-source-id: 6c998cdc73ae4a45e2f4167c22c04df51392da29
Summary:
MSYS provides binaries that tests need so we no longer
depend on system binaries, which might be broken.
MSYS can provide `make.exe` to make `make local` working,
so we don't depend on other things to provide `make`.
As we're here, change `run-tests.py` to use the right Python
interpreter and escape Windows paths.
Reviewed By: phillco
Differential Revision: D9505926
fbshipit-source-id: f17e77dfc599069d4fe849057b7a198758c2dd42
Summary:
Switch `ui.load` and `ui.readconfig` to use the Rust config parser.
`ui` now no longer depends on `config.config` or `rcutil`.
Pest's error messages are fancier, thus most test changes.
For the fbsource repo, debugshell shows the new code is 10+x faster:
On laptop:
Before:
In [1]: %timeit m.ui.ui.load()
10 loops, best of 3: 27.8 ms per loop
After:
In [1]: %timeit m.ui.ui.load()
100 loops, best of 3: 1.85 ms per loop
On devserver:
Before:
In [1]: %timeit m.ui.ui.load()
100 loops, best of 3: 16.8 ms per loop
After:
In [1]: %timeit m.ui.ui.load()
1000 loops, best of 3: 1.28 ms per loop
Since `ui._rcfg` is no longer copy-on-write, there is concern about `ui.copy()`
performance. It is faster too (on devserver):
Before:
In [1]: %timeit ui.copy()
1000 loops, best of 3: 198 µs per loop
After:
In [1]: %timeit ui.copy()
10000 loops, best of 3: 157 µs per loop
The old `ui.py` was copied to `legacyui.py` and can replace the new `ui.py` if
a config file exists on the system. This provides a way to switch back to the
old config parser in case of emergency.
Reviewed By: mitrandir77
Differential Revision: D8887375
fbshipit-source-id: 2951ca622c77bf41187ad5c5cab3445cda0dc519
Summary:
Generally, it seems the `mercurial/entrypoint.py` approach might need some
more thinking, but in this particular case I'd prefer to just fix the tests.
Here's what's going wrong:
- D9407009 intoduced a logic to expect `mercurial/entrypoint.py` to always
exist under the `hg` installation on a *run-tests* level
- `run-tests.py test-run-tests.t` however runs `run-tests.py` (yo dawg), while
`hg` is a symlink to `$(which true)`
- while the `mercurial/entrypoint.py` script cannot be found by the test
suite in this case, it's not important becuase no real Mercurial is run.
Therefore, I propose to change `SystemExit` to `log`. On one hand, the absense
of `mercurial/entrypoint.py` is a big deal, so we should know about it. On the
other, this case can run completely without it. In the dominant majority of the
other test cases, we'll learn about the absense of `mercurial/entrypoint.py`
by means of the failing Mercurial call.
Generally, this migth require some more thought, but for now let's fix tests.
Reviewed By: lukaspiatkowski
Differential Revision: D9421433
fbshipit-source-id: e39628015ff96f27368b99ec1f99145c0cb1ae7b
Summary:
The run-tests script symlinks hg to a place and sets `PATH` so `hg` can be
called from anywhere without requiring the local shell settings, including
"dummy-ssh" server side.
The Rust `hgmain` uses
`env::current_exe().parent().join("mercurial/entrypoint.py")` to locate
the `entrypoint.py` file. However, `env::current_exe()` does not follow
symlink on OSX, unlike Linux. Therefore the entrypoint.py cannot be located on
OSX.
`hgmain` also reads `HGPYENTRYPOINT`. So let's set it explicitly from
run-tests.py.
Reviewed By: singhsrb
Differential Revision: D9407009
fbshipit-source-id: db9a55e11b424625a6ab58afdbebf0944c7012f5
Summary:
Setting `lfs.usercache` means every LFS object is available globally
for the test. Some tests would like to test pushing LFS objects from
one repo to another. This config hides real issues.
Reviewed By: DurhamG, zhh95
Differential Revision: D8986784
fbshipit-source-id: 3f8d925b28acfe1c6b8ebcb02bd3815642747629
Summary:
Previously, the watchman forground server could inherit other fds (ex. the one
that waits for "watchman --version --no-spawn" output) and cause the read of
"watchman --version" to take forever. This patch closes related fds to solve
the issue.
Reviewed By: wez
Differential Revision: D8846430
fbshipit-source-id: d65f3377ac3b2277d1be7149a4ceb590f9a184a2
Summary:
When running all tests with watchman, I noticed there are other tests that fail
with the sock path length limit. So let's just pick a shorter path in
run-tests.py.
Remove `#require no-fsmonitor` that is no longer necessary.
Reviewed By: phillco
Differential Revision: D8844485
fbshipit-source-id: 2d3c40bf33868c65517adf98d6c1e8b4cb46697a
Summary: This prefix makes this file harder because it isn't valid JSON. Per discussion with quark-zju, remove it.
Reviewed By: singhsrb
Differential Revision: D8769139
fbshipit-source-id: f45703c963898202775e90d536dde2894e5029bb
Summary:
Add a config option `fsmonitor.detectrace` and environment variable
`HGDETECTRACE`. Once set, perform an additional query to check if there are
writes to the working copy while `wctx._buildstatus()` is being calculated.
Also enable the race detector for all fsmonitor tests.
Reviewed By: wez
Differential Revision: D8597957
fbshipit-source-id: 5d83d529641325dc8d5e72ad059eed8db27d1f2a
Summary: It turned out that a waiting loop is necessary, at least on my laptop.
Reviewed By: DurhamG
Differential Revision: D8560023
fbshipit-source-id: 8efd8dca4c630a30e5ccb140eb4f2da8a0cc5717
Summary:
While writing the test, I noticed the test didn't error out as expected:
```
% ./run-tests.py test-treestate-downgrade.t -i --watchman
E
Errored test-treestate-downgrade.t: Traceback (most recent call last):
File "./run-tests.py", line 1064, in run
self.setUp()
File "./run-tests.py", line 1053, in setUp
raise RuntimeError("timed out waiting for watchman")
RuntimeError: timed out waiting for watchman
(exit code 0)
```
This means buck test which relies on exit code will treat those tests as
"successful". That's incorrect. So let's change the exit code.
Reviewed By: DurhamG
Differential Revision: D8560021
fbshipit-source-id: 4f98772099c559e59288e42165386f1069086377
Summary:
After spawning the watchman process, there is a small window before the
watchman process listening on the specified socket file. If hg tests run
during that window, they might fail with watchman unavailable problems.
Therefore, change run-tests.py to wait for watchman by testing
`watchman version`.
Reviewed By: DurhamG
Differential Revision: D8523989
fbshipit-source-id: c5cb2366f938c0617fdd14d232f879b7cdc46b30
Summary:
Similar to chg. Add flags to run tests with watchman. This is mostly moving
features from `fsmonitor-run-tests.py`. The blacklist is converted to
`#require no-fsmonitor`.
Reviewed By: phillco
Differential Revision: D8434518
fbshipit-source-id: a8512cd71c1171e9037f36dbef195f1e6210f27e
Summary:
The current buck test outputs failures like:
--- /xxx/xxxxx/xxxxx-xx-xxxxxx-xxxxxxx-529-1528508531/xxxxxx/xxx/hg/tests/test-fb-hgext-sparse-extensions.t
+++ /xxx/xxxxx/xxxxx-xx-xxxxxx-xxxxxxx-529-1528508531/xxxxxx/xxx/hg/tests/test-fb-hgext-sparse-extensions.t.err
....
The file name is too long. It's nicer to just get to the point and show the
basename:
--- test-fb-hgext-sparse-extensions.t
+++ test-fb-hgext-sparse-extensions.t.err
So this patch does that.
Reviewed By: phillco
Differential Revision: D8360547
fbshipit-source-id: 103929747944e819441a428d30dd6c6516439a71
Summary: Mostly empty lines removed and added. A few bugfixes on excessive line splitting.
Reviewed By: quark-zju
Differential Revision: D8199128
fbshipit-source-id: 90c1616061bfd7cfbba0b75f03f89683340374d5
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
Summary:
Our tests use features that are provided by the bash shell to function
properly. I ran into issues with our tests on Ubuntu because the default shell
was `dash` which did not even support the `source` command. Therefore, this
commit changes the default hg shell for the tests to `bash`. Clients can always
override the default hg shell for the tests to another shell.
Reviewed By: quark-zju
Differential Revision: D7563733
fbshipit-source-id: e9c16c002793a919a49292a9aa0a876ba232c293
Summary:
- Support 8 color mode, since some terminals (emacs) do not support 16
colors (i.e. "bright*" colors have no effects).
- Detect emacs and use 8 color mode automatically.
- Read terminfo colors. Respect it if it says the terminal supports more
colors. Suggested by wez.
- Read HGCOLORS. Respect it unconditionally. Change run-tests.py to set it.
- Change diff related colors to also fallback to 8 colors since "bright"
colors are not guaranteed available.
Differential Revision: D7432965
fbshipit-source-id: da75829f856b4de737b946af72d24ff5351026cb
Summary:
Allow color config to be something like `color132:red` that is to use 256
color if supported, but fallback to `red`.
To get a consistent test output. `run-tests.py` is changed to disable 256
color support explicitly.
Reviewed By: singhsrb
Differential Revision: D7388277
fbshipit-source-id: da74ae8fc70c971901d56a6985976db44cbec0d9
Summary:
`.t` tests have some highly repeatitive logics, like creating a repo, etc.
This patch adds a common shell file that defines frequently used functions.
For now, `newrepo` and `enable` are added. The latter can be used to
enable a feature (ex. obsstore), or an extension.
`test-fb-hgext-fbamend-next.t` and `test-fb-hgext-absorb.t` are migrated
to use the new shell functions.
Reviewed By: phillco
Differential Revision: D7121485
fbshipit-source-id: 167fcc20e4e30864199b6c5af0958b80bfb68817