1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-10-24 01:28:51 +02:00
Commit graph

1409 commits

Author SHA1 Message Date
Joshua Spence
566c7e9c5c Add a rule to the XHPAST linter for detecting elseif usage.
Summary: This rule is adapted from [[https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php | PHP_CodeSniffer]] and is used to enforce the consistent use of `else if`.

Test Plan: Wrote and executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin, neal

Differential Revision: https://secure.phabricator.com/D9193
2014-05-19 06:33:22 -07:00
Joshua Spence
904fbe737c Add an ArcanistChmodLinter.
Summary: Fixes T3922. Add a linter which complains if files are executable when they shoudn't be.

Test Plan: Tested by modifying the `.arclint` file of the rARC repository and running `arc lint --everything`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T3922

Differential Revision: https://secure.phabricator.com/D9187
2014-05-18 16:57:08 -07:00
Joshua Spence
606380f4bd Made some additional methods of ArcanistLintEngine final
Summary: To me, it seems that these methods should not be overridden by subclasses

Test Plan: `arc lint` and `arc unit`

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: LegNeato, aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D7960
2014-05-18 11:08:29 -07:00
Joshua Spence
a67b848f44 Made some additional methods of ArcanistBaseWorkflow final.
Summary: To me, it seems that these methods should never be overwritten in subclasses.

Test Plan: `arc lint` and `arc unit`.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: LegNeato, aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D7959

Conflicts:
	src/workflow/ArcanistBaseWorkflow.php
2014-05-18 11:05:51 -07:00
Joshua Spence
6c1bae437e Modernize ArcanistScalaSBTLinter.
Summary: Ref T2039. Convert the `ArcanistScalaSBTLinter` into an `ArcanistExternalLinter` and make it compatible with `.arclint`.

Test Plan: I can't really test this because I don't have any Scala projects and we don't have any test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: codeblock, epriestley, Korvin

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9097
2014-05-18 10:49:22 -07:00
Joshua Spence
178b32c6c2 Fix the ArcanistXHPASTLinter single quote rule.
Summary: Previously, the `ArcanistXHPASTLinter` was suggesting that `"\1"` be written as `'\1'`, which is incorrect. Therefore, I ensured that all of the cases listed in the [[http://www.php.net/manual/en/language.types.string.php | PHP documentation]] were handled correctly.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9182
2014-05-18 06:47:37 -07:00
Joshua Spence
b21a420071 Update ArcanistCoffeeLintLinter to be compatible with CoffeeLint v1.4.0.
Summary: CoffeeLint v1.4.0 deprecated the `--checkstyle` flag in favor of `--reporter=checkstyle`.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9181
2014-05-18 06:07:35 -07:00
Joshua Spence
4181fbde12 Fix the ArcanistJSONLintLinter::getVersion function.
Summary: Ref T4954. There was a typo in the original implementation. It wasn't noticed until now because the `getVersion` function isn't really used anywhere.

Test Plan: Ran `arc linters` in a repository with `ArcanistJSONLintLinter` configured, noticed that the version number appeared in the output.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4954

Differential Revision: https://secure.phabricator.com/D9160
2014-05-17 18:36:25 -07:00
Joshua Spence
b4b6a33d2a Relax the version regex for ArcanistFlake8Linter.
Summary: As noticed by @epriestley in D9060, `flake8 --version` can emit a string like "2.0" rather than the expected "2.0.0".

Test Plan: Uninstalled my existing version of `flake8` (v2.1.0) and installed a prior version (`pip install flake8==2.0.0`). Ran `flake8 --version` and inspected the output.

Reviewers: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D9174
2014-05-17 18:18:03 -07:00
Joshua Spence
7c56fad48f Fix the ArcanistJSHintLinter::getVersion function.
Summary: As identified by @epriestley in D9060, `jshint --version` emits version information on stderr, not stdout.

Test Plan: Ran `jshint --version` locally and verified that the version information is output to stderr.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T4954

Differential Revision: https://secure.phabricator.com/D9173
2014-05-17 18:17:47 -07:00
epriestley
b52f3fafe3 Fix "arc diff --raw-command --create"
Summary: Fixes T5082. We try to access the repository API in some cases when we don't have one.

Test Plan:
  - Made revisions with "arc diff --raw-command --create".
  - Made this revision, without "--raw-command".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5082

Differential Revision: https://secure.phabricator.com/D9165
2014-05-17 13:40:05 -07:00
Joshua Spence
1493e043e1 Add an ArcanistCoffeeLintLinter linter.
Summary:
Add a wrapper around [[http://www.coffeelint.org/ | CoffeeLint]] as an `ArcanistExternalLinter`.

Depends on D9041.

Test Plan: Wrote and executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9051
2014-05-16 21:58:53 -07:00
Joshua Spence
7bde5941cf Set the working directory to the project root for external linter ExecFuture classes.
Summary: Fixes T5085. Currently, the `ExecFuture` instances that are used to call an external linter are executed in the current working directory. This means that if a path is specified in the `.arclint` file, relative to the project root directory, that the path will not be properly interpreted by the external linter when `arc lint` is called from a level deeper than the project root.

Test Plan: Ran `arc lint` from a subdirectory of a project and verified that the linter did not throw an exception due to not being able to find the specified configuration file.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5085

Differential Revision: https://secure.phabricator.com/D9159
2014-05-16 21:48:12 -07:00
Joshua Spence
8cd9cb1047 Add some .arclint configuration options for ArcanistJSHintLinter.
Summary:
Allow `.jshintrc` and `.jshintignore` paths to be passed to `jshint`.

Ref T2039.

Test Plan: Added the `jshintrc` and `jshintignore` keys to an `.arclint` file that was configured to use `ArcanistJSHintLinter`. Ran `arc lint --trace` and inspected the flags that were passed to `jshint`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: john.snow, epriestley, Korvin

Maniphest Tasks: T2039, T5085

Differential Revision: https://secure.phabricator.com/D9112
2014-05-16 21:42:52 -07:00
Joshua Spence
35a26718d8 Add a linter rule for determining when single quotes should be used over double quotes.
Summary: Personally, I am a strong fan of this rule. There is currently a similar rule provided by PHP_CodeSniffer.

Test Plan: Wrote and executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9117
2014-05-16 19:26:55 -07:00
Joshua Spence
38eda3e86b Move getPEP8WithTextOptions method into ComprehensiveLintEngine class.
Summary: Since this method is only used within this class, it makes sense to move it here.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9114
2014-05-16 19:18:35 -07:00
epriestley
75cb3cf358 Fix arc diff --raw when run outside a repository
Summary: Fixes T5071. If you run `arc diff --raw` from some arbitrary, non-repository directory we incorrectly try to read information out of the working copy. Even if this information is available, `arc diff --raw` should not assume it's accurate (there's no guarantee the diff comes from the working copy).

Test Plan: Ran `arc diff --raw` in an arbitrary directory.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5071

Differential Revision: https://secure.phabricator.com/D9142
2014-05-15 19:03:29 -07:00
Vihang Mehta
6c6035d04b Add Closure linter to arcanist
Summary:
Found https://secure.phabricator.com/D4519 but it was horribly out of date, so decided to write a new version.
Kinda clobbered together form that diff and the new version of ArcanistJSHintLinter

Test Plan: Tested on personal projects with js files.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9131
2014-05-15 09:19:28 -07:00
James Rhodes
fcdacc28b8 Fix issue where message contained % but wasn't intended for use with parameters
Summary: This fixes an issue with the C# linter where a message could be returned from cslint that wasn't intended for use with parameters.  This just ensures there's enough parameters so that it won't crash (and consequently ignore lint messages).

Test Plan: Ran the linter, it didn't crash.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9116
2014-05-14 17:11:45 -07:00
Joshua Spence
d484b60295 Minor improvements to the ArcanistLintCheckstyleXMLRenderer class.
Summary: Ref T4948. Move the `startDocument` code to a `renderPreamble` function so that, at least theoretically, the renderer can be reused. Otherwise, the only way to reuse the renderer would be to construct a new instance.

Test Plan: Ran `arc lint --output xml` and verified that the output looked reasonable.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4948

Differential Revision: https://secure.phabricator.com/D9108
2014-05-13 17:32:49 -07:00
Joshua Spence
b744ed9a19 Be more strict with the type of .arclint properties.
Summary: Although this provides less context in terms of the error message (for example, `Parameter has invalid type. Expected type 'optional regex|list<regex>', got type 'list<string>'.`), I think that it is the right approach. I think that `PhutilTypeSpec::checkMap` should be improved such that additional context is provided in the exception message.

Test Plan: Ran `arc lint`. Modified `.arclint` to contain an invalid regex and ran `arc lint` again.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9089
2014-05-13 15:17:56 -07:00
Joshua Spence
79285208c4 Don't prompt for patches when outputting lint results as XML.
Summary: The Checkstyle XML output format is not intended to be an interactive workflow.

Test Plan: Introduced linter issues and ran `arc lint`. Verified that no interactive prompt was shown.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9107
2014-05-13 14:40:27 -07:00
Joshua Spence
ec3de41684 Support Checkstyle as an output format for lint results.
Summary: Fixes T4948. Add a lint renderer which supports outputting the lint results in the Checkstyle XML format.

Test Plan: Ran `arc lint --xml` and inspected the output.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4948

Differential Revision: https://secure.phabricator.com/D9083
2014-05-13 13:20:29 -07:00
Joshua Spence
d826bf65c6 Minor cleanup of linter testing code.
Summary:
Just some minor cleaning up, including:

- Removing old annotations for Diviner.
- Renaming some `lint-test` files so that the directory name bears a closer resemblance to that of the linter.
- Remove some useless `return` statements.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9096
2014-05-13 06:16:02 -07:00
Joshua Spence
c4c0fbd7cd Rename test method.
Summary: Rename this test method for consistency with other linter test classes.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9095
2014-05-13 05:44:32 -07:00
epriestley
abafef7fb6 Write waiting message to stderr, not stdout. 2014-05-12 17:27:19 -07:00
William R. Otte
d5d8086646 Fixed the error message when cppcheck isn't installed to not be completely wrong.
Summary: Arcanist is a dirty rotten liar.  I made it less of a dirty, rotten liar.

Test Plan: http://imgur.com/36qXcgI

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9081
2014-05-12 12:58:03 -07:00
epriestley
0c21afa08a Print out a "waiting on stdin" message from 'arc call-conduit'
Summary: It looks like this command is just hanging if you skim the documentation and miss that you have to echo parameters into it. Print out a hint.

Test Plan: Ran `arc call-conduit` and got a hint.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9050
2014-05-12 11:36:19 -07:00
Joshua Spence
9b05a025b7 Made some additional methods of ArcanistLinter and ArcanistExternalLinter final
Summary: To me, it seems that these methods should never be overwritten in subclasses.

Test Plan: `arc unit`

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D7958
2014-05-12 09:49:45 -07:00
epriestley
0583b39bb0 Minor tweaks for XHPAST config
Summary: Ref T2039. The type specs are right in theory but not quite correct in practice, since we pass strings in rather than objects.

Test Plan: While tweaking `phabricator/`, adjusted these to get desirable results.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9071
2014-05-12 05:06:14 -07:00
epriestley
7bbafe91d2 Fill out some more info functions for libphutil-specific linters
Summary: Ref T2039. It looks like "phutil-library" didn't make it over, I'll add that to the other two (unless I'm wrong and this isn't an oversight?).

Test Plan: Used `arc linters` to read help.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9070
2014-05-12 05:06:04 -07:00
Joshua Spence
be803ce577 Remove the getConfig and setConfig method.
Summary: It seems that there is a lot of overlap between `getConfig` / `setConfig` and `getLinterConfigurationOptions` / `setLinterConfigurationValue` respectively.

Test Plan: `arc lint` and `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9067
2014-05-12 04:46:56 -07:00
Joshua Spence
1b820dbb14 Allow ArcanistPhutilXHPASTLinter to be configured from .arclint.
Summary: Currently, `PhabricatorLintEngine` configures the `ArcanistPhutilXHPASTLinter` linter. In order to use `.arclint` instead, we need to expose the `ArcanistPhutilXHPASTLinter` configuration to the `.arclint` format.

Test Plan: See D9064.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9066
2014-05-12 04:46:41 -07:00
Joshua Spence
c4ac8a1aea Make the PhutilLintEngine final.
Summary:
Phabricator now uses the `ArcanistConfigurationDrivenLintEngine` lint
engine instead of the `PhabricatorLintEngine` lint engine.

Depends on D9064.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9069
2014-05-12 04:31:03 -07:00
Joshua Spence
315314425e Modernize ArcanistCppcheckLinter.
Summary: Ref T2039. Make the `ArcanistCppcheckLinter` compatible with `.arclint`.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9068
2014-05-12 04:30:36 -07:00
epriestley
54c377448d Provide arc linters --verbose to list all available options
Summary:
Ref T2039. I'll update the corresponding documentation.

It feels a little awkward that this is disconnected from `getLinterConfigurationOptions()`, but I dislike returning weird ad-hoc structures more than I dislike having two methods. Most linters don't implement either of these anyway.

Test Plan: Ran `arc linters` and `arc linters --verbose`.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9062
2014-05-11 20:23:07 -07:00
Joshua Spence
b63828a87e Use the ArcanistConfigurationDrivenLintEngine as a linting engine.
Summary: Ref T2039. The `.arclint` file is reasonably complete now and we should start using it if possible, since we are trying to recommend it to others.

Test Plan: `arc lint`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9057
2014-05-11 19:33:40 -07:00
epriestley
86cbcb9f56 Allow linters to share resources by shoving them on the Engine
Summary:
Currently, the Phutil XHPAST Linter and vanilla XHPAST Linter reuse the same parse tree, but do this by having explicit knowledge of one another.

Instead, let them synchronize by writing to a glorified array of globals on the Engine. They no longer require knowledge of one another, so this can work under `.arclint`.

(This could probably be a little cleaner by putting more logic in the shared base class, but Facebook has some kind of goofy subclass of this thing and //this// patch won't disrupt it, while a cleaner one might.)

This should unblock D9057.

Test Plan: Ran unit tests and normal lint, got accurate looking results without duplicate invocations showing up in `--trace`.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9059
2014-05-11 19:28:46 -07:00
Joshua Spence
9bd740b1f8 Remove severity options from some linters.
Summary: The `ArcanistGeneratedLinter` and `ArcanistNoLintLinter` don't actually ever raise any linter messages, so it doesn't make sense to set custom severities for these linters. Instead, don't expose this configuration.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9038
2014-05-11 19:28:27 -07:00
epriestley
7870e7f2e4 Warn when accessing deprecated lint config
Summary:
Ref T2039. Addresses two issues:

  - Issues a warning for use of config which is deprecated by `.arclint`.
  - We no longer require an engine to be present for these linters, so `arc linters` doesn't fatal if they aren't configured.

Test Plan:
  - Ran `arc linters` in a repo with no JSHint.
  - Ran `arc linters` in a repo with junk in .arcconfig and got a warning when it was read. Verified it still took effect.

Reviewers: chad, btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9058
2014-05-11 18:39:28 -07:00
Juan Pablo Civile
377c585752 Allow linters that extend ArcanistExternalLinter to customize the file parameter
Summary: Not all linters run on a `command file` fashion. In particular, the maven checkstyle plugin runs like `command --flag=file`.

Test Plan: Run a linter that extends `ArcanistExternalLinter`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9026
2014-05-11 16:27:23 -07:00
epriestley
5d1f87a8c2 Provide more help text for arc linters
Summary: Ref T2039. This isn't exhaustive, but moves things forward by a decent chunk.

Test Plan: Used `arc linters` and read the messages.

Reviewers: chad, btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9056
2014-05-11 16:16:45 -07:00
epriestley
e13f5839d4 Add 'arc linters' to list available linters and status
Summary: Ref T2039. We're starting to get kind of a lot of linters; provide `arc linters` to help users review and understand them and construct `.arclint` files.

Test Plan: {F152205}

Reviewers: btrahan, joshuaspence

Reviewed By: btrahan, joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9041
2014-05-11 13:42:56 -07:00
Joshua Spence
c4985ef415 Allow global excludes to be specified in .arclint.
Summary: Currently, paths to be excluded from linting need to be specified for each linter individually. This is a pain for projects that are using even a moderate number of linters and which have common paths which should be excluded from linting completely.

Test Plan: Unfortunately, it's hard to test this sort of stuff. I cloned the `arclint-examples` repository and tested my changes there,

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9054
2014-05-11 05:32:38 -07:00
Joshua Spence
48c67d9c15 Minor formatting changes to ArcanistSpellingDefaultData.
Summary:
Fixed a few minor nitpicks:

  - Fix indentation.
  - Change double quotes to single quotes.
  - Add trailing commas to arrays.

Test Plan: Meh.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9053
2014-05-11 05:25:47 -07:00
Joshua Spence
20a0559522 Use PHP type hinting in ArcanistXHPASTLinter.
Summary: Explicitly specify the types of the function parameters. This change is basically the same as D8388.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9040
2014-05-10 01:56:06 -07:00
Joshua Spence
edd85a0e9d Modernize ArcanistMergeConflictLinter.
Summary: The only real change here is adding a `getLinterConfigurationName` method so that this linter can be used with an `.arclint` file. Everything else is just some minor tidying.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9039
2014-05-10 01:55:47 -07:00
Joshua Spence
2dba2f8528 Remove some dead comments.
Summary: These comments are redundant now.

Test Plan: N/A

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9037
2014-05-10 01:53:21 -07:00
Joshua Spence
89de113787 Add --quiet flags to the ArcanistCSSLintLinter.
Summary: This isn't really necessary, nor does it bear any significant benefits, however semantically it seems to make sense. From `csslint --help`, the `--quiet` flag causes `csslint` to "Only output when errors are present".

Test Plan:
Tested using `csslint` directly:

```
> csslint test.css

csslint: No errors in /home/joshua/workspace/github.com/facebook/arcanist/foo.css.
> csslint --quiet test.css
```

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9036
2014-05-10 01:52:57 -07:00
Joshua Spence
d80468bf81 Make the methods of ArcanistBaseXHPASTLinter final.
Summary: No subclass should need to override these methods. Additionally, none currently do.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9035
2014-05-10 01:51:44 -07:00
Joshua Spence
3d5aa332fe PHPCS supports reading from stdin.
Summary: PHPCS does actually support reading data from stdin, so let's make `ArcanistExternalLinter` aware of this.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9034
2014-05-10 01:50:43 -07:00
Joshua Spence
4a1b8a3299 Modernize ArcanistCpplintLinter.
Summary: Convert the `cpplint.py` wrapper linter to `ArcanistExternalLinter`. This is in preparation for T2039.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9033
2014-05-10 01:32:53 -07:00
Phil Frost
88bb9909b9 Allow .arclint to configure max line length of text linter
Test Plan:
Verified manually. Something like this in .arclint:

  "linters" : {
    "text" : {
      "type" : "text",
      "include" : "(\\.(txt|py|html?)$)",
      "text.max-line-length": 200
    }

changes the line length. Something other than an integer there raises an error.

Reviewers: epriestley, #blessed_reviewers, #arcanist

Reviewed By: epriestley, #blessed_reviewers, #arcanist

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D9029
2014-05-09 11:31:58 -07:00
epriestley
441e516104 Don't call writeLogLog. Just writeLog will do.
Test Plan: Ran `arc lint` locally. Now it doesn't exit with an error.

Reviewers: #blessed_reviewers, #arcanist, epriestley

Reviewed By: #blessed_reviewers, #arcanist, epriestley

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9028
2014-05-09 10:22:50 -07:00
Joshua Spence
4298b4ea8b Remove debug key from .arclint file format.
Summary: Having a `debug` key in the `.arclint` file format doesn't seem right. Instead, it would be better to just use a `PhutilConsole` and the `writeLog` method so that "debug" messages are output when using `arc --trace`.

Test Plan: Ran `arc lint --trace` in a repository using `.arclint`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9021
2014-05-09 06:00:36 -07:00
Joshua Spence
1591b21e86 Fix a typo.
Summary: The `lessc` binary is a part of the NPM `less` module.

Test Plan: `npm install less` works whereas `npm install lessc` does not.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9006
2014-05-08 07:39:02 -07:00
Bob Trahan
b6b9fdffb5 Fix a typo in land workflow
Summary: Contine is not a word methinks.

Test Plan: looks better

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8997
2014-05-07 09:15:14 -07:00
Joshua Spence
88ff113f92 Add a LESS linter.
Summary: This class provides an adapter for [[https://github.com/less/less.js/ | lessc]].

Test Plan: Wrote and executed unit tests.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8992
2014-05-06 06:50:44 -07:00
Joshua Spence
9a13c87ac4 Parse JSON as an associate array.
Summary:
It seems that in some situations, JSHint does not set the `evidence`
property. In such cases, PHP fails with `Undefined property:
stdClass::$evidence`. It would be safer to access the error object as an
associative array rather than as `stdClass`.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8993
2014-05-05 21:18:43 -07:00
Joshua Spence
8523b98f39 Add a puppet-lint linter.
Summary: This linter is a wrapper around [[http://puppet-lint.com/ | puppet-lint[]].

Test Plan: Wrote an executed unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8990
2014-05-05 20:42:40 -07:00
Joshua Spence
48d52c30b0 Reduce method visibility.
Summary: These methods are declared `public`, but there are meant to be `protected` (as they are declared in `ArcanistExternalLinter`).

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8991
2014-05-05 20:31:33 -07:00
Joshua Spence
e00ce65200 Add an XML linter.
Summary: Add a linter which uses [[http://php.net/simplexml | SimpleXML]] to detect errors and potential problems in XML files.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8989
2014-05-05 20:15:53 -07:00
Joshua Spence
ab5c1562c0 Add a JSON linter.
Summary: Provide bindings for [[https://github.com/zaach/jsonlint | JSONLint]], which is a useful tool for linting and validating JSON. Theoretically, this could be done with pure PHP, however it would not be trivial (`json_decode`, for example, does not provide any context as to JSON validation errors).

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8988
2014-05-05 20:15:35 -07:00
Andrew Jones
85000be96f Updating the pylint linter to set the output fomat correctly depending on the version of pylint installed
See: <https://github.com/facebook/arcanist/pull/161>

Reviewed by: epriestley
2014-05-05 19:05:16 -07:00
Burak Yigit Kaya
b4e91e1a37 Accept int as map key too
See: <https://github.com/facebook/arcanist/pull/163>

Reviewed by: epriestley
2014-05-05 19:01:51 -07:00
Joshua Spence
213997dc9d Fix flake8 unit test.
Summary:
This unit test is failing for me. It seems that I have a newer version of `flake8`. We should probably provide support for the most recent versions of any external tools, at least until we can implement version-specific stuff.

I am running `2.1.0 (pep8: 1.5.6, pyflakes: 0.8.1, mccabe: 0.2.1) CPython 2.7.6 on Linux`.

Test Plan: `arc unit`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8987
2014-05-05 18:59:35 -07:00
Joshua Spence
c013124690 Convert more linters to modern formats with .arclint support
Summary:
Ref T3186. Ref T2039.

  - Convert JSHint to modern format; improve granularity of errors.
  - Convert PyFlakes to modern format;
  - Remove ApacheLicenseLinter and LicenseLinter (these have been deprecated for a very long time).

This is somewhat disruptive and will break some users by no longer respecting various path/config options. I'll sequence documentation and deprecation warnings in front of these.

Test Plan: Ran unit tests.

Reviewers: btrahan, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin, joshuaspence, aran

Maniphest Tasks: T3186, T2039

Differential Revision: https://secure.phabricator.com/D6810
2014-05-05 18:58:13 -07:00
Joshua Spence
f2b341ae03 Add a getVersion function to ArcanistExternalLinter.
Summary:
This method will, theoretically, allow `arc lint` to be configured to require some minimum version of an external linter (although this would probably require significantly more work).

Additionally, the existence of this method simplifies the `getCacheVersion` function which, previously, was implemented by the external linters individually. Instead, a general approach to determining the version for cacheing purposes can be used.

Fixes T4954.

Test Plan: I'm not sure how to test this.

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T4954

Differential Revision: https://secure.phabricator.com/D8971
2014-05-05 15:10:20 -07:00
Joshua Spence
a7327ca0e9 Modernize ArcanistJSHintLinter.
Summary: Modernize `ArcanistJSHintLinter` by extending from `ArcanistExternalLinter` instead of `ArcanistLinter`.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8965
2014-05-05 14:22:27 -07:00
Bob Trahan
96d3416218 Arcanst - add support for custom statuses to arc close workflow
Summary:
Fixes T4938. Now that we have customs statuses, this workflow needs to know about 'em.

One fun caveat is that Conduit isn't up and running to generate the help method, so I had to add a parameter to have the statuses list out. This could maybe be omitted since entering erroneous status options does indeed tell you the correct options.

Test Plan:
`arc close --list-status` -- got a list of statuses
`arc close T1` -- closed T1
`arc close T1` -- error T1 closed already
`arc close T1 -s foobar` -- T1 status set to foobar

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T1, T4938

Differential Revision: https://secure.phabricator.com/D8938
2014-05-01 16:14:03 -07:00
Peng Li
c4ec22b140 It should be also valid to have empty change under hg
Summary: Like git, it is also valid to have empty net change under hg. Should not throw if that is the case.

Test Plan: Tried on a hg repo.

Reviewers: lifeihuang, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8888
2014-04-29 14:17:35 -07:00
Jinghao Yan
577914e623 Correct "agument" to "argument", not "augment"
See: <https://github.com/facebook/arcanist/pull/162>

It looks like the word `argument` appears many more times than `augment`, so I'm assuming `agument` is most likely to be a typo of `argument`.

Reviewed by: epriestley
2014-04-29 04:34:57 -07:00
Joshua Spence
30ecf46c11 Allow ArcanistExternalLinter flags to be specified as an array.
Summary: Personally, I prefer to specify command lines flags as an array rather than a string.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aran, epriestley, Korvin, chad

Differential Revision: https://secure.phabricator.com/D8387
2014-04-23 16:22:49 -07:00
epriestley
6e597b292a Show build results in arc land
Summary:
Fixes T4809. When landing a revision, check for a (non-manual) buildable of the current diff. If we find one, check its status:

  - If it passed, print out a message to inform the user that we checked.
  - If it failed or is still building, print out details about the issue and require a confirmation to continue.
  - Just ignore other cases.

Test Plan:
  - Ran `arc land` on a revision with no buildable, a passing buildable, a failed buildable, and a building buildable for the current diff.
  - Got sensible output / prompts.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4809

Differential Revision: https://secure.phabricator.com/D8801
2014-04-17 15:59:54 -07:00
epriestley
23c9e87fdf After landing to a repository, hint that it should be updated
Summary: Fixes T4605. Smart waits (see D8782) are presumably good on the balance, but may cause some delays when changes are made to rarely updated repositories. To help mitigate this, have `arc land` hint that a repository has changed.

Test Plan: Will run `arc land`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4605

Differential Revision: https://secure.phabricator.com/D8783
2014-04-16 13:01:14 -07:00
Bob Trahan
43792895a6 Arcanist - fix shouldAmend code
Summary: make it a real member variable. See rARC77a9c1814063 and D8753#33914.

Test Plan: sending up this diff!

Reviewers: shadowhand, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8761
2014-04-11 13:07:54 -07:00
Bob Trahan
77a9c18140 Arcanist - normalize question about unstaged files across workflows (diff vs land)
Summary:
Fixes T4163. Re-word the question so its the same as in "arc diff". Draw the line though and don't automagically do anything if the user says "Y", 'cuz amending / adding files last minute in 'arc land' and other workflows is batshit insane. Assuming infinite growth in the future, I think its best to get this language consistent now.

I changed the shouldAmend member variable to a shouldAmend() function with a static inside. Previously shouldAmend was getting set as a side effect and it was kind of weird. I thought maybe it was written this way because the calls to the vcs are a little slow or something. As such, I figured caching it in the static was a good idea? Didn't seem awful but maybe a premature optimization with whatever the performance reality turns out to be.

Also a modest amount of bonus pht.

Test Plan: this very diff. i'm going to arc land it laters too.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: chad, epriestley, Korvin

Maniphest Tasks: T4163

Differential Revision: https://secure.phabricator.com/D8753
2014-04-11 10:52:35 -07:00
Bob Trahan
02456c0aed Arcanist - stop arc land if local is ahead of remote
Summary: Fixes T4291. Also pht user-facing strings.

Test Plan:
made a branch `foo` off master. made a commit and a diff in `foo`. switched backed to master and cowboy committed some thing. went back to branch`foo`, did an arc land, and saw the error message. went back to master, did a git resert --hard HEAD^1, went back to branch `foo`, and then successfully arc landed.

also ran arc help land and things looked good

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4291

Differential Revision: https://secure.phabricator.com/D8738
2014-04-09 12:35:31 -07:00
epriestley
ac528ab3a8 Changed the rendering of the priority column color based on the priorityColor property
Summary:
I changed the rendering of the bar color for the `priority` column when running `arc tasks` to match the `priorityColor` property.

If the `priorityColor` property is one of the basic colors already supported by ansi, then the bar is set to that color, otherwise it is set to white.

This will allow the user to customize maniphest priorities and then set their own colors and have those colors display correctly when running `arc tasks`

Fixed some linting errors

Test Plan:
Run `arc tasks` and ensure that:
 * the priority column is displayed with a colored bar
 * the priority column bar is the correct color (or white if it is an unsupported color)

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8735
2014-04-09 12:13:40 -07:00
Brayden Winterton
7e394dcf11 Changed checking for a closed task in arc tasks to look for the isClosed property instead of a non-empty status
Summary: I changed the way `arc tasks` was checking to see if a maniphest task was closed from looking for a non-empty status to looking for the isClosed property submitted in D8731.

Test Plan: Run `arc tasks` and check that the tasks show open/closed correctly.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8732
2014-04-09 07:48:58 -07:00
Bob Trahan
2714395d98 Arcanist - allow amending revisions by other authors in the working copy
Summary: Fixes T4670. Give the user an option to abort but otherwise proceed.

Test Plan: arc patch D8685 (by epriestley); arc amend

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4670

Differential Revision: https://secure.phabricator.com/D8716
2014-04-08 11:58:50 -07:00
Peng Li
0cff627d75 Fix an issue in arc patch with git-svn
Summary:
We recently moved our HEAD and it caused some issues on `arc patch` with git-svn repos. The base revision is incorrect and patch will fail. Add the check in such case to make it work.
The check was there before but removed in change b202158. The reason wasn't mentioned there though.

Test Plan: Tried it on svn.

Reviewers: lifeihuang, JoelB, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8717
2014-04-08 10:46:27 -07:00
Bob Trahan
f099168aa8 Make "arc land" support landing someone else's code that got there via arc patch
Summary: Ref T4670.

Test Plan: arc patch D8685; arc land --hold; verified i got a nice message asking me to be sure i wanted to land epriestley's code

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4670

Differential Revision: https://secure.phabricator.com/D8709
2014-04-07 11:44:14 -07:00
Gabriel Guzman
0e5bea940c T4670 Remove the any-author flag from the which command, make any-author the default, and annotate the username of the owner of the revision.
Summary: Remove any-author flag from 'arc which' make any-author be the default behavior.  Annotate revision with the owners username.

Test Plan:
Apply a patch that you don't own (arc patch Dxxx) run 'arc which' verify that:
   1. You see the revision
   2. You see the original authors username next to the revision (owned by sjobs) etc.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8690
2014-04-03 11:30:38 -07:00
David Cramer
b8e4261455 Add coverage reports to py.test runner
Summary: Of note this now forces the pytest-cov plugin to be installed unless they turn it off.

Test Plan:
```
../arcanist/bin/arc unit

COVERAGE REPORT
     97%     changes/models/test.py
    100%     tests/changes/api/serializer/models/test_testcase.py
    100%     changes/api/serializer/models/testcase.py
 UNIT OKAY  No unit test failures.
Updated an existing Differential revision:
        Revision URI: https://tails.corp.dropbox.com/D43387

Included changes:
  M       changes/api/serializer/models/testcase.py
  M       changes/models/test.py
  M       tests/changes/api/serializer/models/test_testcase.py
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8667
2014-04-02 11:31:38 -07:00
epriestley
11e2c1688f Fix escaping of bookmarknames properly for arc patch
Summary:
Fixes T4596. I misunderstood this issue and D8512 was not correct. Specifically:

  - The `hg log` needs to be escaped, since otherwise "arcpatch-x" is interpreted as a revset.
  - The `hg update` does not need to be escaped, since updating to a revset doesn't make sense and the command never treats its argument as a revset.
  - The `hg bookmark` does not need to be escaped, for similar reasons.

Test Plan:
  - Ran these commands in isolation and got sensible, consistent results.
  - Ran `arc patch` several times in a row and got proper bookmark names.

Reviewers: btrahan, durham, rvanvelzen

Reviewed By: rvanvelzen

Subscribers: epriestley

Maniphest Tasks: T4596

Differential Revision: https://secure.phabricator.com/D8661
2014-04-01 08:21:15 -07:00
epriestley
5280f3708e Strip comments during arc diff --verbatim workflow before submitting to Phabricator
Summary: Fixes T4649. The issue in that task is caused because we're submitting a block of text including comments. We've probably been doing this for a long time, but maybe were more liberal in parsing before. Instead, strip them.

Test Plan: Ran `arc diff --verbatim` and got "Dxxx" prefilled correctly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4649

Differential Revision: https://secure.phabricator.com/D8658
2014-04-01 08:21:05 -07:00
epriestley
a36969e58b Allow arc to parse svnlook diffs from moves/copies
Summary: Ref T4697. This is similar to the existing stuff, but `svnlook diff ...` can also produce a "Copied" header. Currently, we choke on it in Herald when running pre-commit rules.

Test Plan: Added and ran tests. In the next diff, used this in a real system.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4697

Differential Revision: https://secure.phabricator.com/D8653
2014-04-01 08:20:55 -07:00
Aviv Eyal
d0bab7f34a fix tab complete for out-of-workdir
Summary:
see https://github.com/facebook/phabricator/issues/546 - arc complete blows up when not
in a workdir.

There's no "is ArcanistWorkingCopyIdentity object valid" method, but getVCSType() looks like the
closest match.

git grep for `getProjectRoot` didn't reveal any more problmatic call sites.

Test Plan: `arc [tab] [tab]`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8578
2014-03-25 17:33:23 -07:00
epriestley
46fe94db9f Support git-format-patch format in diff parser
Summary:
Fixes T4063. The `git format-patch` command produces a special header
and footer which we need to detect, strip, and parse.

Test Plan:
  - Added and ran unit tests.
  - Submitted a diff with `git format-patch HEAD^ --stdout | arc diff --raw`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4063

Differential Revision: https://secure.phabricator.com/D8547
2014-03-15 11:25:49 -07:00
epriestley
1e6d958b27 Use more modern detection of repositories in "arc close-revision"
Summary:
Fixes T4603. We fire `arc close-revision --finalize` implicitly from `arc land`, which may close a corresponding Differential revision.

We want to close if the repository is not present in Phabricator (i.e., we'll never be able to close in response to the commit message, since we'll never see it). Historically, we used Arcanist Project -> "Tracked" to make this determination. Instead, just check if the working copy is associated with a repository. This is simpler, easier, and works better.

Test Plan: Ran `arc close-revision --finalize`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: aran, epriestley

Maniphest Tasks: T4603

Differential Revision: https://secure.phabricator.com/D8523
2014-03-13 18:01:53 -07:00
epriestley
03ddc17032 Don't close revisions on "arc amend"
Summary:
Ref T4603. This workflow predates `arc land` and doesn't make much sense in modern Phabricator/Arcanist. It is surprising that `arc amend` will sometimes close accepted revisions, and we're better at detecting that repositories are tracked, and tracking repositories is easier.

Also fix some inaccuracies and old claims in the documenation and help.

Test Plan: Ran `arc amend`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: aran, epriestley

Maniphest Tasks: T4603

Differential Revision: https://secure.phabricator.com/D8522
2014-03-13 18:00:20 -07:00
epriestley
67239a08a5 Use hgsprintf() when managing bookmarks in arc patch in mercurial
Summary: Fixes T4596. I couldn't immediately reproduce this, but the `hgsprintf()` version is clearly more correct.

Test Plan: Used `arc patch --trace` to examine hg commands.

Reviewers: btrahan, durham

Reviewed By: durham

Subscribers: aran, epriestley

Maniphest Tasks: T4596

Differential Revision: https://secure.phabricator.com/D8512
2014-03-12 19:43:48 -07:00
Peng Li
ac82dea3c9 Lint engine seems to get null configuration manager in svn precommit hook workflow
Summary:
We recently tried to advance the arcanist HEAD in our release branch but failed, due to an exception in SVN pre-commit hook like this:

abort: Commit blocked by pre-commit hook (exit code 1) with output:
 LINT 1.3s FacebookWebJSLintLinter (1 file)
Exception
Some linters failed:
 - FacebookWebCopyrightLinter: BadMethodCallException: Call to a member function getConfigFromAnySource() on a non-object
(Run with --trace for a full exception trace.)

However `arc lint` works just fine. By searching the change history, it looks related to a few commits D7271, D7377, D7382, especially D7377, where configuration manager is added to the lint engine. Add it to the SVN precommit hook workflow too.

Test Plan: I am not quite sure how to test it out easily. Any suggestions?

Reviewers: lifeihuang, JoelB, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aran, epriestley, mikemag, Korvin

Differential Revision: https://secure.phabricator.com/D8492
2014-03-11 15:35:28 -07:00
Bob Trahan
37dac61131 Arcanist - add revision data to TYPE_LAND_WILLPUSHREVISION event
Summary:
pretty straight-forward stuff here. Note that in other events we use "fields" or "specification" rather than "revision"; I think "revision" is best particularly in this context where it is in fact the revision being landed.

Fixes T4565.

Test Plan: php -l

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: aran, epriestley, Korvin

Maniphest Tasks: T4565

Differential Revision: https://secure.phabricator.com/D8484
2014-03-11 15:21:46 -07:00
Joshua Spence
a2706f6539 Ignore detached git branches.
Summary:
Fixes T4559.

It looks like the code currently (at least partially) handles this by checking for `(no branch)`. I suspect that the behaviour of `git` has changed (I am running version 1.9.0) because I haven't figured out what state to be in to cause `git` to output `(no branch)`.

Test Plan: Ran `arc branch` when on a detached branch.

Reviewers: #blessed_reviewers, epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4559

Differential Revision: https://secure.phabricator.com/D8466
2014-03-09 08:04:33 -07:00
epriestley
a90a72c648 Make assertTrue() / assertFalse() messages more descriptive
Summary: See discussion in D8460. Primarily, this prints out the failing value when a true/false assertion fails, so if it was something useful (like a function result) it's visible.

Test Plan:
Added `assertTrue("quack")`:

     FAIL  ArcanistDiffParserTestCase::testParser
  Assertion failed, expected 'true' (at ArcanistDiffParserTestCase.php:16).

  ACTUAL VALUE
  quack

Added `assertFalse("quack")`:

     FAIL  ArcanistDiffParserTestCase::testParser
  Assertion failed, expected 'false' (at ArcanistDiffParserTestCase.php:16).

  ACTUAL VALUE
  quack

Added `assertEqual("quack", "moo")`:

     FAIL  ArcanistDiffParserTestCase::testParser
  Assertion failed, expected values to be equal (at ArcanistDiffParserTestCase.php:16).
  Expected: quack
    Actual: moo

Reviewers: joshuaspence

Reviewed By: joshuaspence

CC: aran

Differential Revision: https://secure.phabricator.com/D8465
2014-03-08 19:23:23 -08:00
epriestley
06cfe0746e Utilize assertFalse and assertTrue methods.
Summary:
Ref D8460.

Use `$this->assertFalse(...)` and `$this->assertTrue(...)` instead of `$this->assertEqual(false, ...)` and `$this->assertEqual(true, ...)` respectively.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8461
2014-03-08 18:33:05 -08:00
Joshua Spence
c42bef4e25 Added some additional assertion methods.
Summary:
There are quite a few tests in Arcanist, libphutil and Phabricator that do something similar to `$this->assertEqual(false, ...)` or `$this->assertEqual(true, ...)`.

This is unnecessarily verbose and it would be cleaner if we had `assertFalse` and `assertTrue` methods.

Test Plan: I contemplated adding a unit test for the `getCallerInfo` method but wasn't sure if it was required / where it should live.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8460
2014-03-08 18:23:14 -08:00
Joshua Spence
cf52d88f8b Fix unit test coverage for NoseTestEngine.
Summary:
I noticed that code coverage wasn't showing in Differential for
some repositories that we are using with Phabricator.

`arc unit` would should unit test coverage, but the paths were messy
(for example, `.//foo/bar.py` instead of `foo/bar.py`). As a result,
the code coverage info wasn't recognised as being for the correct
module.

I'm not sure why this logic is the way that it is... perhaps this is to
do with an older version of `nose` (I am using v1.3.0).

Test Plan:
I created a diff for an internal repository that we have, and
observed that code coverage was displayed in Differential.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, seporaitis, avive, dctrwatson, zeeg

Differential Revision: https://secure.phabricator.com/D8433
2014-03-07 10:17:04 -08:00
epriestley
c6b1f3f070 Fail Arcanist tests when they make zero assertions
Summary:
Fixes T4570. When a test case doesn't make any assertions, fail it:

  - A tiny fraction of tests pass by not throwing. These tests can easily make a trivial assertion. It took about 5 minutes to fix them all (D8435, D8436).
  - In other cases, no assertions means a test construction problem, as with T4570. In these cases, failing loudly catches a severe error.
  - Fixes the no-assertion test cases in `arcanist/`
  - Makes the PHP 5.4 test pass for the moment, see discussion in T4334.

Test Plan: Ran `arc unit --everything`.

Reviewers: leebyron, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4570

Differential Revision: https://secure.phabricator.com/D8437
2014-03-07 10:03:24 -08:00
epriestley
22f6207920 Fail lint tests if no tests are found in the test directory
Summary: Ref T4570. Testing a directory with no recognized tests currently passes, but should fail.

Test Plan:
  - Ran `arc unit`.
  - Removed tests from a test directory, ran `arc unit`, got test failure.

Reviewers: leebyron, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4570

Differential Revision: https://secure.phabricator.com/D8434
2014-03-07 10:03:17 -08:00
Peng Li
18251a1bd8 Remove a parameter
Summary: D7271 added this line but the signature of function ArcanistWorkingCopyIdentity::newFromRootAndConfigFile(...) was never changed. I have no idea why it was added here and it's causing failures in facebook. I am just removing it now.

Test Plan: No idea how to test

Reviewers: wez, lifeihuang, JoelB, #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8432
2014-03-06 15:53:06 -08:00
epriestley
133d289ad1 Generate a documentation book for Arcanist
Summary: Ref T988. Not pretty or polished, but works fine.

Test Plan: Generated the docs, made sure they were all there.

Reviewers: chad, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D8413
2014-03-05 13:00:40 -08:00
epriestley
7b6b24154b Add "Changes Planned" and "In Preparation" states for revisions
Summary:
Ref T2222. Discussion in T4481. Ref T2543.

Primarily, this will let me fix some of the rough edges that came out of ApplicationTransactions and state-based transitions.

I'm also adding a constant for T2543 while I'm in here.

Test Plan: Used `grep` to look for any weird special behavior, didn't see any.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2543, T2222

Differential Revision: https://secure.phabricator.com/D8400
2014-03-05 10:44:26 -08:00
Joshua Spence
fb826bbf9c Correctly identify @todo comments as TODOs.
Summary: Allow `@todo` comments to be linted as TODOs as well as `TODO` comments.

Test Plan: I added a new test case (`todo.lint-test`)

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8389
2014-03-04 11:03:09 -08:00
Joshua Spence
0888b6616c Use PHP type hinting in ArcanistXHPASTLinter.
Summary: Explicitly specify the types of the function parameters.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8388
2014-03-04 11:02:18 -08:00
Joshua Spence
9bca4bfda8 Simplified the logic in various functions.
Summary:
- Tidied up `ArcanistCSSLintLinter::getDefaultBinary`.
- Tidied up `CSSLintLinter::getDefaultFlags` function.
- Tidied up `ArcanistPhpcsLinter::getDefaultBinary` function.
- Tidied up `ArcanistPEP8Linter::getDefaultFlags` function
- Tidied up `ArcanistFlake8Linter::getDefaultFlags`.
- Tidied up `ArcanistCppcheckLinter::getLintOptions`.
- Tidied up `ArcanistCppcheckLinter::getLintPath`.
- Tidied up `ArcanistCpplintLinter::getLintOptions`.
- Tidied up `ArcanistCpplintLinter::getLintPath`.
- Removed child functions which are identical to the corresponding parent functions.

Test Plan: `arc lint` and `arc unit`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: chad, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8385
2014-03-04 11:00:01 -08:00
Joshua Spence
9fb2a147f9 Made ArcanistNoLintTestCaseMisnamed final.
Summary: Self explanatory.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8386
2014-03-04 10:55:00 -08:00
Joshua Spence
53492fd01e Removed useless comments.
Summary: To me, it seems that these comments add no value. Personal opinion I suppose.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: chad, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8382
2014-03-04 10:53:17 -08:00
Joshua Spence
9fbf316d38 Various linter fixes
Summary:
Fixed various linter issues that were identified by running `arc lint --everything`.

- Removed trailing whitespace.
- Added newline at EOF.
- Added whitespace after `if` statement

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: aurelijus, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8337
2014-02-25 07:53:07 -08:00
Joshua Spence
bd6cc6b946 Update CSSLint bindings for v0.10.0
Summary: See <https://github.com/facebook/arcanist/pull/131>

It looks like the behaviour of csslint has changed since the ArcanistCSSLintLinter was written. Consequently, ArcanistCSSLintLinter does not work with the latest version of csslint (v0.10.0).

  - `csslint` has a non-zero exit status
  - Fixed `csslint` parsing for v0.10.0

Reviewed by: epriestley
2014-02-16 15:20:29 -08:00
epriestley
13fd0a5ef1 Minor modernizations to arc browse
Summary:
Do a little cleanup:

  - Remove copyright header (we removed all of these a long time ago, this one just snuck through somehow).
  - Remove `@group` comment (obsolete with new Diviner).
  - Note support for all VCSes.
  - Add pht() for translation.
  - Hint `arc browse .`.
  - Fail on no paths sooner.
  - Raise a useful error if we can't figure out which repository we're heading to.
  - Clarify "open" comment.
  - Use `Filesystem::binaryExists()`.
  - Some minor wordsmithing.

Test Plan: `arc browse`, `arc browse .`, `arc browse README`, `arc browse README src`, ran `arc browse` in valid working copy with no associated repo.

Reviewers: btrahan, spicyj

Reviewed By: spicyj

CC: aran

Differential Revision: https://secure.phabricator.com/D8176
2014-02-09 12:19:57 -08:00
Ben Alpert
52d3cd1b4e Support browsing '.' and default to it
Test Plan: Ran 'arc browse', 'arc browse .', 'arc browse main.py'.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, avivey

Differential Revision: https://secure.phabricator.com/D8174
2014-02-09 09:01:52 -08:00
Ben Alpert
c3fe03db08 Detect repo for 'browse'; don't require project ID
Test Plan: Ran 'arc browse' in a repo that contains a .arcconfig and one without.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8173
2014-02-09 08:55:16 -08:00
epriestley
7c46000527 Permanently remove license linters
Summary: For eventual commit.

Test Plan: none

Reviewers: nh, btrahan

Reviewed By: btrahan

CC: aran, vrana, FacebookPOC

Maniphest Tasks: T2274

Differential Revision: https://secure.phabricator.com/D4907
2014-02-03 10:01:19 -08:00
Richard van Velzen
114bb9f25b Align usages of "\1" and "\2" in MercurialRepositoryAPI
Summary:
Especially on Windows it is hard to use "\1" type escapes in shell commands. The direct usage resulted in some undefined variables because the \1 and \2 weren't actually passed as control characters.

By passing them through the regular arguments list they get sent in the "correct way" regardless of OS

Test Plan: Executed `arc diff` in a HG repo and did not get undefined indexes back

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8129
2014-02-02 08:26:25 -08:00
epriestley
988a482ff3 Minor, fix an issue with SVN. 2014-01-29 15:05:51 -08:00
Guy Warner
14f2f7fdd2 Arc output the correct action being taken
Summary: Fixes T3929. If arc is merging it will say merging * into * vs always saying rebasing * onto *

Test Plan: Make arc do a rebase, then a merge

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T3929

Differential Revision: https://secure.phabricator.com/D8085
2014-01-28 08:54:01 -08:00
epriestley
d1a68ccb37 Don't consider a no-op amend to be an error in Mercurial
Summary:
Unlike git, Mercurial considers an `hg commit --amend` which doesn't change the working copy to be an error.

The current behavior for this is fairly bad, since the user gets an exception wrapping the entire command ("Command Failed! ...") and it's pretty verbose and not obvious what has happened.

Some alternatives are:

  1. Detect this condition and raise a more tailored exception, like a UsageException.
  2. Detect this condition and succeed.

Although I tend to think (1) is the right approach in general (that is, `arc x` should usually behave like `git x` or `hg x`), I went with (2) here because we have a handful of amend callsites and they all assume git semantics (no-op amends are successful), and because I think Mercurial's behavior is a little silly (the working copy ends up in the correct / expected state, which seems fairly clearly like a success to me).

Test Plan:
  - Had reporting user verify patch.
  - Ran `arc amend --revision Dxxx` twice in a Mercurial working copy.

The old output looked like this:

  $ arc amend --revision 922
  Amending commit message to reflect revision D922: Improve performance of PhutilSymbolLoader::selectAndLoadSymbols().
  Exception
  Command failed with error #1!
  COMMAND
  HGPLAIN=1 hg commit --amend -l '/private/var/folders/8k/c3vkmjy5335gcxdzxkhwq82w0000gn/T/71k8q057844c4g84/3539-gfkvV4'

  STDOUT
  nothing changed

  STDERR
  (empty)
  (Run with --trace for a full exception trace.)

The new output looks like this:

  $ arc amend --revision 922
  Amending commit message to reflect revision D922: Improve performance of PhutilSymbolLoader::selectAndLoadSymbols().
  Done.

Reviewers: btrahan, richardvanvelzen

Reviewed By: richardvanvelzen

CC: aran

Differential Revision: https://secure.phabricator.com/D8083
2014-01-28 03:03:30 -08:00
epriestley
7116659289 Improve some messaging in arc which for autodetection of repositories
Summary:
  - The modern name for the config is "project.name".
  - Missing parameter in a pht().
  - When the value is set, but not valid, we gave you a misleading error message.

Test Plan: Ran `arc which`.

Reviewers: talshiri, btrahan

Reviewed By: talshiri

CC: aran

Differential Revision: https://secure.phabricator.com/D8081
2014-01-27 19:45:18 -08:00
epriestley
1daa719ace Don't choke on blame of files with whitespace-only trailing lines
Summary:
Fixes T4349. Two issues:

  - As discussed in T4349, we would trim the entire output and then require spaces when matching. This choked incorrectly if the last line of a file contained only whitespace. Use `phutil_split_lines()` instead, and regexp things more reasonably.
  - We were capturing the line text, not the commit, as "revision". This isn't actually used elsewhere, but was obviously wrong. Make this consistent with Git/SVN.

Test Plan: Rigged a call up and saw reasonable output after the patch, on a working copy which threw before the patch.

Reviewers: durham, btrahan

Reviewed By: durham

CC: aran

Maniphest Tasks: T4349

Differential Revision: https://secure.phabricator.com/D8078
2014-01-27 11:03:08 -08:00
epriestley
b1d3948d77 Default to array() when failing to look up repository PHIDs.
Auditors: btrahan
2014-01-27 10:36:40 -08:00
epriestley
a7376624b4 Allow arc to identify repositories without "project_id"
Summary:
Ref T4343. Continues the process of reducing the prominence of Arcanist Projects. Primarily:

  - Query Phabricator to identify the working copy based on explicit configuration, or guess based on heuristics.
  - Enhance `arc which` to explain the process to the user.
  - The `project_id` key is no longer required in `.arcconfig`.

Minor/cleanup changes:

  - Rename `project_id` to `project.name` (consistency, clarity).
  - Rename `conduit_uri` to `phabricator.uri` (consistency, clairty).
  - These both need documentation updates.
  - Add `repository.callsign` to explicitly bind to a repository.
  - Updated `.arcconfig` for the new values.
  - Fix a unit test which broke a while ago when we fixed a rare definition of "unstaged".
  - Make `getRepositoryUUID()` generic so we can get rid of one `instanceof`.

Test Plan:
  - Ran `arc which`.
  - Ran `arc diff`.
  - This doesn't really change anything, so the only real risk is version compatibility breaks. This //does// introduce such a break, but the window is very narrow: if you upgrade `arc` after this commit, and try to diff against a Phabricator which was updated after yesterday (D8068) but before D8072 lands, the lookup will work so we'll add `repositoryPHID` to the `differential.creatediff` call, but it won't exist in Phabricator yet. This window is so narrow that I'm not going to try to fix it, as I'd guess there is a significant chance that no users will be affected. I don't see a clever way to fix it that doesn't involve a lot of work, either.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4343

Differential Revision: https://secure.phabricator.com/D8073
2014-01-26 15:31:30 -08:00
epriestley
e4b1e8e681 Use user.query, not user.find, in arc tasks
Summary: I'm going to deprecate `user.find`, `user.query` is more modern/powerful and obsoletes it.

Test Plan: Ran `arc tasks --owner epriestley`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D8070
2014-01-25 14:23:23 -08:00
Sergey Sharybin
2c2c5663cb Fix exception on diff parse on FreeBSD
FreeBSD 9.2 comes with diff tool version 2.8.7 which behaves
a bit different from how it is expected to. Namely for diff
between two binary files it says:

  Files A and B are differ

This was leading to an exception when browsing revisions with
changes in binary files.

Tweaked parse patterns in order to fix this issue. Now both
older and newer diff tools are supported.

See: <https://github.com/facebook/arcanist/pull/139>

Reviewed by: epriestley
2014-01-18 11:13:28 -08:00
epriestley
a247e21093 Call willLintPath() hook from PhutilLinter
Summary:
Some callpaths end up here, which doesn't cause the internal linter's willLintPath() method. This can mean its `activePath` is set wrong, which results in us raising lint for the wrong file.

Particularly, if you apply D7979 (diff 18069) and `arc lint` it, you'll get a syntax error message in the wrong file.

Test Plan: Applied D7979 and linted it, got proper error message.

Reviewers: btrahan

Reviewed By: btrahan

CC: aarwine, aran

Differential Revision: https://secure.phabricator.com/D7988
2014-01-17 21:30:18 -08:00
Jonathan Hitchcock
7ce0c8e84e Prompt user for commit message when auto-committing
See: <https://github.com/facebook/arcanist/pull/137>

Reviewed by: epriestley
2014-01-14 15:27:50 -08:00
Joshua Spence
d62bd48a81 Added ArcanistTextLinter::LINT_BOF_WHITESPACE and ArcanistTextLinter::LINT_EOF_WHITESPACE
Summary: This might not be universally desireable, but I found myself writing an additional linter (which I had called `WhitespaceTextLinter`) for the sake of these two linter tests. I figured it may be of use upstream, and so I decided to submit it as a diff. I won't be offended if it is rejected however.

Test Plan: `arc lint` and `arc unit` are both okay with it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7957
2014-01-13 18:05:42 -08:00
Joshua Spence
dd12b72f9a Added test namespace field to ArcanistUnitTestResult
Summary: See https://github.com/facebook/libphutil/issues/34

Test Plan: Run `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7952
2014-01-13 12:37:26 -08:00
Joshua Spence
ef598794a8 Skip unit tests if ArcanistLinter::getCacheVersion throws an ArcanistUsageException
Summary: Fixes T4288

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4288

Differential Revision: https://secure.phabricator.com/D7913
2014-01-09 09:25:35 -08:00
Joshua Spence
66e3614f69 Allow PhutilUnitTestEngine::getTestsForPaths to return paths from the library root directory
Summary: Currently, running `arc unit -- src/` returns with `No tests to run`, even if there are test classes in `src/__tests__/`. This diff changes this behaviour so that `arc unit -- src/` executes unit tests in `src/__tests__/`.

Test Plan: N/A. I suppose you could create a file `src/__tests__/SomeTestCase.php` and see for yourself.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7915
2014-01-09 05:21:55 -08:00
Joshua Spence
e2234a5be9 Allow ArcanistLinterTestCase to find "lint-test" files at an arbitrary depth
Summary: Self-explanatory

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7910
2014-01-08 16:23:58 -08:00
Joshua Spence
90a5a8512e Allow tests to be executed in the root library directory
See: <https://github.com/facebook/arcanist/pull/135>

Reviewed by: epriestley
2014-01-03 12:55:10 -08:00
epriestley
488b8e365a In Subversion, treat missing files similarly to conflicted files
Summary: See <https://github.com/facebook/arcanist/issues/133>. Treat "!" files like "C" and "?" files and make the user deal with them.

Test Plan:
  >>> orbital ~/repos/INIS $ svn st
  !       README
  >>> orbital ~/repos/INIS $ arc diff
  Usage Exception: You have missing files in this working copy. Revert or formally remove them (with `svn rm`) before proceeding.

    Working copy: /INSECURE/repos/INIS/

    Missing files in working copy:
      README

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7886
2014-01-03 12:23:34 -08:00
iodragon
6769c6b17c Show current config and source using arc set-config --show
Summary:
`arc set-config --show` only show the user config
It would be better to contain local/global/system config

Test Plan: set config by local/global/system/user/project, and check the result of `arc set-config --show`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: epriestley, aran

Differential Revision: https://secure.phabricator.com/D7851
2014-01-02 12:09:03 -08:00
Eric Stern
739881a3f4 Print a more useful error message if any PHPUnit tests crash
Summary:
Before, if PHPUnit crashed (syntax error, undefined constant, etc), you would get a relatively unhelpful error message:

    firehed@Eric-Sterns-Mac-Pro ~/dev/php-lcd: arc unit
    Exception
    Clover coverage XML report file is empty, it probably means that phpunit failed to run tests. Try running arc unit with --trace option and then run generated phpunit command yourself, you might get the answer.
    (Run with --trace for a full exception trace.)

This now checks the json and code coverage reports and tries to pull a useful error message:

  firehed@Eric-Sterns-Mac-Pro ~/dev/php-lcd: arc unit
  Exception
  The test '/Users/firehed/dev/php-lcd/tests/PlateButtonsTest.php' crashed with the following output:

  Fatal error: Undefined class constant 'EFT' in /Users/firehed/dev/php-lcd/tests/PlateButtonsTest.php on line 25

  Call Stack:
  	0.0002     233104   1. {main}() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/composer/bin/phpunit:0
  	0.0039     564872   2. PHPUnit_TextUI_Command::main() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/composer/bin/phpunit:63
  	0.0039     565496   3. PHPUnit_TextUI_Command->run() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
  	0.0247    2280168   4. PHPUnit_TextUI_TestRunner->doRun() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
  	0.0293    2730760   5. PHPUnit_Framework_TestSuite->run() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
  	0.1211    3996832   6. PHPUnit_Framework_TestSuite->runTest() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
  	0.1211    3996832   7. PHPUnit_Framework_TestCase->run() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
  	0.1211    3996832   8. PHPUnit_Framework_TestResult->run() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
  	0.1233    3999752   9. PHPUnit_Framework_TestCase->runBare() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
  	0.1236    4016432  10. PHPUnit_Framework_TestCase->runTest() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
  	0.1237    4017240  11. ReflectionMethod->invokeArgs() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
  	0.1237    4017520  12. Firehed\PlateButtonsTest->testSingleButtonOnButtonDown() /Users/firehed/dev/php-lcd/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983

  (Run with --trace for a full exception trace.)

Or if nothing was written to `stderr`, you may get something like this:

  firehed@Eric-Sterns-Mac-Pro ~/dev/php-lcd: arc unit --no-coverage
  Exception
  Test Firehed\PlateButtonsTest::testSingleButtonOnButtonDown did not finish
  (Run with --trace for a full exception trace.)

Test Plan:
`arc unit` for arcanist itself
`arc unit` before and after the change on a project where:
* all tests pass
* some tests are failing
* a test causes a fatal error (undefined constant, bad method call, etc)
* a test file is invalid (syntax error)

No regressions that I could find, and all crashes now display a more useful error.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: aurelijus, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7848
2014-01-02 12:02:22 -08:00
epriestley
35c01eee7b Improve arc lint --output summary
Summary:
This currently output like this:

  file_a:
  file_b:
  file_c:
    Warning on line 29: blah blah

This isn't especially useful and can't be piped to other tools. Instead, emit output like:

  file_c:29:Warning: blah blah

This is greppable / pipeable.

Test Plan: Ran `arc lint --output summary`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7788
2013-12-18 14:21:03 -08:00
epriestley
8e177c4db8 Parse the output of svnlook diff ...
Summary: Ref T4195. When figuring out changed content in SVN, the easiest approach is to use `svnlook diff`, but it has a slightly different header than we're used to. Adjust the parser for it and add some tests.

Test Plan: Clean unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4195

Differential Revision: https://secure.phabricator.com/D7790
2013-12-18 14:20:59 -08:00
Joshua Spence
cd0ee5492a Make sure the local arc config directory exists on ArcanistWorkingCopyIdentity::writeLocalArcConfig
See: <https://github.com/facebook/arcanist/pull/126>

Reviewed by: epriestley
2013-12-11 06:42:46 -08:00
epriestley
e0b4eef9de Make sure no one ever misunderstand the "unkonwn symbol" lint message ever again
Summary: A lot of new contributors don't resolve this. Make it easier to resolve, more comprehensive, and more explicit about not being ignorable.

Test Plan:
  >>> orbital ~/devtools/arcanist $ arc lint
  >>> Lint for src/lint/linter/ArcanistPhutilLibraryLinter.php:

     Error  (PHL1) Unknown Symbol
      Use of unknown class 'BlerpBarp'. Common causes are:

        - Your libphutil/ is out of date.
          This is the most common cause.
          Update this copy of libphutil: /INSECURE/devtools/libphutil

        - Some other library is out of date.
          Update the library this symbol appears in.

        - This symbol is misspelled.
          Spell the symbol name correctly.
          Symbol name spelling is case-sensitive.

        - This symbol was added recently.
          Run `arc liberate` on the library it was added to.

        - This symbol is external. Use `@phutil-external-symbol`.
          Use `grep` to find usage examples of this directive.

      *** ALTHOUGH USUALLY EASY TO FIX, THIS IS A SERIOUS ERROR.
      *** THIS ERROR IS YOUR FAULT. YOU MUST RESOLVE IT.

               181               "*** THIS ERROR IS YOUR FAULT. YOU MUST RESOLVE IT.");
               182
               183             if (false) {
      >>>      184               new BlerpBarp();
               185             }
               186           }
               187         }
  >>> orbital ~/devtools/arcanist $

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D7752
2013-12-10 08:33:35 -08:00
epriestley
4fdb87761b Fix working copy binding powers in weird edge cases
Summary:
Fixes T1277. The rules we use to figure out the root of the working copy get a bunch of edge cases wrong right now. A particularly troublesome one is when a user has a `/.arcconfig` or `/home/.arcconfig` or similar, which raises a completely useless and confusing error message (T1277).

Rewrite these rules to get all the edge cases correct and do reasonable things in the presence of stray `.arcconfig`. There are a bunch of comments, but basically the algorithm is:

  - From the top, go down one directory at a time until we find ".svn", ".git", or ".hg".
  - In Subversion, keep going down looking for ".arcconfig". In Git and Mercurial, look for ".arcconfig" only in the same directory.
  - Now that we've figured out the VCS root (where the ".vcs" directory is) and the project root (where the ".arcconfig" file is, if it exists), build an identity.

This logic was also spread across three different places. Consolidate it into one and add some logging so we can figure out what's going wrong if users run into trouble.

Test Plan:
  - Ran VCS (`arc list`) and non-VCS (`arc help`) commands in Git, Mercurial, and Subversions roots and subdirectories. Also ran them in non-VCS directories. Ran them with and without .arcconfig. All the outputs seemed completely reasonable.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1277

Differential Revision: https://secure.phabricator.com/D7686
2013-12-03 10:32:31 -08:00
James Rhodes
00d5eb2f21 Update C# tools unit test engine to work
Summary: This updates the C# tools unit test engine (the derived version of xUnit.NET test engine that supports code coverage) to work after the updates in D7594.

Test Plan:
Switched the test engine from 'XUnitTestEngine' to 'CSharpToolsTestEngine' and ran `arc unit --everything`.  The results were identical except that code coverage was provided.

Tested on Linux; will update or comment based on whether it works on Windows as well.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7640
2013-11-26 18:00:44 +11:00
Chris Dentel
d30c77d0a8 Add output-json option to arc feature
Summary:
The current format of arc feature is not very friendly to parsing.  This adds a json output
format.

Test Plan: Run the command and ensure output is valid

Reviewers: lifeihuang, #blessed_reviewers, epriestley

Reviewed By: epriestley

CC: epriestley, aran, Korvin

Differential Revision: https://secure.phabricator.com/D7647
2013-11-25 11:50:11 -08:00
James Rhodes
799841a0d8 Remove debugging output from xUnit.NET test engine
Summary: This just removes the `print "Discovered test .."` code in the xUnit.NET unit test engine.  If users need to diagnose what tests are being debugged, it can be found out with `--trace` and observing what build commands are invoked.

Test Plan: Ran `arc unit --everything` and didn't see the message any more.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7639
2013-11-24 11:36:45 +11:00
James Rhodes
bd191c2860 Fix issues in C# unit test engine
Summary: This fixes a few issues in the C# unit test engine.  It fixes tests sitting in subdirectories not being tested correctly (the location of both the test assembly and the results file would be wrong).  It also fixes a very strange issue where xUnit.NET seems to not output the resulting XML file when it executes; in this case we just retry running the test until the XML file appears after completion (and eventually it works).

Test Plan: Ran `arc unit --everything` and `arc unit --everything --no-coverage` and verified that it's all reliably working.

Reviewers: epriestley, #blessed_reviewers, hach-que

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7594
2013-11-22 14:32:48 -08:00
Ramkumar Ramachandra
6033f14221 ArcanistGitAPI: replace 'ls-files -m' with diff-files
As documented,

  $ git ls-files -m

fails to exclude ignored submodules. Replace it with an equivalent:

  $ git diff-files --name-only

which does not suffer from this defect.

See: <https://github.com/facebook/arcanist/pull/121>

Reviewed by: epriestley
2013-11-22 08:39:20 -08:00
Ramkumar Ramachandra
e62b23e67d ArcanistGitAPI: document a git ls-files bug
When a submodule is ignored (ignore=all in .gitconfig),

  $ git ls-files -m

fails to exclude the submodule from the listing. Other commands like

  $ git diff-index --name-only HEAD

exclude it just fine.

See: <https://github.com/facebook/arcanist/pull/120>

Reviewed by: epriestley
2013-11-22 05:35:37 -08:00
Ramkumar Ramachandra
86eae809e0 ArcanistGitAPI: remove a bogus comment
See: <628de7d7a1 (commitcomment-4675543)>

This comment is indecipherable even if it originally meant something.

Reviewed by: epriestley
2013-11-22 05:28:37 -08:00
James Rhodes
fb8a0d32ae Set limit for execution in C# linter
Summary: This sets the limit for future execution in the C# linter to 8.  See D7606 for more information.

Test Plan:
Ran

```
arc lint --everything --trace --never-apply-patches --output json
```

and saw it only run 8 commands at once.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7607
2013-11-19 13:36:27 -08:00
James Rhodes
61753b6770 Upgrade C# linter to support linting multiple files at a time
Summary:
This upgrades `cslint` to support linting multiple files at a time.  As this required a backwards-incompatible to `cslint`, I've added a SUPPORTED_VERSION constant which can be used to detect these kinds of breaking changes in the future (and prompt users to upgrade the `cslint` they have in their repository).

The reason for this upgrade is mainly around running `arc lint --everything`, where there are significant performance benefits gained when bulk linting lots of files per command execution.

Test Plan: Upgraded `cslint` in the Tychaia repository and ran `arc lint --everything --trace`.  Saw a substantially less number of executions happening for linting and all of the results came through as expected.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, waynea

Differential Revision: https://secure.phabricator.com/D7599
2013-11-18 11:32:58 -08:00
Burak Yigit Kaya
19edbbb46e Make ScriptAndRegexLinter available to ConfigurationDrivenLintEngine
See: <https://github.com/facebook/arcanist/pull/118>

Reviewed by: epriestley
2013-11-18 10:08:19 -08:00
Anirudh Sanjeev
17e4e9e651 Fix markup in documentation for arcanist lint engine
Summary: Fixed wrong markup which was 1 space instead of 2

Test Plan: I couldn't test it as I don't know how to build documentation

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7587
2013-11-14 10:19:08 -08:00
epriestley
9310df9615 Handle empty output from hg --debug branches in the parser
Summary: Ref T1493. Also consolidate this a bit more.

Test Plan: Unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1493

Differential Revision: https://secure.phabricator.com/D7481
2013-11-04 12:15:12 -08:00
Sven Axelsson
aabbdbd2ab Filter out messages from included files
Summary:
CppCheck shows lint messages from included files as well as the current
file. Filter out those, since they don't make much sense in the context
of `arc lint`.

Test Plan:
Before this patch, `arc lint` using `ArcanistCppcheckLinter`. Note that lint messages
from included files appear pointing to a line in the active file.
After this patch, only messages from the active file are included.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7444
2013-10-30 13:46:30 -07:00
Aviv Eyal
6dc04af6e8 Specify custom arcrc filename
Summary: allow specifing an replacement .arcrc file, for the odd cases.

Test Plan: `echo {} | arc call-conduit user.whoami` with and without `--arcrc-file=`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7208
2013-10-25 15:57:38 -07:00
Aviv Eyal
0d212ccf5a rename getConfig -> getProjectConfig, make all linters use getConfigFromAnySource
Summary:
Lingers on from D7271; Rename `ArcanistWorkingCopyIdentity.getConfig()`.

Changed all linters (Except one) to use `getConfigFromAnySource()`, because it seems to make sense.

Test Plan: arc unit --everything; arc lint in github.com:epriestley/arclint-examples.git (Except for phpcs, flake8, cpplint and csslint which I don't have installed).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: chad, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7382
2013-10-22 15:34:06 -07:00
Aviv Eyal
4103bc423c get Config Manager to Unit engine and use getConfigFromAnySource
Summary:
somewhat related to D7271 and D7377.
Not actually broken right now, but might be worth it for completeness.

Test Plan: arc unit invokes PHPUnit; Can't test Csharp/XUnit on my end.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: aurelijus, Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7381
2013-10-22 13:58:32 -07:00
epriestley
ddbc14ade1 Provide ConfigurationManager to LintEngine in Arcanist
Summary: Unbreaks ArcanistSingleLintEngine / ArcanistScriptAndRegexLinter from recent config churn.

Test Plan: `arc lint --engine ArcanistSingleLintEngine --rev HEAD^`

Reviewers: btrahan

Reviewed By: btrahan

CC: csilvers, aran

Differential Revision: https://secure.phabricator.com/D7377
2013-10-21 16:57:22 -07:00
epriestley
5c2f7b2abd Autocomplete branch names in arc feature
Summary: SPOOKY

Test Plan: `arc feature <tab>`

Reviewers: cpojer, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7376
2013-10-21 16:29:08 -07:00
Pascal Borreli
831fc9a92b Fixed typos
See: https://github.com/facebook/arcanist/pull/110

Reviewed by: epriestley
2013-10-20 07:53:23 -07:00
epriestley
2c64f1b072 Minor, fix a missing config source change. 2013-10-19 13:32:59 -07:00
Aviv Eyal
359e1c2803 Couple of fixes from refactor
Test Plan: arc set-<tab> <enter> from a not-workspace.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7354
2013-10-18 16:41:50 -07:00
epriestley
d85f7bee66 Minor, fix a typo. 2013-10-18 16:19:22 -07:00
Aviv Eyal
a2285b2b5a Extract configuration read/write methods out of BaseWorlkflow
Summary:
Create a new class for them, pass instance around as need.

This looks like it's mostly working, but I'd like to replace the various `new ArcanistConfigurationManager()`
calls with something more suitable.

And maybe get a better name for ArcanistConfigurationManager ("Configuration" is already taken).

Test Plan: arc unit --everything, and then some.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, chad

Differential Revision: https://secure.phabricator.com/D7271
2013-10-18 16:10:45 -07:00
Bob Trahan
b2021586d4 Arcanist - make Patch workflow automagically apply dependencies
Summary: Nice title. Ref T479.

Test Plan:
Actually, help on that? I want to make sure I properly build up the "depends" on data. Is it as simple as

  -- observe at some commit hash RAZZMATAZZ
  -- git checkout -B "foo"
  -- <work>
  -- git commit -m "stash"
  -- arc diff -> yields DX
  -- git checkout -B "foo_prime"
  -- <work>
  -- git commit -m "stash"
  -- arc diff -> yield DY
  -- git checkout RAZZMATAZZ
  -- arc patch DY
  -- get prompted in workflow, agree
  -- git log and observe DX and DY applied

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, davidressman

Maniphest Tasks: T479

Differential Revision: https://secure.phabricator.com/D6790
2013-10-17 14:59:04 -07:00
epriestley
13e422e123 Remove spurious +x from arcanist
Summary: A few files here have +x, but should not. Also correct a
spelling mistake.
2013-10-05 05:20:05 -07:00
root
10a9bb1e99 Keep Arcanist from mistaking paths that look like svn:externals as svn:externals
Summary: Fixes T3920. Added a slash to the path and external name so that "public" and "publicnotexternal" won't appear to be the same root.

Test Plan:
We've had this issue in one of our projects for some time, just ran into it again today. Ran the patched arc against the same directory structure and the troublesome file was added to the diff. Confirmed that files
modified in the "public" (svn external) folder are still caught as external modifications.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3920

Differential Revision: https://secure.phabricator.com/D7226
2013-10-04 17:31:18 -07:00
Tal Shiri
4e892e7269 get jshint error codes
Summary:
makes jshint slightly more useful by printing out error numbers. I love memorizing numbers.
Sorry about the crappy getLintMessageName(). There was no list of error names, just the long descriptions that are already rendered as 'reason'.

Test Plan: Verify that the numbers are mezmorizing. Been tested on OSX with jshint v2.1.11

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7213
2013-10-04 06:29:47 -07:00
epriestley
587addfd94 Strip comments from all diffs before parsing them
Summary:
See <https://github.com/facebook/phabricator/issues/400>. Since all of `patch`, `git apply` and `hg export` either accept or emit header comments, parse them unconditionally.

This is a tiny bit messy because we already had a less-general parser for `hg export` diffs, which have a large header section.

This is less permissive than GNU `patch`, which allows comments anywhere. We could do that, but `git apply` won't read them and they seem pretty crazy.

Test Plan: Added and ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7207
2013-10-03 15:06:35 -07:00
Tal Shiri
0ece525d6c added getLinterConfigurationName() to ArcanistJSHintLinter.
Summary: Needed for it to be usable from ArcanistConfigurationDrivenLintEngine, which is pretty ok.

Test Plan: put jshint in your .arclint and feel the electricity in the air.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7200
2013-10-02 19:02:40 -07:00
James Rhodes
02e4a690dd Add C# linter for Arcanist.
Summary:
Completes T3859.  This implements a C# linter for Arcanist, which in turn uses `cslint` from `cstools` to actually perform the linting.  `cslint` internally uses StyleCop in addition to it's own lint rules.

Unlike other linters, C# is a compiled language, which means that the StyleCop integration must be aware of the full project.  To this end, there is the `discovery` setting in `.arclint`.  This allows users to define mappings between C# files and the projects they belong to.  Here is an configuration for `.arclint` (and is the one we use):

```
{
  "linters": {
    "csharp": {
      "type": "csharp",
      "include": "(\\.cs$)",
      "binary": "cstools/cslint/bin/Debug/cslint.exe",
      "discovery": {
        "([^/]+)/(.*?)\\.cs": [
          "$1/$1.Linux.csproj"
        ],
        "([^\\\\]+)\\\\(.*?)\\.cs": [
          "$1\\$1.Windows.csproj"
        ]
      }
    }
  }
}
```

Test Plan: Tested under both Linux and Windows.  Changed some files, ran `arc lint` and it all worked correctly.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, jamesr

Maniphest Tasks: T3859

Differential Revision: https://secure.phabricator.com/D7170
2013-10-01 11:37:26 -07:00
Aviv Eyal
0b8ea973ae Fix coverage for NoseTestEngine
Summary:
In case that the $source_path is `.` or empty, it produces filenames that
look like `./foo.py`, which differential doesn't like.

Test Plan: arc diff, see coverage data.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7181
2013-09-30 10:44:38 -07:00
Aviv Eyal
aebcd7a985 Extract xUnit test results parser
Summary:
Many test frameworks can format their output in xUnit-like format.

Test Plan: Tested the Nose engine with a Nose one, and the pytest with a demo project.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7011

Conflicts:
	src/__phutil_library_map__.php
2013-09-30 10:44:13 -07:00
epriestley
9bae517a38 Fix a stiring issue in the External linter
Summary: See error message in D7170 --  this should be a `.`, not a `,`.

Test Plan:
Faked interprerter and got reasonable error message:

> Unable to locate interpreter "TESTpython2.6" to run linter ArcanistPEP8Linter. You may need to install the intepreter, or adjust your linter configuration.
> TO INSTALL: Install PEP8 using `easy_install pep8`.

This doesn't fix the //real// error, which is that the test should skip if you don't have the interpreter/binary, but that's a little more involved.

Reviewers: hach-que, chad, btrahan

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D7172
2013-09-29 07:44:33 -07:00
Gareth Evans
1ead3cc307 Set the CWD before applying a git patch
Summary:
If in a subdirectory, any changes made in a different location
is missed from the patch with no errors from git. The other
option was to run some logic to compare the files being changed.

Test Plan:
Run arc patch from a subdirectory that would miss some files
previously.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3733

Differential Revision: https://secure.phabricator.com/D7167
2013-09-28 06:53:20 -07:00
Chris Dentel
08536d8917 Adding arc lint flag that will show lint only on changed lines - even when paths are specified
Summary:
The existing lint configurations do not allow for linting only the lines that have
changed when paths are added.  --lintall has a default behavior of true when paths are specified,
and false when paths are not specified.  Because of this (and because it does not take a boolean
param) it is not possible to lint a path for only the errors on changed lines - only-new is not
working presently.

Test Plan: play around with the linter

Reviewers: lifeihuang

Reviewed By: lifeihuang

CC: epriestley, aran

Differential Revision: https://secure.phabricator.com/D7055
2013-09-27 10:13:31 -07:00
epriestley
6270dd0de5 Add https.blindly-trust-domains to Arcanist
Summary:
This allows users to specify that they want to implicitly trust their weird self-signed certificate without verification.

This can either be specified per user (which will make it apply every time the user runs `arc`, in any project):

  arc set-config https.blindly-trust-domains '["example.mycompany.com"]'

...or added to a `.arcconfig` file (which will make it apply to every user who runs `arc` in that project):

  "https.blindly-trust-domains" : ["example.mycompany.com"]

Depends on D7130.

Test Plan: Tweaked config and verified this setting sends HTTPSFuture down the right branch.

Reviewers: btrahan

Reviewed By: btrahan

CC: hlau, aran

Differential Revision: https://secure.phabricator.com/D7131
2013-09-25 15:26:38 -07:00
epriestley
0d0333d50a Fix an issue where method prototypes have different signatures
Summary: PHP whines about this:

> [2013-09-23 08:09:22] ERROR 2048: Declaration of CSharpToolsTestEngine::loadEnvironment() should be compatible with XUnitTestEngine::loadEnvironment($config_item = 'unit.xunit...') at [/INSECURE/devtools/arcanist/src/unit/engine/CSharpToolsTestEngine.php:13]

Auditors: jamesr, btrahan
2013-09-23 08:34:28 -07:00
James Rhodes
4ba895c30d Add C# tools and xUnit unit test engines.
Summary:
This implements Arcanist support for the xUnit testing framework.  It also supports code coverage by way of `cstools` (which is something I've written).

The unit test support works under both Linux and Windows, while the code coverage support has only been tested under Linux (one would assume it would also work under Windows given that Windows has a super-set of functionality in the C# world).

The Arcanist support assumes that the directory layout will be something like:

  * MyProject
  * MyProject.Tests

When files are changed in either MyProject or MyProject.Tests, it causes MyProject.Tests to be built and the xUnit runner to be executed on the resulting binary.

Test Plan: I guess if really wanted to, you could create a C# project in MonoDevelop, set up `.arcconfig` to point to this unit test engine, and download and build xUnit and cstools.  Run `arc unit --coverage` to see the results of your unit test coverage.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3859

Differential Revision: https://secure.phabricator.com/D7058
2013-09-23 05:32:34 -07:00
James Rhodes
75737c6d89 Prevent detailed code coverage from accessing missing report.
Summary:
Fixes T3856.

Detailed code coverage iterates over all of the files with changes in the current repository, however the code coverage tool might not generate a report for all changed files in the repository, and this would result in an undefined index error.

As an additional bonus, since changes to binary files won't be reported by code coverage tools, this also prevents binary data from being outputted to the console.

Test Plan:
Change a binary file in a repository and run a code coverage tool.  The binary file should be reported as 0% code coverage, but the file contents should not be rendered to the console.

Change a code file that is not covered by a code coverage tool and run code coverage.  The file should be reported as 0% code coverage, and the file contents should not be displayed.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3856

Differential Revision: https://secure.phabricator.com/D7051
2013-09-20 09:18:02 -07:00
Eric Stern
bfcb3cfcd0 Perform case-insensitive check for PHPUnit test finder to not return original file
Summary: PhpunitTestEngine incorrectly included some source files as tests when run on a case-insensive fiesystem. This fixes that behavior. It could introduce problems for case-sensive users, but it's extremely unlikely to be an issue in practice (who would put a file in both Tests/ and tests/ and expect different results for the two?)

Test Plan: arc unit before and after change on OS X. Stubs and autoloaders in .../tests/... directories are no longer picked up.

Reviewers: epriestley

Reviewed By: epriestley

CC: aurelijus, Korvin, aran

Differential Revision: https://secure.phabricator.com/D7048
2013-09-19 15:14:58 -07:00
Jakub Vrana
bfbb16f322 Pluralize add files questions
Test Plan: Saw 'Do you want to add these files to the commit?'

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6991
2013-09-14 08:06:50 -07:00
epriestley
c00d8c551c Correct capitalization of "new" in lint
Summary: Automatically correct `New` to `new` in lint.

Test Plan: Ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6948
2013-09-12 13:01:25 -07:00
epriestley
ba3c8e3356 Ignore errors from "svn upgrade" in unit tests
Summary: See discussion in D6893. Different versions of `svn` do different stuff, just ignore any possible error here.

Test Plan: Ran unit tests.

Reviewers: andrewjcg, btrahan

Reviewed By: andrewjcg

CC: aran

Differential Revision: https://secure.phabricator.com/D6946
2013-09-11 21:23:30 -07:00
Aviv Eyal
1fa8e861b2 parse ls-tree with git-submodule correctly
Summary:
git ls-tree gives type 'commit' for submodules.

This code-path is only used when a binary file is present in the diff.

Test Plan: arc diff with a binary file

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6943
2013-09-11 10:36:23 -07:00
epriestley
699f3b3c05 Fix an issue with PHPCS output formatting
Summary:
See <https://github.com/facebook/arcanist/issues/102>. PHPCS changed its output format sometime between 1.4.6 (stable) and 1.5.0RC3.

Add a "no errors" test and make the linter work on both versions.

Test Plan: Ran `arc unit` on PHPCS 1.5.0RC3.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6926
2013-09-10 15:10:34 -07:00
katherine
5fd07856c0 [lint][spelling] delimeter -> delimiter
Summary:
I got bit by this one earlier (I swear I thought it was delimeter),
so I figured I would add it to the spelling data lint rule.

Test Plan:
changed an instance of delimiter to delimeter, ran `arc lint` fixed the
typo.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6936
2013-09-10 11:36:17 -07:00
Evan Priestley
70567e48ae Merge pull request #90 from dcramer/pytest
Add PytestTestEngine
2013-09-06 11:49:56 -07:00
epriestley
5b869c2349 Fix arc + svn + delted binary file with properties + image heuristic
Summary:
See IRC. This fixes an issue when deleting an SVN file that ends with one of the extensions in the regexp, which may only affect newer versions of SVN.

Possibly we shouldn't have this heuristic, or should move it elsewhere or make it more explicit, but at least stop it from being broken for now.

Test Plan: Ran `arc diff --only` in a working copy with a deleted binary file ending in ".jpg".

Reviewers: btrahan, nh

Reviewed By: nh

CC: aran, mbishopim3

Differential Revision: https://secure.phabricator.com/D6893
2013-09-05 15:05:26 -07:00
Bob Trahan
67061480f9 Tighten up "arc land"
Summary:
Make sure on failure (restoreBranch()) we call `git submodule update --init --recursive` to handle all those purdy submodules. For the pushing step, wrap the push commands in the try / catch block so everything gets cleaned up nice if there's failure. BONUS - add --recursive to arc patch workflow to so nested submodules work correctly. (Crazy git users)

Fixes T3407, T2945.

Test Plan: I wasn't sure how to simulate a good "push" failure but I think this should work.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T2945, T3407

Differential Revision: https://secure.phabricator.com/D6885
2013-09-05 12:45:59 -07:00
Nick Harper
db3581b8fa Don't error on first run of arc diff
Summary:
When running arc diff in a repository that supports commit ranges, it is
possible that the setting for the default relative commit hasn't been set.
If this is the case, the user will be prompted. This change makes sure that
the prompt happens (and thus the setting is set) before we run the
background lint and unit runs.

Test Plan:
```
rm .git/arc/default-relative-commit
arc diff
```

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T2351

Differential Revision: https://secure.phabricator.com/D6854
2013-08-31 14:57:10 -07:00
Wez Furlong
4a3d829223 Fixup lint testing for changes in D6798
Summary:
We have some linters that trigger based on the path name
in the tree (some rules apply in some dirs and not others).
The changes in D6798 caused all the paths to appear to be outside
the tree, so allow for passing a fake through from those test cases
that are sensitive to this.

We also have a test for the copyright linter, and that needs to read
settings from the .arcconfig file.  The change to faking a working
copy meant that this config option was effectively unset, so add a way
to pass the entire arcconfig through from the tests that need it.

Lastly, the logic to skip deleted files needs to be special cased
when we're faking paths like this: if we've added data for a file
in the testable engine, we should also consider that file as existing.

Test Plan:
`arc unit --everything` here, and passing our tests in
our repo over there.

Reviewers: epriestley, mareksapota

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6841
2013-08-29 09:55:30 -07:00
epriestley
2c5c9815c0 Support PHPCS as a .arclint linter
Summary:
Ref T3186. Ref T2039. Ref T3771. A few effects here:

  # Expose PHPCS as a `.arclint` linter.
  # Turn PHPCS into an ArcanistExternalLinter linter.
  # Add test coverage for PHPCS.
  # Add a `severity.rules` option to `.arclint`. Some linters have very explicit builtin severities ("error", "warning") but their meanings are different from how arc interprets these terms. For example, PHPCS raises "wrong indentation level" as an "error". You can already use the "severity" map to adjust individual rules, but if you want to adjust an entire linter it's currently difficult. This rule map makes it easy. There's substantial precedent for this in other linters, notably all the Python linters.

For `severity.rules`, for example, this will turn all PHPCS "errors" into warnings, and all of its warnings into advice:

      "severity.rules" : {
        "(^PHPCS\\.E\\.)" : "warning",
        "(^PHPCS\\.W\\.)" : "advice"
      }

The user can use `severity` (or more rules) to get additional granularity adjustments if they desire.

Test Plan: 5bb919bc3a

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, ajtrichards

Maniphest Tasks: T2039, T3186, T3771

Differential Revision: https://secure.phabricator.com/D6830
2013-08-29 06:47:27 -07:00
Bob Trahan
96a47759ae Make arc patch slightly better about submodules
Summary:
Ref T3776, Ref T479. Say you have some DN, with a submodule X@Y. Later, X@Z in your working copy / repo. If you run arc patch DN, you'd end up with a dirty working copy claiming that X@Z was wrong and it should be X@Y.

To fix, basically run 'submodule init' and 'submodule update'. This makes it so after "arc patch" if you run "git status" it looks clean.

Gross part though now is if you then "git checkout master" you'll have a dirty checkout the other way. I think this is better though.

Test Plan: made a new repository where I added libphutil @ X, did some work (DX), then made libphutil @ y. When I arc patch'd DX, things looked good!

Reviewers: epriestley

Reviewed By: epriestley

CC: csilvers, Korvin, aran

Maniphest Tasks: T479, T3776

Differential Revision: https://secure.phabricator.com/D6837
2013-08-28 16:47:30 -07:00
epriestley
3ad72195bf When converting a file to a binary, populate the binary's data
Summary:
Currently, we prompt the user to mark non-UTF8 files as binary, but don't actually attach the data to the change when they do. This means we don't upload the data, and can't patch it later.

A simple reproduction case is to build a test file (I used one with bytes from 1..255):

  $ # Don't include \0, since Git treats that specially.
  $ ./echo_every_byte_from_1_to_255_inclusive.erl > example.txt

Then add it:

  $ git add example.txt
  $ git commit -a -m derp
  $ arc diff --only HEAD^

You'll be prompted to convert the file to binary:

  Do you want to mark this file as binary and continue? [Y/n] y

Before this patch, that would be followed by:

  Uploading 0 files...

...which is incorrect; we need to upload the new data. After this patch, this shows:

  Uploading 1 files...

...which is also incorrect, but only grammatically. Diffs created after this patch apply back cleanly with `arc patch` and restore the file properly.

Test Plan: Followed instructions above, restoring a textual binary conversion by using `arc patch`.

Reviewers: zeeg, btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6815
2013-08-27 09:34:30 -07:00
Eric Stern
a28d4ff3e4 Add support for 'phpunit_binary' config setting
Summary:
If present, this will override the default phpunit path. Allows easy
integration of Composer-provided installs of phpunit (ex. set phpunit_binary to
vendor/bin/phpunit). If the path provided doesn't resolve to an executable it
will assume the path is relative to the project root.

fix line length issue

Test Plan:
Added phpunit_binary to .arcconfig in a simple project using Composer with
phpunit/phpunit package as part of require-dev (installed to
$ROOT/vendor/bin/phpunit). Phpunit not otherwise installed on the system. Set
unit.engine to PhpunitTestEngine. Confirmed that 'arc unit' used the specified
binary, both at project root and from subdirectories.

Reviewers: epriestley

CC: aurelijus, Korvin, aran

Differential Revision: https://secure.phabricator.com/D6791
2013-08-26 09:59:51 -07:00
epriestley
65c19ff0c0 Automatically answer excuse prompts if stdin is not a TTY
Summary: Fixes T3696. Currently, we abort. If stdin is not a TTY, we should just continue. A script which cares could conceivably run `arc lint` and `arc unit` separately, but it seems unlikely that any script would ever want to fail here.

Test Plan: Ran `echo -n '' | arc diff --create --verbatim` with a lint error and got a revision (D6720).

Reviewers: Firehed, btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3696

Differential Revision: https://secure.phabricator.com/D6721
2013-08-26 05:41:32 -07:00
epriestley
0f30aca626 Ready more linters and linter functions for .arclint
Summary:
Ref T3186. Ref T2039. Continues work on readying linters for `.arclint`.

  - **Ruby**: Make this an ExternalLinter.
  - **Priority**: Currently, linters have an implicit "correct" order (notably, the "NoLint" linter needs to run before other linters). Make this explicit by introducing `getLinterPriority()`.
  - **Binaries**: Currently, linters manually reject binary files. Instead, reject binary files by default (linters can override this if they do want to lint binary files).
  - **Deleted Files**: Currently, linters manually reject deleted files (usually in engines). Instead, reject deleted files by default (linters can override this).
  - **Severity**: Move this `.arclint` config option up to top level.
  - **willLintPaths()**: This method is abstract, but almost all linters provide a trivial implementation. Provide a trivial implementation in the base class.
  - **getLintSeverityMap()/getLintNameMap()**: A bunch of linters have empty implementations; these are redundant. Remove them.
  - **Spelling**: clean up some dead / test-only / unconventional code.
  - **`.arclint`**: Allow the filename, generated, nolint, text, spelling and ruby linters to be configured via `.arclint`.

Test Plan:
458beca3d6

Ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: Firehed, aran

Maniphest Tasks: T2039, T3186

Differential Revision: https://secure.phabricator.com/D6805
2013-08-26 05:37:10 -07:00
durham
57bc582ad2 Better heuristic for checking for hgsubversion
Summary:
The existing heuristic checks for the existence of .hg/svn, but it
turns out that this directory can exist in a non-svn hg repo if the user or a
script ever runs a 'hg svn' command.

Now we check for a file inside .hg/svn.  The hgsubversion maintainer said this
particular file will always be present in hgsubversion repos.

Test Plan:
arc land --trace
Verified it used 'hg push' and not 'hg push -r ...'. This indicates it
considered the repo to be an hgsubversion repo.

Reviewers: epriestley

Reviewed By: epriestley

CC: dschleimer, sid0, Korvin, aran

Differential Revision: https://secure.phabricator.com/D6807
2013-08-23 16:40:15 -07:00
epriestley
1f3cb63db2 Expose PEP8, Flake8 and CSSLint engines to .arclint
Summary:
Ref T3186. Ref T2039. Allow these linters to be selected with `.arclint`.

Also allow severities to be set.

Also fix some other minor bugs.

Test Plan:
https://github.com/epriestley/arclint-examples
https://github.com/epriestley/arclint-examples/blob/master/.arclint

Reviewers: btrahan

Reviewed By: btrahan

CC: chad, aran

Maniphest Tasks: T2039, T3186

Differential Revision: https://secure.phabricator.com/D6803
2013-08-23 11:58:07 -07:00
epriestley
6e5be59ad6 Port flake8 to ArcanistExternalLinter
Summary:
Ref T3186. Brings another linter onboard. This one uses the stdin stuff.

The unit test was ostensibly broken so I fixed it, but that might just be some kind of version issue.

Test Plan: Unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3186

Differential Revision: https://secure.phabricator.com/D6802
2013-08-23 11:52:54 -07:00
epriestley
e23fc30c19 Introduce a rough abstract base class for "linters which run programs and read the results"
Summary:
Ref T3186. We have about 50 linters which run programs and read the results, all of which have ad-hoc one-off custom config that isn't formalized anywhere.

Consolidate all this stuff into `ArcanistExternalLinter`, which is configurable through `.arclint` (although nothing supports this quite yet).

Extend CSSLint and Pep8Lint from `ArcanistExternalLinter`.

Add unit tests for both.

There are still some rough edges here, but it mostly seems to work pretty well.

Test Plan: Ran unit tests, hit some (most?) of the error cases.

Reviewers: btrahan

Reviewed By: btrahan

CC: chad, aran, Firehed

Maniphest Tasks: T3186

Differential Revision: https://secure.phabricator.com/D6800
2013-08-23 11:52:44 -07:00
Chad Little
c882877f50 Rebuild map
Summary: rebuild arc map

Test Plan: run phabricator

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3748

Differential Revision: https://secure.phabricator.com/D6804
2013-08-23 05:29:40 -07:00
epriestley
f18130a6aa Simplify and demuck some of the linter test cases
Summary:
Ref T3186.

  - Every linter builds a WorkingCopyIdentity in the same way, with no specialized data. Don't do that.
  - Linters get passed a goofy hardcoded ".php" path. Don't do that.
  - Linters generally run on an imaginary path, which might not work. Just give them a real path by building a tiny working copy in `/tmp`.
  - Fix a TODO now that we have better typechecking.

Test Plan: `arc unit --everything`, intentionally broke a test to make sure that still works.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3186

Differential Revision: https://secure.phabricator.com/D6798
2013-08-22 16:02:41 -07:00
epriestley
97ad54ed00 Lay groundwork for configuration-driven linters
Summary:
Ref T2039. That task has a bunch of discussion, but basically we do a poor job of serving the midrange of lint configuration right now.

If you have something simple, the default linters work.

If you have something complex, building your own engine lets you do whatever you want.

But many users want something in between, which isn't really well accommodated. The idea is to let you write a `.arclint` file, which looks something like this:

  {
   "linters" : {
      "css" : {
        "type" : "csslint",
        "include" : "(\.css$)",
        "exclude" : "(^externals/)",
        "bin" : "/usr/local/bin/csslint"
      },
      "js" : {
        "type" : "jshint",
        "include" : "(\.js$)",
        "exclude" : "(^externals/)",
        "bin" : "support/bin/jshint",
        "interpreter" : "/usr/local/bin/node"
      }
   }
  }

...which will provide a bunch of common options around lint severity, interpreter and binary locaitons, included and excluded files, etc.

This implements some basics, and very rough support in the Filename linter.

Test Plan:
Generated a `.arclint` file and saw it apply filename lint correctly. Used `debug` mode and tried invalid regexps.

  {
    "debug" : true,
    "linters" : {
      "filename" : {
        "type" : "filename",
        "exclude" : ["@^externals/@"]
      }
    }
  }

Next steps include:

  - Provide an external linter archetype (T3186) and expose a common set of configuration here ("bin", "interpreter", "flags", "severity").
  - Provide a `.arcunit` file which works similarly (it can probably be simpler).

Reviewers: btrahan, Firehed

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D6797
2013-08-22 16:02:16 -07:00
Firehed
5eb82c8e7d fix issue where multi-line dataproviders in phpunit were parsed incorrectly when displaying results
Summary: Found an issue where if arc unit runs phpunit and the datasets included a dataprovider which spanned multiple lines, it wasn't filtered out correctly in the result parser, this fixes it

Test Plan: accidentally ran tests against phpunit itself which exhibits this problem. no longer a problem after this fix, nothing else breaks.

Reviewers: epriestley

Reviewed By: epriestley

CC: aurelijus, epriestley, aran

Differential Revision: https://secure.phabricator.com/D6773
2013-08-20 06:58:14 -07:00
durham
8465c4dd53 Fix arc land for mercurial on windows
Summary:
arc for mercurial on windows was broken in several way.
Executing a command via passthru failed because passthru on windows
skips the shell so 'set HGPLAIN=1 & ...' was an invalid command. The
fix was to just not set HGPLAIN for passthru commands on windows.

Also removed hardcoded '' quotes in mercurial commands since windows
doesn't support single quots.

Test Plan: arc land --hold on a windows machine

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6763
2013-08-14 18:00:51 -07:00
Firehed
acb90fd9e7 fixes local svn branch name detection
Summary: Corrects relative vs absolute branch name when using 'arc commit'

Test Plan: 'arc commit' on a release branch gave an error before making the change (change was generated from 'branches/yyy' but working copy root is 'https://xxx/branches/yyy', now it does not.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6743
2013-08-13 14:16:14 -07:00
Eric Stern
c11b9e1af9 Fix 'arc lint --everything' when svn has uncommitted changes
Summary: My recent change adding --everything to arc lint could sometimes cause a "diff is empty" error, this patch fixes it.

Test Plan: Ran "arc lint --everything" before and after patch. No longer errors out. Only appeared to originally happen when there were uncommited changes in an svn repo.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D6732
2013-08-12 13:47:43 -07:00
Mehdi Mulani
857b754c7e Use underscores instead of hyphens as bookmark suffixes.
Summary:
When trying to find an unused bookmark we append hyphened suffixes to the end of the bookmark name. In Mercurial, these are treated the same as the bookmark name without the suffix, here's the output from hg log -r:

```
[mehdi] HGPLAIN=1 hg log -r "arcpatch-1"
abort: unknown revision 'arcpatch'!
[mehdi] HGPLAIN=1 hg log -r "arcpatch_1"
abort: unknown revision 'arcpatch_1'!
```

Test Plan: None.

Reviewers: epriestley, dschleimer

Reviewed By: dschleimer

CC: aran, Korvin, DurhamGoode, dschleimer

Differential Revision: https://secure.phabricator.com/D6698
2013-08-07 14:56:03 -07:00
Eric Stern
dccc8571d7 Improve arc commit with SVN branches
Summary:
If you are trying to commit someone else's diff, arc commit gives warnings about path mismatch. This changes the path comparison to be based on the repo url rather than the local working directory. E.g. if both the author and committer are working in branches/release/2013_08_07 despite being checked out in ~/dev/2013_08_07 (system user being different, of course) it no longer warns that the WC path is different

Original behavior:

	eric@Eric-MBP ~/dev/2013_07_31: arc commit --revision 21
		You are not the author of 'D21: WeMerge Automatic Request'. Commit this
		revision anyway? [y/N] y

		Revision 'D21: WeMerge Automatic Request' was generated from '', but
		current working copy root is '/Users/eric/dev/2013_07_31/'. Commit this
		revision anyway? [y/N] y

	Committing 'D21: WeMerge Automatic Request'...
	Adding         test
	Transmitting file data .
	Committed revision 52676.
	Closing revision D21 'WeMerge Automatic Request'...
	Exception
	ERR-CONDUIT-CORE: You can not mark a revision you don't own as closed.
	(Run with --trace for a full exception trace.)

New behavior:

	eric@Eric-MBP ~/dev/2013_07_31: arc commit --revision 24

		You are not the author of 'D24: WeMerge Automatic Request'. Commit this
		revision anyway? [y/N] y

	Committing 'D24: WeMerge Automatic Request'...
	Adding         test
	Transmitting file data .
	Committed revision 52679.
	Closing revision D24 'WeMerge Automatic Request'...
	Exception
	ERR-CONDUIT-CORE: You can not mark a revision you don't own as closed.
	(Run with --trace for a full exception trace.)

Test Plan: 'arc diff' changes with one user. 'arc patch Dxx' on a different working copy by a different user to review and test changes. accept review. 'arc commit --revision xx' as reviewer to land the patch. complaint goes away.

Reviewers: epriestley, ghostwriter78

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D6665
2013-08-04 09:01:22 -07:00
Eric Stern
5e3b436099 Pass global CA bundle to HTTPSFuture, T3668
Summary: Update and clarify precedence of CA bundles

Test Plan:
tested with "arc call-conduit user.whoami" from project root
Same from other subdirectory in project
Repeated tests with both https.cabundle and https.cacert settings, both in
.arcconfig and ~/.arcrc

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3668

Differential Revision: https://secure.phabricator.com/D6647
2013-08-04 08:21:35 -07:00
Lajos Veres
a680c55670 Add CSSLint linter to Arcanist
See: https://github.com/facebook/arcanist/pull/93

Reviewed by: epriestley
2013-08-02 05:14:00 -07:00
Aviv Eyal
d54f0f69d4 arc unit --output none
Summary:
Support for no output from arc unit (For scripts, etc).
Also include --output param, analogous to arc lint --output.

Test Plan: run all 6 variants + `--output bad-value`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6642
2013-08-01 12:07:21 -07:00
durham
5b69749812 Remove hard coded single quotes in arc feature
Summary:
Single quotes aren't valid in the windows cmd prompt, so arc feature
didn't work in mercurial when it got to this line.

I have no idea why %C was used before.  Nothing in that string should be
broken by the escaping.

Test Plan:
Ran arc feature --trace on my mac. Verified the command was escaped correctly
and the correct feature results were printed.

I don't have a windows machine to try it on, but the builtin escaping should
now account for windows machines.

Reviewers: epriestley

Reviewed By: epriestley

CC: sid0, aran, Korvin

Differential Revision: https://secure.phabricator.com/D6637
2013-08-01 10:14:38 -07:00
Jakub Vrana
19181fb3e8 Remove warning about deprecated phutil_render_tag()
Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6567
2013-07-28 11:00:00 -07:00
Eric Stern
12f2175da1 Add --everything support to 'arc lint'
Summary:
When adding arcanist support to a new project or adding a new linter,
it's helpful to be able to run new linters against the entire codebase. This
patch adds support for this with an '--everything' option, similar to 'arc unit
--everything'

Test Plan:
Run 'arc lint --everything' and check out the code. Optionally dump
the paths to test in the current lint engine's buildLinters() function to
demonstrate that it's receiving all files in the project rather than just the
changed and/or specified ones

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D6592
2013-07-27 18:29:20 -07:00
Eric Stern
b56634ad27 Pass correct filename into PHPUnitTestEngine coverage
Summary: The test result parser in PhpunitTestEngine was receiving $test_path from the previous loop instead of $path from the current one. The variable isn't actually used in the PhpunitResultParser object (it exists for strict compatibility with the parent class) so it didn't cause any problems, but who knows if that could change in the future

Test Plan: Review diff. No changes to the output of running 'arc unit' when using the Phpunit engine, as expected

Reviewers: epriestley

CC: aran, epriestley, aurelijus, chad

Differential Revision: https://secure.phabricator.com/D6587
2013-07-26 19:10:17 -07:00
epriestley
490984936b Revert "Merge pull request #93 from vlajos/csslint"
This reverts commit 2852a965e3, reversing
changes made to 46bb3dbc36.

See: https://github.com/facebook/arcanist/pull/93
2013-07-22 06:52:08 -07:00
Jeff Ferland
2852a965e3 Merge pull request #93 from vlajos/csslint
CSS lint support for arcanist using csslint.
2013-07-22 06:44:22 -07:00
Aviv Eyal
46bb3dbc36 arc browse: Support line number and reduce conduit call
Summary:
support common "filename:line number" format.
Also, remove redundent conduit call.

Test Plan: arc browse with and without :33 suffix.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6451
2013-07-14 19:17:02 -07:00
Jakub Vrana
ad9cb418c4 Display line number with assertion for failed test cases
Summary: We use custom `assert*` functions here and there. Remove them from backtrace.

Test Plan: Ran `XHPASTTreeTestCase`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6411
2013-07-10 08:42:49 -07:00
Jakub Vrana
f5ceceea87 Lint undeclared variables in strings
Summary: Depends on D6405.

Test Plan:
New unit test.
Linted libphutil, Arcanist, Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6406
2013-07-10 08:26:11 -07:00
Lajos Veres
2e30c97ade comment typo fix 2013-07-09 14:11:21 +01:00
Lajos Veres
2b07f22e08 update __phutil_library_map__ 2013-07-09 12:48:07 +01:00
Lajos Veres
395c15e630 add css lint 2013-07-09 12:46:59 +01:00
epriestley
fbcd686e18 Update spelling replacement rule for 'algorithmical'
Summary:
I suspect that when people use 'algorithmical', they mean it as an adjective and not an adverb.

'algorithmic' = adjective
'algorithmically' = adverb

Test Plan: Add the word 'algorithmical' to a file. Run `arc lint` on the file. See suggestion to correct it to 'algorithmic'.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6373
2013-07-08 09:46:24 -07:00
epriestley
910df64d31 Stop using deprecated Conduit methods in arc
Summary:
  - Replace `maniphest.find` with `maniphest.query`. These calls are nearly identical, it was just a rename for consistency.
  - Replace `differential.find` with `differential.query`.

Test Plan:
  - Ran `arc tasks`.
  - Ran `arc close-revision` on valid, nonexistent, and existent-but-invalid revisions.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6336
2013-07-02 05:47:52 -07:00
Miorel-Lucian Palii
7130004015 Don't instantiate abstract classes in ArcanistConfiguration::buildAllWorkflows
Summary:
I wanted to write a couple of workflows that shared some code in an abstract superclass, but ##arc## would fail trying to instantiate the abstract class.

As it turns out, we can modernize the ##buildAllWorkflows## function a bit, and it will only load concrete objects.

Test Plan:
1. Define an abstract subclass of ##ArcanistBaseWorkflow##.
2. ##arc liberate## the source directory that contains it.
3. Try any ##arc## operation without this diff, and see it fail.
4. Patch this diff and see that ##arc## operations work now.

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6324
2013-06-28 18:24:30 -07:00
Gareth Evans
a746ad8757 Update some output based on flag being set
Summary: Makes sense now

Test Plan: Get someone else to test it

Reviewers: epriestley

CC: aran, Korvin

Maniphest Tasks: T3342

Differential Revision: https://secure.phabricator.com/D6307
2013-06-25 15:26:14 -07:00
Gareth Evans
4f3dee80e5 Allow passing library name with flag
Summary: Enables the process to pass the user input for library name. Fixes T3342

Test Plan: Little help... `arc liberate` doesn't run on windows. Though I saw the flag :)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3342

Differential Revision: https://secure.phabricator.com/D6306
2013-06-25 15:20:30 -07:00
Gareth Evans
1d5ee03fdb Add Delete Flag to Paths ignore mask
Summary:
When `arc diff` runs unit tests it uses all of the affected files as the base array of paths. These files may have been deleted. If the deleted file fits the test criteria `unit` will try and run the test and in some cases fail.

An example of this fataling is with PHPUnit;

> Fatal error: Uncaught exception 'Exception' with message 'JSON report file is em
pty, it probably means that phpunit failed to run tests. Try running arc unit wi
th --trace option and then run generated phpunit command yourself, you might get
 the answer.' in C:\Websites\facebook\arcanist\src\unit\engine\PhpunitResultPars
er.php on line 156

Test Plan: Re-ran the tests that were causing issues with `arc unit --rev HEAD^ --trace`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, aurelijus

Differential Revision: https://secure.phabricator.com/D6246
2013-06-20 07:35:30 -07:00
durham
b713eb51c9 Don't prepopulate update message in hg amend diff workflow
Summary:
Previously, updating a commit via arc diff in mercurial would
prepopulate the update message with part of the commit message.  In an
amend workflow this doesn't make sense, so I disabled it. Git already
does this, so now mercurial matches git in this scenario.

We had users complain that new users would often submit diffs with the
default update message, and it wasn't useful since they were using a
amend flow.

Test Plan:
arc diff on a commit that already had a diff
Verified the editor did not have a update message
arc diff on a stack of commits where the bottom one had a diff
Verified the editor provided a default update message

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6215
2013-06-17 11:40:58 -07:00
David Cramer
81a1c09148 Add PytestTestEngine 2013-06-13 14:23:45 -07:00
epriestley
c38bc4376c When a file upload fails during "arc diff", show why
Summary: We currently swallow the exception message, but this isn't useful. Fixes T3354.

Test Plan:
  $ arc diff HEAD^ --conduit-uri=http://local.aphront.com:8080/ --only
  Uploading 1 files...
  Failed to upload new binary 'large.png'.

  [HTTP/500] Internal Server Error
  As received by the server, this request had a nonzero content length but no POST data.

  Normally, this indicates that it exceeds the 'post_max_size' setting in the PHP configuration on the server. Increase the 'post_max_size' setting or reduce the size of the request.

  Request size according to 'Content-Length' was '2093052', 'post_max_size' is set to '100K'.

      Continue? [Y/n]

Reviewers: jamesr, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T3354

Differential Revision: https://secure.phabricator.com/D6186
2013-06-12 05:50:08 -07:00
epriestley
2e61b1a3df Fix a catch class name
Summary: Now that we examine these in lint, this came up. There is no `ConduitException`; the class is `ConduitClientException`.

Test Plan: Lint.

Reviewers: vrana, chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D6158
2013-06-11 06:26:42 -07:00
Omer Strulovich
9a46ba7ea1 Support for lint messages which are always shown
Summary: If one wishes to implement a linter which finds unused resources or variables the current scheme does not work as the lint engine filters all changes from lines which were not introduced in a diff. To solve that, I've added an "always show" configuration for a lint message allowing creation of such linters.

Test Plan:
1. Created a custom linter for finding unused Android resources in a project
2. Ran arc lint with linter added and received warnings as expected

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6119
2013-06-09 08:38:30 -07:00
Jakub Vrana
5336f4bcf0 Verify classes used in typehints
Summary: Also support `SomeInterface::CONSTANT`.

Test Plan:
  interface I {
    const A = 1;
  }
  I::A;

  function f(stdClass $a, array $b, Iterator $c) {
  }

Linted Phabricator.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6135
2013-06-05 13:53:43 -07:00
epriestley
e93726cb3b Fix some Arcanist lint warnings
Summary: Lint. See https://github.com/facebook/phabricator/pull/332

Test Plan: Lint.

Reviewers: chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D6126
2013-06-04 15:29:39 -07:00
epriestley
ae66d4caa9 Use a temporary file to execute arc patch
Summary:
Piping data around on Windows doesn't work well when it contains zany characters like "null" and "newline". Fixes T3266.

Instead of piping data into `git apply`, write to a temporary file.

Test Plan:
Ran `arc patch`, got good results.

  >>> [17] <exec> $ git apply --index --reject -- '/private/var/folders/8k/c3vkmjy5335gcxdzxkhwq82w0000gn/T/7z9iea6srikoo0sc/4266-ZEyvz9'

Reviewers: btrahan, hach-que

Reviewed By: hach-que

CC: aran

Maniphest Tasks: T3266

Differential Revision: https://secure.phabricator.com/D6070
2013-05-30 21:03:21 -07:00
James Rhodes
50419e584d Fixing the star on unit tests for Windows consoles
Summary: On Windows consoles, the star on the unit tests (I'm assuming it's a Unicode character of some kind), doesn't render correctly and you just get garbage.  This fixes it so that on Windows, it falls back to just using an ASCII asterisk.

Test Plan: On Windows run some unit tests, the star should now be a plain asterisk.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6087
2013-05-30 20:57:00 -07:00
epriestley
1fcf7bac4e Compute UTF8 string differences correctly, accounting for combining characters
Summary:
@Afaque_Hussain has done a bunch of utf8 work here; combined with PhutilEditDistanceMatrix we can now do utf8 diffs correctly, in a general way, without a significant performance impact.

Use PhutilEditDistanceMatrix and `phutil_utf8v_combined()` to compute accurate diffs for all (or, at least, most) UTF8 text.

The only thing this doesn't handle completely correctly is lines beginning with combining characters. This is messy/expensive to handle and will probably never actually happen, so I'm punting for now. Nothing should actually break.

The utf8 stuff will be slow, but we only pay for it when we need it.

Test Plan:
Ran unit tests. I changed a few unit tests to use a non-combining character (snowman) for clarity, and some results are different now (since we get combining characters right).

{F44064}

Reviewers: btrahan, Afaque_Hussain

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D6019
2013-05-23 14:38:09 -07:00
epriestley
24d54a5fbd Use PhutilEditDistanceMatrix in ArcanistDiffUtils
Summary: Replace this old hard-coded implementation with the new vector-based, unicode-capable one.

Test Plan: Ran unit tests. Looked at revisions in Differential, using whitespace modes to bypass cache.

Reviewers: btrahan, Afaque_Hussain

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D6016
2013-05-23 14:36:42 -07:00
Gareth Evans
4c37e6ff4a Allow an unassigned flag to be passed to arc tasks
Summary: Returns unassigned tasks

Test Plan: Run `arc tasks`, `arc tasks --unassigned`, make sure I get the correct results

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3201

Differential Revision: https://secure.phabricator.com/D6009
2013-05-23 10:36:40 -07:00
Jakub Vrana
eb449a40b4 Update PHP compat info
Summary: Also warn against functions not available on Windows at all.

Test Plan: Compared old and new file.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5975
2013-05-22 11:36:41 -07:00
Afaque Hussain
0b8e9823fa Implementing prefix and suffix diffing for multi-byte unicode characters.
Summary: Prefix and suffix diffing for multi-byte unicode characters.

Test Plan:
Test diff:
------------------------------------------------------------
diff --git a/test b/test
index 252ad2f..a5bad3b 100644
--- a/test
+++ b/test
@@ -1 +1 @@
-This file contains this and this stuff.
+This file contains žžžž and this stuff.
--------------------------------------------------------------

{F43738}
--------------------------------------------------------------

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D5925
2013-05-21 13:06:14 -07:00
Jakub Vrana
a1c0ba785d Lint for PHP 5.3 on Windows
Test Plan: Linted `FileFinder`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5972
2013-05-19 11:00:08 -07:00
Bob Trahan
a45ef76a8f Arcanist changes related to T2784
Summary: These were in my sandbox, but I forgot about them. Without this things break post D5896. Ref T2784

Test Plan: my sandbox works and soon so shall others

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2784

Differential Revision: https://secure.phabricator.com/D5929
2013-05-14 15:24:20 -07:00
epriestley
592172c775 Remove "--allow-empty-message"
Summary: @alex has git 1.7.0.4 which doesn't have this flag. We don't actually need it: we always provide a commit message when calling this method. Remove the flag for compatibility, leaving a note in case we bump into this in the future.

Test Plan: N/A

Reviewers: btrahan, vrana, alex

Reviewed By: alex

CC: aran

Differential Revision: https://secure.phabricator.com/D5926
2013-05-14 13:35:42 -07:00