Commit Graph

10 Commits

Author SHA1 Message Date
Adam Simpkins
dd746f1765 unittests: add option to skip the test-check* tests
Summary:
Update scripts/unit.py with an option to skip running all of the test-check*
tests.  This makes it easier to run just a single specific test when developing
a unit test itself.

Test Plan:
Used "./scripts/unit.py --skip-checks tests/test-smartlog.t" when adding new
tests to test-smartlog.g

Reviewers: #sourcecontrol, stash, mjpieters, rmcelroy

Reviewed By: rmcelroy

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4430919

Signature: t1:4430919:1484820777:08da5f8fd4144bf05c7596db846d827b3680bc3e
2017-01-19 12:52:54 -08:00
Jun Wu
2698cf1d22 scripts: unify spwaning run-test logic
Summary:
Previously, lint.py and unit.py have different logic spawning
run-tests.py.

The logic in `unit.py` is more robust: it sets `PYTHONPATH` and
`cwd`. It sets `-j` according to CPU cores. It can find `run-tests.py`
even if `MERCURIALRUNTESTS` is not set. You can run the script
from any directory (not only reporoot).

Test Plan: Run `lint.py` and `unit.py`, from the `scripts` directory and reporoot.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4095437

Signature: t1:4095437:1477663516:13a7ac4270435c272077132915f9d02cc98a5afb
2016-10-28 13:58:48 +01:00
Jun Wu
dc57735d63 arc: include test-check-code-hg in unit tests
Summary:
Previously, `arc unit` does not run `test-check-code-hg.t` and if people
have ignored lint errors, they may be ignored forever.

Since test-check-code-hg.t is relatively fast (3 seconds), let's also
run it during `arc unit`.

Test Plan: `arc unit` and confirm test-check-code-hg shows up.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4051073

Signature: t1:4051073:1476985307:5448827437ecee9add534855a0f87ac3c3bd1f84
2016-10-20 15:44:26 +01:00
Adam Simpkins
27acd63250 [arc] honor paths specified by "arc unit"
Summary:
Update MercurialTestEngine.php and the unit.py script to honor the list of
changed files computed by arcanist.

Previously the unit.py script always used the files that were changed since the
".^" commit.  At best this was doing redundant work since arc had already
computed the list of files to test.  At worst this was testing the wrong files
if arc had been invoked with a list of explicit files to check.

Test Plan:
Ran "arc unit tests/test-mergedriver.t" and confirmed it ran the
test-mergedriver.t test, regardless of the changes in my current commit and
working directory.  Confirmed that "arc unit" with no path arguments still
ran the tests relevant to my local changes.

Reviewers: quark, rmcelroy, mjpieters

Reviewed By: mjpieters

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4004727

Signature: t1:4004727:1476258607:d6adb5ec3d677f6d93016a994cadaa7a48df353a
2016-10-13 11:48:02 -07:00
Adam Simpkins
8d1252d8d3 [unit] minor refactoring of interestingtests()
Summary:
This is just a minor performance clean-up of interestingtests(), even though
performance probably isn't a big deal here (unless we eventually get a very
large number of tests).

The old code was calling words(path) once per test file (for each path), rather
than just once.  I cleaned up the code so that we only call it once per path.

I also updated the code to build testwords as a dictionary so we can do an easy
lookup to find relevant tests for a given word, rather than having to do a
linear scan of all tests.  We now also don't bother computing the words for
test-check* tests.

Test Plan:
Manually confirmed that interestingtests() returns the expected test lists for
a variety of input paths.

Reviewers: simonfar, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3935730

Signature: t1:3935730:1475052012:08b9a495c7c3e7fc2d0b9eaa097d5286874edf46
2016-09-28 12:08:10 -07:00
Adam Simpkins
68222e17e9 [unit] fix computation of changed files
Summary:
Make sure a nul byte is printed between the list of files changed in the
working directory and the files changed in the parent commit.

Previously these two lists were printed back-to-back, causing the last path
from the working directory to be joined with the first path from the parent
commit.

Also return the results as a set so we exclude duplicates if a file was changed
both in the working directory and in the current commit.

Test Plan:
Manually printed the changedfiles computed, and confirmed that the lists were
correct.

Reviewers: simonfar, durham, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3935654

Signature: t1:3935654:1475053555:66da9102e312d8d345d00c4d41f76d41ce673069
2016-09-28 11:59:55 -07:00
Adam Simpkins
4f37b53188 Various improvements to scripts/unit.py
Summary:
- Set PYTHONPATH so we actually test the extensions from the local repository
  rather than the versions installed in the system's normal python library
  directories.
- Invoke the test runner directly with subprocess, rather than via a subshell,
  and always wait for it to exit, even if we receive an interrupt during the
  test run.
- Various other minor refactoring of argument parsing and handling of the json
  results file.

Test Plan:
Ran scripts/unit.py and confirmed it tested the local version of remotefilelog,
rather than the system version.

Reviewers: durham, simonfar, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3935628

Tasks: 13595089

Signature: t1:3935628:1475052856:61480fddbf97c830496257b89be3999364ab7c31
2016-09-28 12:10:17 -07:00
Jun Wu
230550558a arc: do not pollute tty when running arc unit
Summary: It breaks CLI vim users.

Test Plan: Code Review

Reviewers: durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3915796

Signature: t1:3915796:1474662158:dfca849d9aa2914e799c267205178db67860d2d1
2016-09-23 21:20:46 +01:00
Adam Simpkins
1a72bd37c9 Make sure "arc unit" doesn't crash if there are no tests to run
Summary:
Make sure we write an empty results lists even if there are no interesting
tests to run.

(Alternatively, I could have made MercurialTestEngine.php handle a null result
from json_decode(), but this could also mean that the json results were
invalid, or that they had encoded data deeper than json_decode()'s recursion
limit.  Making sure unit.py always writes a result means we will still bail out
as desired if the result file was bogus for some reason.)

Test Plan: Ran "arc unit" on this diff.

Reviewers: simonfar, quark

Reviewed By: simonfar, quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3911461

Signature: t1:3911461:1474623139:f04f78dd5d5fa59f83e1171d21608eb38647142f
2016-09-23 12:35:31 -07:00
Jun Wu
71c96fe8ea arc: implement an arcanist unittest engine for mercurial
Summary:
This makes `arc unit` work for the repo.
Hopefully it helps improve the code quality.

Test Plan:
Run `arc unit`. Make some changes locally to confirm
it can handle skipped and failed tests.

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3889495

Signature: t1:3889495:1474454314:b3fb7e538979c775f8301d9abdad0d6eda71e411
2016-09-19 22:41:58 +01:00