Граф коммитов

37 Коммитов

Автор SHA1 Сообщение Дата
Andrew Halberstadt 8d7db75ee7 Bug 1340162 - Add task for running mozlint unitttests on Linux (and pull old tests out of make check), r=smacleod
MozReview-Commit-ID: 3XCWMJtQMvZ

--HG--
extra : rebase_source : 290c14cda5b7abf6aea43315fc91c0ac8fc869f0
2017-02-02 11:08:41 -05:00
Mike Hommey dc5d1e6adf Bug 1335309 - Change the default for find_executables to False. r=mshal
Back when the class was written, for the packaging code, it made sense
that the default was True. But now that it's used all over the place,
and that the vast majority of uses are with find_executables=False, it
makes more sense for that to be the default.

--HG--
extra : rebase_source : ff813735fc0d53093f348f20eb77ee03e9b09d4e
2017-01-31 14:06:15 +09:00
Francesco Pischedda 8a2906dd4f Bug 1313194 - Add --outgoing argument to mozlint. r=ahal
Was: Replace mozlint's --rev with a --outgoing argument

MozReview-Commit-ID: 5YcRWbc1dR4

--HG--
extra : rebase_source : e13fca582d37fb40ba9d7782413190da4c1fa8b3
2017-01-26 17:50:34 +01:00
Andrew Halberstadt b994a9eca5 Bug 1318597 - Explicitly call manager.shutdown() after running mozlint, r=mshal
This is an educated guess in an attempt to solve a hard to reproduce intermittent. This
also makes sure the original SIGINT handler is restored after running the linters.

MozReview-Commit-ID: HRo0GRlSN5L

--HG--
extra : rebase_source : 7b8bf4b5818d741b5ab6a38c8c56f4eb53a801c8
2017-01-23 17:35:03 -05:00
Andrew Halberstadt 6adcf5b456 Bug 1317970 - Use manifestparser manifests for python unit tests, r=chmanchester
This deprecates PYTHON_UNIT_TESTS and replaces it with PYTHON_UNITTEST_MANIFESTS.
In the build system, this means python unittests will be treated the same as all
other test suites that use manifestparser. New manifests called 'python.ini' have
been created for all test directories containing python unittests.

MozReview-Commit-ID: IBHG7Thif2D

--HG--
extra : rebase_source : 11a92a2bc544d067946bbd774975140147458caa
2016-11-16 09:59:22 -05:00
Andrew Halberstadt 4524d8939a Bug 1318488 - [mozlint] Use sys.stdout.encoding when printing formatter's output, r=smacleod
This fixes a UnicodeDecodeError when sys.stdout's encoding can't handle unicode.

MozReview-Commit-ID: 3INna8MRje5

--HG--
extra : rebase_source : bb8f3b5cbdbb6601b6946d5fbb7396848f22b5c6
2016-11-17 17:36:34 -05:00
Andrew Halberstadt 7c26ce739c Bug 1316925 - Keep track of failed linters in stylish formatter summary, r=jgraham
This replaces the "return_code" property on the LintRoller object with a list of "failed"
linters. This is a bit more useful as it lets us know exactly which linters had a problem
(whereas previously we just knew *something* went wrong). This patch pushes determining
the return code back into cli.py, which I think is fine.

In addition, we now pass the list of failed linters into the formatter. This allows us to
clarify exactly how many linters hit a failure which is a lot better than a seemingly
"successful" summary message.

Finally I also removed the "no files to lint" message because I've seen several people
confuse it for an error. I'll probably add it back as a debug log message when we switch
to using mozlog for output.

MozReview-Commit-ID: 4wyCeOZdOf8

--HG--
extra : rebase_source : 23810a8ab8dd9cbbad6b9e965ccff7214f947fbc
2016-11-14 11:56:46 -05:00
Andrew Halberstadt 5b45c5a120 Bug 1315805 - [mozlint] Make sure multiprocess' stdout gets flushed in lint tasks, r=dustin
MozReview-Commit-ID: FhOI92JySXg

--HG--
extra : rebase_source : f3de6198a2616315358e3e3be1441df0713b442f
2016-11-08 13:33:13 -05:00
Andrew Halberstadt dde3965629 Bug 1309963 - Make sure return codes are passed from .lint files up to the cli, r=jgraham
If a linter returns a status code instead of a list of results, mozlint will throw away
that status code and move on to the next linter. We should make sure that status code
bubbles all the way up to the cli.

MozReview-Commit-ID: 9fXpmtlUUT1

--HG--
extra : rebase_source : 84c80d1b24d7233d0c4c6e38b23e775110776d1f
2016-10-13 16:23:13 -04:00
James Graham bba975bca2 Bug 1302796 - Add integration between structured logging and lints, r=ahal
MozReview-Commit-ID: K3tu0Zdg5go

--HG--
extra : rebase_source : 2b78059908c3a297b8ce7d134af20733fc082df5
2016-09-13 14:18:41 +01:00
Andrew Halberstadt 98a0fd6336 Bug 1302172 - [mozlint] Convert unittest tests to use pytest instead, r=maja_zf
MozReview-Commit-ID: D4bN62QbkKm

--HG--
extra : rebase_source : 22ffe05ca78095fc469520b9f85d93585251cd1c
2016-09-09 16:20:09 -04:00
Andrew Halberstadt 0f35e014fa Bug 1300779 - [mozlint] Redirect stderr when detecting version control root, r=smacleod
This avoids printing harmless (but confusing) errors to the log. For instance, git users
will see a '.hg not found!' error in the output even though not finding an hg repo is
expected in that case.

MozReview-Commit-ID: DBPOabcV7PA

--HG--
extra : rebase_source : a40de185cd4bf0c58917065d1331e0e663b92b94
2016-09-06 10:36:45 -04:00
Andrew Halberstadt 1ec1f86a90 Bug 1299618 - [mozlint] Encode results to utf-8 before printing to stdout, r=smacleod
MozReview-Commit-ID: 93RAqIRKAHc

--HG--
extra : rebase_source : d1973e52e72baab13ba9c8f1b07df5a7ddda7d49
2016-08-31 17:18:52 -04:00
Mike Hommey 411867285a Bug 1299661 - Use hg --template flag instead of -T. r=gps
Versions of mercurial older than 3.0 don't support the -T shorthand for
the --template option. While most people should be using something
newer, it can still happen that some run an older version, and it's
still trivial to support them by using the long option.

--HG--
extra : rebase_source : 1507aea436779495045df48b044a58f4af1382be
2016-09-01 07:43:38 +09:00
Andrew Halberstadt c88eb083d8 Bug 1258341 - [mozlint] Add ability to forward miscellaneous command line arguments to the underlying linter, r=smacleod
This is mostly to maintain backwards compatibility with the |mach eslint| command. But it's also going to be used in
automation. The 'mozlint-eslint' task will need to pass in --quiet to eslint.

Maybe in the future we should remove this ability and only allow well-defined arguments in mozlint. But for now it's
convenient and allows us to land the eslint->mozlint patch series quicker.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : ad7f0cdeb57ed8a99becb90d761d73ef45ce853a
2016-08-25 09:52:50 -04:00
Andrew Halberstadt ae1bcceeda Bug 1297699 - Mozlint tests should run with test directory as the "project root", r=smacleod
MozReview-Commit-ID: 9sbhlc11YF5

--HG--
extra : rebase_source : dee2bc4820374ca833f8351de72743f8d5a95aec
2016-08-24 09:55:04 -04:00
Andrew Halberstadt ed73940aa9 Bug 1288425 - Make sure we skip invalid extensions when linting with --rev or --workdir, r=smacleod
Some linters, such as flake8, will lint invalid file extensions if you explicitly pass them in. E.g,
|flake8 foobar.js| will result in flake8 attempting to lint a JS file. This is a problem because passing
in files explicitly is exactly what the --rev/--workdir options do. If a developer modifies a JS file
then runs |mach lint -l flake8 -w|, that JS file will get linted.

To prevent this, mozlint needs to handle file extensions instead of relying on the underlying linter to
do it. This patch adds an "extensions" config option to the LINTER dict, and will filter these files out
as part of the 'filterpaths' steps.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 6fea2942b2db1bea7deca1d6738546362b6ebd65
2016-08-09 16:24:04 -04:00
Andrew Halberstadt 797aa910b7 Bug 1294802 - Improve color handling in mozlint stylish formatter, r=jgraham
This will make specifying terminal colours cleaner and provide fallbacks for terminals
with only 8 colours. It also tweaks the 'grey' color to match an update to the eslint
stylish formatter.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 8d3242edc54bf6505aa2e60cdb08cb0dd9743dd3
2016-07-19 11:54:04 -04:00
Andrew Halberstadt 8c3bcff5a6 Bug 1289805 - Properly normalize all paths so they are absolute, r=smacleod
It's important to use absolute paths so lint errors for the same files don't show up in two
different places. For example, eslint will absolutize a relative path, whereas flake8 will
not.

This patch also makes sure all include/exclude paths are joined to the mozlint 'root' that
was previously calculated from vcs.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 9b88ee70a997d3f7b6cc0eb849e47931d5726f20
2016-07-19 13:09:38 -04:00
Andrew Halberstadt 560ce6a254 Bug 1289805 - Resolve vcs arguments directly in LintRoller class, r=smacleod
Previously, vcs related stuff was resolved in the cli.py module. But it's possible
for consumers to bypass the cli and instantiate a LintRoller directly. In fact this
is what the mozlint tests do.

Now that we always try to find the vcs root, calling into vcs is no longer optional.
This patch moves the VCSFiles class to a new vcs.py module and makes LintRoller
responsible for instantiating it instead of cli.py.

MozReview-Commit-ID: 5yA3gDZ1UGM

--HG--
extra : rebase_source : 96adc0ca01e8220b0432b64c96c478fc526db756
extra : source : 709c1e521ad3eb466c3434000aed7f71ebf37365
2016-08-10 10:21:43 -04:00
Andrew Halberstadt ce3f82ffbe Bug 1289805 - Ensure the VCSFiles class returns paths that have been absolutized to the repository root, r=smacleod
This makes sure we return absolute paths from the VCSFiles class. This is done so we don't accidentally normalize
the relative paths onto $CWD in the event the relative path is valid in both places.

MozReview-Commit-ID: 2QIuR2YqFos

--HG--
extra : rebase_source : 2e82b4a5cf9a18856bbcb8d04fdc916ff7e72deb
2016-08-09 14:49:41 -04:00
Andrew Halberstadt 64bfc88f52 Bug 1289805 - Refactor filterpaths to accept all lintargs, r=smacleod
This makes it easier to pass configuration to the filterpaths method. In
the future, 'root' and 'extensions' will both be used here.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 19ddf511ebd24a1a6c21f7c06b67ab64e78e7903
2016-08-09 15:29:49 -04:00
Iris Hsiao bb2d612158 Backed out changeset 2141360b4137 (bug 1288425) for build bustage 2016-07-27 10:59:10 +08:00
Andrew Halberstadt 18f9c226a5 Bug 1288425 - Make sure we skip invalid extensions when linting with --rev or --workdir, r=smacleod
Some linters, such as flake8, will lint invalid file extensions if you explicitly pass them in. E.g,
|flake8 foobar.js| will result in flake8 attempting to lint a JS file. This is a problem because passing
in files explicitly is exactly what the --rev/--workdir options do. If a developer modifies a JS file
then runs |mach lint -l flake8 -w|, that JS file will get linted.

To prevent this, mozlint needs to handle file extensions instead of relying on the underlying linter to
do it. This patch adds an "extensions" config option to the LINTER dict, and will filter these files out
as part of the 'filterpaths' steps.

MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : 46807a4913660f33e691b864c2c59c448902dfa5
2016-07-19 13:50:25 -04:00
Tom Tromey 5538d692d3 Bug 1286877 - do not set c-basic-offset for python-mode; r=gps
This removes the unnecessary setting of c-basic-offset from all
python-mode files.

This was automatically generated using

    perl -pi -e 's/; *c-basic-offset: *[0-9]+//'

... on the affected files.

The bulk of these files are moz.build files but there a few others as
well.

MozReview-Commit-ID: 2pPf3DEiZqx

--HG--
extra : rebase_source : 0a7dcac80b924174a2c429b093791148ea6ac204
2016-07-14 10:16:42 -06:00
Andrew Halberstadt d5b1ff9f2e Bug 1287834 - [mozlint] Fix regression preventing specific linters from being run, r=smacleod
MozReview-Commit-ID: KYhC6SEySC3

--HG--
extra : rebase_source : bce3e321f407b89d65f1491be74384c0ae171431
2016-07-19 11:50:33 -04:00
Andrew Halberstadt 3c8be23f37 Bug 1281899 - [mozlint] Add ability to lint files touched by revisions and/or the working directory, r=smacleod
This adds two parameters, --rev and --workdir. Each works both with mercurial and git (though the syntax for
specifying revisions is different between them). The value is simply forwarded to either |hg log| or |git diff|
so syntax like |mach lint -r .~4::.| or |mach lint -r "HEAD~4 HEAD"| will work as expected.

MozReview-Commit-ID: aOGp2Yrncs

--HG--
extra : rebase_source : d2cb834d4cc1a083171a3551af4e72c8a7d14021
2016-06-24 14:09:58 -04:00
Andrew Halberstadt 482f8a956c Bug 1281899 - [mozlint] Create cli module and move logic from tools/lint/mach_commands.py there, r=smacleod
There is currently no built-in user interface to mozlint. The only existing interface is the
external cli provided by |mach lint|. However, in the future mozlint may need to be used in a
context where mach isn't readily available (i.e version-control-tools). This patch basically
just moves the cli logic out of mach_commands.py, and into mozlint core. That way it can be
re-used in other places without needing to be re-implemented.

The |mach lint setup| subcommand was removed because apparently subcommands don't work with
the parser attribute. Nothing was using it yet anyway, so I removed it for now. It may get
re-added in some form in the future.

MozReview-Commit-ID: aOGp2Yrncs

--HG--
extra : rebase_source : 8f7530de96e5c131d2ed5bfcdd7a159329401e5b
2016-06-24 14:06:22 -04:00
James Graham 3ca7bb37ed Bug 1279811 - Make output of column number optional in mozlint, r=ahal
MozReview-Commit-ID: 7eGTJKPMMAc
2016-06-23 10:36:47 +01:00
Andrew Halberstadt 13a551f7f9 Bug 1277641 - [mozlint] Add --no-filter option to make experimenting locally easier, r=smacleod
This makes it easier to lint a path that otherwise wouldn't have been linted due to the include/exclude
directives. Now, you can pass in -n/--no-filter instead of needing to modify the linter configuration file.

MozReview-Commit-ID: GMJuE2C1NyY

--HG--
extra : rebase_source : 03627e930f76903ad629cb01b58c4ae7372e4bb1
2016-06-02 15:14:07 -04:00
Andrew Halberstadt 031698ae90 Bug 1273634 - [mozlint] Add a treeherder formatter, r=jgraham
This is a really simple and ugly formatter that is compatible with
treeherder's error highlighting mechanism. It is designed to be identical
to the current eslint output on treeherder:
https://dxr.mozilla.org/mozilla-central/rev/4d63dde701b47b8661ab7990f197b6b60e543839/tools/lint/eslint-formatter.js

Eventually eslint will also use this and we can remove that file. Once
bug 1276486 is fixed, we can make this look a little nicer. But for now
it gets the job done.

MozReview-Commit-ID: CwfWPcwWFxF

--HG--
extra : transplant_source : %F3PJ%CB%27%A5%82U%D2%CF%B3%9E%A7%9F%0F%A4%F4%E9%5D%BB
2016-05-28 23:38:30 -04:00
Carsten "Tomcat" Book c30c6ba10e Backed out changeset c48f3b04c9de (bug 1273634) 2016-06-02 15:05:01 +02:00
Andrew Halberstadt df97806e5f Bug 1273634 - [mozlint] Add a treeherder formatter, r=jgraham
This is a really simple and ugly formatter that is compatible with
treeherder's error highlighting mechanism. It is designed to be identical
to the current eslint output on treeherder:
https://dxr.mozilla.org/mozilla-central/rev/4d63dde701b47b8661ab7990f197b6b60e543839/tools/lint/eslint-formatter.js

Eventually eslint will also use this and we can remove that file. Once
bug 1276486 is fixed, we can make this look a little nicer. But for now
it gets the job done.

MozReview-Commit-ID: CwfWPcwWFxF

--HG--
extra : rebase_source : 8dd39aefec1064e0836c847c6d223db43df4755b
2016-05-28 23:38:30 -04:00
Andrew Halberstadt 464b3a9f2e Bug 1273556 - [mozlint] Better SIGINT handling, return partial results on Ctrl-C, r=jgraham
Currently a bug in python (https://bugs.python.org/issue8296) is preventing a KeyboardInterrupt from
reaching the parent process, meaning we can't kill the process with SIGINT. There is a workaround to
this bug, but instead I decided to ignore SIGINT in the parent process completely. Now, each child
process is responsible for handling SIGINT on its own. Since child processes should all shutdown
relatively quickly anyway, this effectively also ends the parent process.

The benefit of doing it this way is that each child process can return the results they have collected
to date. So when a developer hits Ctrl-C, they'll still see some (but not all) formatted lint output.
The downside is that a poorly implemented external linter could block the parent process from exiting
quickly, but if this happens we should just fix the linter.

MozReview-Commit-ID: 2tRJgtmoPYP

--HG--
extra : rebase_source : e72282bcc29c9b22690168dc973a817236cdf8ca
2016-05-17 12:24:42 -04:00
Andrew Halberstadt b1445349ea Bug 1270506 - [mozlint] Add python flake8 linter, r=smacleod
For now, only the following two directories will be linted:
python/mozlint
tools/lint

New directories can be added by adding them to the 'include'
directive in tools/lint/flake8.lint. They all default to the
configuration specified in topsrcdir/.flake8. Subdirectories
can override this configuration by creating their own .flake8
file.

MozReview-Commit-ID: Eag48Lnkp3l

--HG--
extra : rebase_source : 6d98c9fef80055a48cc2622848aa04c3045b747e
2016-05-05 17:21:12 -04:00
Andrew Halberstadt 5f616862e3 Bug 1270506 - [mozlint] Refactor the include/exclude path filtering algorithm, r=smacleod
The current algorithm for filtering down tests is too naive. For example, given the following
directory structured:

parent
  - foo
    - bar
    - baz

And the following include/exclude directives:
include = ['foo']
exclude = ['foo/bar']

Then running ./mach lint parent and ./mach lint foo/baz should both lint all files in baz but
no files in bar. This provides a nice way to include/exclude directories, while allowing the
underlying linters to find appropriate files to lint *within* those directories.

tl;dr - Straight file paths (no globs) will be passed straight to the underlying linter as is.
While paths with globs will first be resolved to a list of matching file paths.

MozReview-Commit-ID: Eag48Lnkp3l

--HG--
extra : rebase_source : 18ce2231bc4198b1e811d39f9803f0d5e03d982e
2016-05-05 17:20:33 -04:00
Andrew Halberstadt bb96d51342 Bug 1230962 - Add python/mozlint for running several linters at once, r=smacleod
Mozlint provides two main benefits:
1. A common system for defining lints across multiple languages
2. A common interface and result format for running them

This commit only adds the core library, it does not add any consumers of mozlint just yet.

MozReview-Commit-ID: CSQzq5del5k

--HG--
extra : rebase_source : b520b96177281a1b1770edf53a01cbc2196f494f
2016-03-16 14:55:21 -04:00