Commit Graph

942 Commits

Author SHA1 Message Date
Jun Wu
c3355e8af9 run-tests: use "hg debugpython" instead of "python" to run tests
Summary: This makes the test runner compatible with the next change.

Reviewed By: singhsrb

Differential Revision: D17429690

fbshipit-source-id: 100d2c9f341cfc64be22137b7013f5b234005771
2019-09-20 18:32:35 -07:00
Jun Wu
57e6e896ad testutil/dott: simplify error messages
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
2019-09-10 13:01:33 -07:00
Jun Wu
1493c68d40 run-tests: make -i/--update-output/--fix autofix Python t.py tests
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
2019-09-10 13:01:33 -07:00
Jared Bosco
6bf5f920ee hgmain: implement native hg root command with new dispatch library
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
2019-07-26 20:38:50 -07:00
Xavier Deguillard
ec9ec06360 run-tests: add testpilot test runner
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
2019-07-19 11:47:04 -07:00
Xavier Deguillard
f9b4c4917a run-tests: return a success error code when tests are skipped
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
2019-07-18 15:54:21 -07:00
Kostia Balytskyi
45a372b238 run-tests: replace try-finally block with a context manager
Summary:
Can do os as per
https://docs.python.org/2/library/threading.html#using-locks-conditions-and-semaphores-in-the-with-statement

Reviewed By: xavierd

Differential Revision: D16028590

fbshipit-source-id: 70c37b65fc497ff87a09deb155d719ceb2bbcfb2
2019-06-27 10:16:31 -07:00
Kostia Balytskyi
8d68e40dd2 run-tests: do not rely on PYTHONPATH for heredoctest
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
2019-06-27 06:42:45 -07:00
Kostia Balytskyi
85e0a72826 run-tests: do not set PYTHONUSERBASE on Windows
Summary: This was causing `Popen` to crash, since `env` had non-strings (`NoneType`)

Reviewed By: mitrandir77

Differential Revision: D16009578

fbshipit-source-id: cbed384b7d773e3de23f9a8920d85296c5deec85
2019-06-26 12:40:29 -07:00
Kostia Balytskyi
9125f0d9e8 run-tests: avoid dead lock when calling a child process
Summary: If `subprocess.Popen` crashes, the lock is never released.

Reviewed By: mitrandir77

Differential Revision: D16009579

fbshipit-source-id: e27137826ffb29aa1f497a3c4c85160b183f2a51
2019-06-26 12:40:29 -07:00
Thomas Orozco
26c6765128 run-tests: conditonally report execution time in milliseconds
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
2019-06-21 03:50:28 -07:00
Jun Wu
a17a87bf4f setup: move native extensions to edenscmnative
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
2019-06-19 17:55:49 -07:00
Durham Goode
ad813edcbd treemanifest: enable treemanifest by default in tests
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
2019-05-28 03:17:02 -07:00
Durham Goode
65a9f2ac94 treemanifest: set reponame and cachepath by default
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
2019-05-10 09:59:54 -07:00
Durham Goode
9e90a464ee treemanifest: add flatcompat mode for test migration
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
2019-05-10 09:59:53 -07:00
Mark Thomas
0cc0028d21 run-tests: don't disable linewrapping if there is nothing to output
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
2019-04-09 13:31:56 -07:00
Mark Thomas
d0edbd5b64 run-tests: don't disable linewrap all the time
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
2019-04-09 03:37:44 -07:00
Jun Wu
58027d450b runtests: add --update-output flag
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
2019-03-08 17:15:52 -08:00
Wez Furlong
45a59ef1d4 hg: run-tests: treat a parse error as return code 1
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
2019-02-07 18:58:40 -08:00
Jun Wu
9dc21f8d0b codemod: import from the edenscm package
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
2019-01-29 17:25:32 -08:00
Mark Thomas
45ac931774 run-tests: close child stdout after running test
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
2018-12-19 07:53:02 -08:00
Mark Thomas
49ebfc610d run-tests: fix escape sequences
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
2018-12-19 07:53:02 -08:00
Kostia Balytskyi
3e70d22bf6 hgbuild: run all tests with hg.rust rather than with python-based hg
Summary: Since we are using `hg.rust` with everything, we should also test it.

Differential Revision: D13121588

fbshipit-source-id: 3a4e07c1d70c279f008812d026bf9a7c74aa3b2e
2018-11-22 07:41:41 -08:00
Kostia Balytskyi
e788232917 chg: make sure CHGDISABLE is set for non-chg tests
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
2018-11-19 06:15:32 -08:00
Jun Wu
a906cd90a0 run-tests: use Rust RLock implemenation if possible
Summary:
The Rust implemenation has a smaller chance to have deadlock issues when
interruptted.

Reviewed By: markbt

Differential Revision: D10843400

fbshipit-source-id: af5614b9992577bde74cf54c5760d15d050aafbf
2018-10-25 13:12:00 -07:00
Zsolt Dollenstein
64d45ccdb6 Format with black 18.9b0
Summary: Reformat all opted-in python code with version `18.9b0` of Black.

Reviewed By: ambv

Differential Revision: D10126605

fbshipit-source-id: 82af0d645dd411ce8ae6b8d239e151b3730cd789
2018-10-01 07:21:42 -07:00
Jun Wu
20a01dee08 run-tests: improve reliability killing hang tests
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
2018-08-27 13:05:30 -07:00
Jun Wu
1fe370b4f9 run-tests: add progress bars
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
2018-08-27 13:05:30 -07:00
Jun Wu
b14232f56c run-tests: truncate diff output
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
2018-08-27 13:05:30 -07:00
Jun Wu
783b7ae902 windows: use MSYS binaries to support run-tests.py
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
2018-08-27 11:36:42 -07:00
Jun Wu
a987ecb9b2 ui: use Rust config parser in Mercurial
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
2018-08-23 17:52:52 -07:00
Jun Wu
e082921ddc run-tests: remove warning about entry point does not exist
Summary:
It breaks test-runtests.t when running with buck:
https://fburl.com/testinfra/7ui6uffp

Reviewed By: singhsrb

Differential Revision: D9436487

fbshipit-source-id: caa01f5d5c2d60cd0bd197a1d1b6269e64c98df7
2018-08-21 13:35:26 -07:00
Kostia Balytskyi
0598171436 hg: fix linux test failure
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
2018-08-21 07:51:24 -07:00
Jun Wu
159468b58f run-tests: set HGPYENTRYPOINT explicitly
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
2018-08-20 17:05:24 -07:00
Jun Wu
8b421e16c4 run-tests: do not set lfs.usercache
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
2018-07-27 20:06:07 -07:00
Jun Wu
a5dfe6b736 run-tests: explicitly close fds when spwaning watchman
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
2018-07-13 17:21:02 -07:00
Jun Wu
4ce060d4c7 run-tests: use a shorter watchman sock dir
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
2018-07-13 17:21:02 -07:00
Phil Cohen
b05631eff7 tests: remove the testreport= prefix in report.json
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
2018-07-09 13:36:27 -07:00
Jun Wu
4c9d79b852 fsmonitor: add a race detector
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
2018-06-25 19:51:40 -07:00
Jun Wu
7f750a43a1 run-tests: wait watchman in a loop
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
2018-06-21 18:50:07 -07:00
Jun Wu
321c62d02a run-tests: return non-zero if there is an error
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
2018-06-21 18:50:07 -07:00
Jun Wu
bac05845b8 run-tests: wait watchman before using it
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
2018-06-20 19:35:31 -07:00
Jun Wu
64c3b8c2ab run-tests: add --watchman and --with-watchman flags
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
2018-06-14 18:49:24 -07:00
Jun Wu
776584f6fc run-tests: use basename when showing test errors
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
2018-06-11 18:32:36 -07:00
Lukasz Langa
dfda82e492 Upgrade to 18.5b1
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
2018-05-30 02:23:58 -07:00
Jun Wu
584656dff3 codemod: join the auto-formatter party
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
2018-05-25 22:17:29 -07:00
Saurabh Singh
32da3b0259 run-tests: change the default hg shell for tests to bash
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
2018-04-13 21:51:50 -07:00
Jun Wu
901e92e858 colors: improve compatibility
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
2018-04-13 21:51:40 -07:00
Jun Wu
3d8a2aa583 color: support fallback configs
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
2018-04-13 21:51:36 -07:00
Jun Wu
c6742cd74c run-tests: source tinit.sh for all .t tests
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
2018-04-13 21:51:20 -07:00