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
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
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
Summary: This is more robust and keeps the style consistent throughout
Test Plan: ran tests against zsh and bash
Reviewers: #sourcecontrol, ttung, zamsden
Reviewed By: zamsden
Subscribers: zamsden, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3597346
Signature: t1:3597346:1469073711:de76132bd9c161242d8d8171da765ddb54a806a2
Summary:
The old scm-prompt uses this longer, less awesome name.
Let's be backwards compatible with this and all that jazz.
Test Plan: tests pass under bash and zsh
Reviewers: #sourcecontrol, ttung, quark
Reviewed By: quark
Subscribers: quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3597315
Signature: t1:3597315:1469153052:98600400bb3cabf561294fd62f7cc601c280a1bd
Summary:
Previously, aliases could screw up scm-prompt. We had seen earlier
issues with this (thus the --color=never), but this is a more generic and
robust solution, applied everywhere.
We can't use full paths because they differ on different hosts, so we still
rely on a reasonable $PATH, as we always have.
Test Plan: ran scm-prompt tests under bash and zsh
Reviewers: #sourcecontrol, ttung, zamsden
Reviewed By: zamsden
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3597300
Tasks: 12298139
Signature: t1:3597300:1469060969:e88be6bd79234167f039f2964117a738ffbb95f5
Summary:
we weren't matching this pattern:
```
$ ./scripts/lint.py
+++ /data/users/wez/facebook-hg-rpms/fb-hgext/tests/test-check-code-hg.t.err
@@ -37,6 +37,8 @@
Skipping fastmanifest/tree_copy_test.c it has no-che?k-code (glob)
Skipping fastmanifest/tree_diff.c it has no-che?k-code (glob)
Skipping fastmanifest/tree_diff_test.c it has no-che?k-code (glob)
+ Skipping fastmanifest/tree_disk.c it has no-che?k-code (glob)
+ Skipping fastmanifest/tree_disk_test.c it has no-che?k-code (glob)
Skipping fastmanifest/tree_iterate_rt.c it has no-che?k-code (glob)
Skipping fastmanifest/tree_iterator.c it has no-che?k-code (glob)
Skipping fastmanifest/tree_iterator.h it has no-che?k-code (glob)
ERROR: test-check-code-hg.t output changed
!
Failed test-check-code-hg.t: output changed
# Ran 1 tests, 0 skipped, 0 warned, 1 failed.
python hash seed: 583073521
```
Due to the way that arc lint works, we have to associate the linter issue
with the files that changed in the diff, but we don't have an easy way to
figure out the line number where the `no-check-code` line was added, so
we just use line number 0.
Test Plan:
`arc patch D3236640` and `arc lint`:
```
$ arc lint --everything
>>> Lint for fastmanifest/tree_disk.c:
Error (S&RX) CheckCode
Update tests/test-check-code-hg.t to add Skipping
fastmanifest/tree_disk.c it has no-che?k-code (glob)
>>> 1 // Copyright 2016-present Facebook. All Rights Reserved.
2 //
3 // tree_disk.c: methods to persist to and restore from disk.
4 //
>>> Lint for fastmanifest/tree_disk_test.c:
Error (S&RX) CheckCode
Update tests/test-check-code-hg.t to add Skipping
fastmanifest/tree_disk_test.c it has no-che?k-code (glob)
>>> 1 // Copyright 2016-present Facebook. All Rights Reserved.
2 //
3 // tree_disk_test.c: tests to verify tree_disk
4 //
```
Reviewers: #sourcecontrol, ttung, lcharignon
Reviewed By: lcharignon
Subscribers: lcharignon, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3237054
Signature: t1:3237054:1461949072:ac7cc29fcee9dbc00a4019088f3adb50de9625bf
Summary:
if you run `arc lint --output json` and don't have your environment correctly set up, the failure to run the linter was silently ignored.
I wanted to fix that, but then realized that we could integrate this better without too much effort, hence this diff.
This is a small python script that processes the output from the check code test and captures the appropriate context so that `arc lint` can show you where in the code the problem(s) lie.
Test Plan:
This is the output when the environment is not set up correctly:
```
$ arc lint
>>> Lint for lint.py:
Error (S&RX) ENVIRON
Please either set MERCURIALRUNTEST env var to the full path to
run-tests.py, or add the containing directory to your $PATH
>>> 1
Error (S&RX) ENVIRON
Please either set MERCURIALRUNTEST env var to the full path to
run-tests.py, or add the containing directory to your $PATH
>>> 1
```
This is the same thing but in json output mode:
```
$ arc lint --output json
{".arcconfig":[]}
{"scripts\/lint.py":[]}
{"lint.py":[{"line":"1","char":null,"code":"S&RX","severity":"error","name":"ENVIRON","description":"Please either set MERCURIALRUNTEST env var to the full path to run-tests.py, or add the containing directory to your $PATH","original":null,"replacement":null,"granularity":1,"locations":[],"bypassChangedLineFiltering":null,"context":""},{"line":"1","char":null,"code":"S&RX","severity":"error","name":"ENVIRON","description":"Please either set MERCURIALRUNTEST env var to the full path to run-tests.py, or add the containing directory to your $PATH","original":null,"replacement":null,"granularity":1,"locations":[],"bypassChangedLineFiltering":null,"context":""}]}
```
This shows the lint errors from my `hg publish` stack:
```
>>> Lint for phabricator/arcconfig.py:
Error (S&RX) CheckCode
don't raise generic exceptions
18 def load_for_path(path):
19 homedir = os.getenv('HOME')
20 if not homedir:
>>> 21 raise Exception('$HOME environment variable not found')
22
23 # Use their own file as a basis
24 userconfig = _load_file(os.path.join(homedir, '.arcrc')) or {}
```
Reviewers: #sourcecontrol, ttung, lcharignon
Reviewed By: lcharignon
Subscribers: mjpieters
Differential Revision: https://phabricator.fb.com/D3203666
Signature: t1:3203666:1461185075:e9b03c8251d7e3b8e965b81146d17cdeac75d837
Summary:
Editorconfig (http://editorconfig.org/) is a file format helping define coding
styles like spaces, tabs etc. It supports a wide range of editors. The upstream
is using it already.
This patch adds a simple .editorconfig, making it clear we use 8-char tabs in
C code, 4-char spaces in Python and Shell scripts, and we don't keep trailing
spaces.
Besides, do a style fixes for `scripts/runcheckcode.sh`. But note that
`scripts/scm-prompt.sh` is left untouched since it was copied from other
repository and we may sync it later.
Test Plan:
Use `gg=G` in vim to format `scripts/runcheckcode.sh` and make sure it does
not showed up in Phabricator with space changes ignored.
Reviewers: #sourcecontrol, durham, ttung
Reviewed By: durham
Subscribers: durham, mjpieters
Differential Revision: https://phabricator.fb.com/D3197242
Signature: t1:3197242:1461129423:e24a898370f8e8eb9bea8be414fee8670f06c16d
Summary:
Before this patch, `runcheckcode.sh` sets an extra config option
`extensions.lz4revlog=`, which will break if lz4revlog is not installed
in the system. This patch drops the config option if the repo does not
require `lz4revlog`.
Test Plan: Run `runcheckcode.sh` in both lz4revlog and non-lz4revlog repos.
Reviewers: #sourcecontrol, ttung
Reviewed By: ttung
Subscribers: mjpieters
Differential Revision: https://phabricator.fb.com/D3196200
Signature: t1:3196200:1461088741:11cfc8f3236f471e060e768c01a772072543e6fc
Summary:
It was too easy to check in code that was not passing check-code. I
got tired of fixing it so let's add a linter :)
Test Plan:
Test that the linter works as expected and asks the user to provide
the location of run-tests.py if not set.
Reviewers: #sourcecontrol, ttung
Subscribers: mjpieters
Differential Revision: https://phabricator.fb.com/D3153365