]> khamidou — GitHub mirrors - arcanist.git/log
arcanist.git
12 years agoMake assertTrue() / assertFalse() messages more descriptive
epriestley [Sun, 9 Mar 2014 03:23:23 +0000 (19:23 -0800)]
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

12 years agoUtilize `assertFalse` and `assertTrue` methods.
epriestley [Sun, 9 Mar 2014 02:32:32 +0000 (18:32 -0800)]
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

12 years agoAdded some additional assertion methods.
Joshua Spence [Sun, 9 Mar 2014 02:23:14 +0000 (18:23 -0800)]
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

12 years agoFix unit test coverage for `NoseTestEngine`.
Joshua Spence [Fri, 7 Mar 2014 18:16:27 +0000 (10:16 -0800)]
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

12 years agoFail Arcanist tests when they make zero assertions
epriestley [Fri, 7 Mar 2014 18:03:24 +0000 (10:03 -0800)]
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

12 years agoFail lint tests if no tests are found in the test directory
epriestley [Fri, 7 Mar 2014 18:03:17 +0000 (10:03 -0800)]
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

12 years agoRemove a parameter
Peng Li [Thu, 6 Mar 2014 23:53:06 +0000 (15:53 -0800)]
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

12 years agoGenerate a documentation book for Arcanist
epriestley [Wed, 5 Mar 2014 21:00:40 +0000 (13:00 -0800)]
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

12 years agoAdd "Changes Planned" and "In Preparation" states for revisions
epriestley [Wed, 5 Mar 2014 18:44:26 +0000 (10:44 -0800)]
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

12 years agoCorrectly identify `@todo` comments as TODOs.
Joshua Spence [Tue, 4 Mar 2014 19:03:09 +0000 (11:03 -0800)]
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

12 years agoUse PHP type hinting in `ArcanistXHPASTLinter`.
Joshua Spence [Tue, 4 Mar 2014 19:02:18 +0000 (11:02 -0800)]
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

12 years agoSimplified the logic in various functions.
Joshua Spence [Tue, 4 Mar 2014 19:00:01 +0000 (11:00 -0800)]
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

12 years agoMade `ArcanistNoLintTestCaseMisnamed` final.
Joshua Spence [Tue, 4 Mar 2014 18:55:00 +0000 (10:55 -0800)]
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

12 years agoRemoved useless comments.
Joshua Spence [Tue, 4 Mar 2014 18:53:16 +0000 (10:53 -0800)]
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

12 years agoVarious linter fixes
Joshua Spence [Tue, 25 Feb 2014 15:53:06 +0000 (07:53 -0800)]
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

12 years agoAdd password_* functions to extension functions list
epriestley [Fri, 21 Feb 2014 01:26:03 +0000 (17:26 -0800)]
Add password_* functions to extension functions list

Summary: These are technically added in PHP 5.5.0 mainline, not an extension, but the two are effectively equiavlent.

Test Plan: o.O

Reviewers: btrahan, dctrwatson

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D8280

12 years agoUpdate CSSLint bindings for v0.10.0
Joshua Spence [Mon, 23 Dec 2013 13:44:47 +0000 (00:44 +1100)]
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

12 years agoMinor modernizations to `arc browse`
epriestley [Sun, 9 Feb 2014 20:19:57 +0000 (12:19 -0800)]
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

12 years agoSupport browsing '.' and default to it
Ben Alpert [Sun, 9 Feb 2014 17:00:54 +0000 (09:00 -0800)]
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

12 years agoDetect repo for 'browse'; don't require project ID
Ben Alpert [Sun, 9 Feb 2014 16:55:16 +0000 (08:55 -0800)]
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

12 years agoPermanently remove license linters
epriestley [Mon, 3 Feb 2014 18:01:19 +0000 (10:01 -0800)]
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

12 years agoAlign usages of "\1" and "\2" in MercurialRepositoryAPI
Richard van Velzen [Sun, 2 Feb 2014 16:26:25 +0000 (08:26 -0800)]
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

12 years agoMinor, fix an issue with SVN.
epriestley [Wed, 29 Jan 2014 23:05:51 +0000 (15:05 -0800)]
Minor, fix an issue with SVN.

12 years agoArc output the correct action being taken
Guy Warner [Tue, 28 Jan 2014 16:53:50 +0000 (08:53 -0800)]
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

12 years agoDon't consider a no-op amend to be an error in Mercurial
epriestley [Tue, 28 Jan 2014 11:03:30 +0000 (03:03 -0800)]
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

12 years agoImprove some messaging in `arc which` for autodetection of repositories
epriestley [Tue, 28 Jan 2014 03:45:18 +0000 (19:45 -0800)]
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

12 years agoDon't choke on blame of files with whitespace-only trailing lines
epriestley [Mon, 27 Jan 2014 19:03:08 +0000 (11:03 -0800)]
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

12 years agoDefault to `array()` when failing to look up repository PHIDs.
epriestley [Mon, 27 Jan 2014 18:36:40 +0000 (10:36 -0800)]
Default to `array()` when failing to look up repository PHIDs.

Auditors: btrahan

12 years agoRestore "project.name" (previously "project_id") to .arcconfig for arcanist
epriestley [Mon, 27 Jan 2014 00:11:25 +0000 (16:11 -0800)]
Restore "project.name" (previously "project_id") to .arcconfig for arcanist

Summary:
A couple of things actually still care about this:

  - The code that detects if we're running `arc` on `arc`, and then runs the `arc` we're running on instead of the `arc` we ran, checks for the project being "arcanist" (`reenter_if_this_is_arcanist_or_libphutil()`).
  - Some of the symbol stuff still relies on it.
  - Removing it was really more to prove it works (which it seems to) than to accomplish any concrete goals.

Test Plan: looked at the file I guess

Reviewers: btrahan, talshiri

Reviewed By: talshiri

CC: aran
Differential Revision: https://secure.phabricator.com/D8076

12 years agoAllow `arc` to identify repositories without "project_id"
epriestley [Sun, 26 Jan 2014 23:31:30 +0000 (15:31 -0800)]
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

12 years agoUse `user.query`, not `user.find`, in `arc tasks`
epriestley [Sat, 25 Jan 2014 22:23:23 +0000 (14:23 -0800)]
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

12 years agoFix exception on diff parse on FreeBSD
Sergey Sharybin [Fri, 17 Jan 2014 10:37:55 +0000 (16:37 +0600)]
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

12 years agoCall willLintPath() hook from PhutilLinter
epriestley [Sat, 18 Jan 2014 05:30:18 +0000 (21:30 -0800)]
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

12 years agoPrompt user for commit message when auto-committing
Jonathan Hitchcock [Tue, 14 Jan 2014 23:20:08 +0000 (15:20 -0800)]
Prompt user for commit message when auto-committing

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

Reviewed by: epriestley

12 years agoAdded `ArcanistTextLinter::LINT_BOF_WHITESPACE` and `ArcanistTextLinter::LINT_EOF_WHI...
Joshua Spence [Tue, 14 Jan 2014 02:05:42 +0000 (18:05 -0800)]
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

12 years agoAdded test namespace field to `ArcanistUnitTestResult`
Joshua Spence [Mon, 13 Jan 2014 20:35:33 +0000 (12:35 -0800)]
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

12 years agoSkip unit tests if `ArcanistLinter::getCacheVersion` throws an `ArcanistUsageException`
Joshua Spence [Thu, 9 Jan 2014 17:25:35 +0000 (09:25 -0800)]
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

12 years agoAllow `PhutilUnitTestEngine::getTestsForPaths` to return paths from the library root...
Joshua Spence [Thu, 9 Jan 2014 13:21:55 +0000 (05:21 -0800)]
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

12 years agoAllow `ArcanistLinterTestCase` to find "lint-test" files at an arbitrary depth
Joshua Spence [Thu, 9 Jan 2014 00:23:58 +0000 (16:23 -0800)]
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

12 years agoAllow tests to be executed in the root library directory
Joshua Spence [Thu, 2 Jan 2014 14:24:15 +0000 (01:24 +1100)]
Allow tests to be executed in the root library directory

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

Reviewed by: epriestley

12 years agoIn Subversion, treat missing files similarly to conflicted files
epriestley [Fri, 3 Jan 2014 20:23:34 +0000 (12:23 -0800)]
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

12 years agoRecognize `ZipArchive` as an extension class
epriestley [Fri, 3 Jan 2014 01:08:48 +0000 (17:08 -0800)]
Recognize `ZipArchive` as an extension class

Summary: See D7879 for an example. This is an extension class.

Test Plan: You do it bwahaha

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D7880

12 years agoShow current config and source using arc set-config --show
iodragon [Thu, 2 Jan 2014 20:07:03 +0000 (12:07 -0800)]
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

12 years agoPrint a more useful error message if any PHPUnit tests crash
Eric Stern [Thu, 2 Jan 2014 20:02:22 +0000 (12:02 -0800)]
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

12 years agoImprove `arc lint --output summary`
epriestley [Wed, 18 Dec 2013 22:21:03 +0000 (14:21 -0800)]
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

12 years agoParse the output of `svnlook diff ...`
epriestley [Wed, 18 Dec 2013 22:20:59 +0000 (14:20 -0800)]
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

12 years agoMake sure the local arc config directory exists on `ArcanistWorkingCopyIdentity:...
Joshua Spence [Tue, 10 Dec 2013 21:29:19 +0000 (08:29 +1100)]
Make sure the local arc config directory exists on `ArcanistWorkingCopyIdentity::writeLocalArcConfig`

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

Reviewed by: epriestley

12 years agoMake sure no one ever misunderstand the "unkonwn symbol" lint message ever again
epriestley [Tue, 10 Dec 2013 16:33:35 +0000 (08:33 -0800)]
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

12 years agoFix working copy binding powers in weird edge cases
epriestley [Tue, 3 Dec 2013 18:32:31 +0000 (10:32 -0800)]
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

13 years agoUpdate C# tools unit test engine to work
James Rhodes [Tue, 26 Nov 2013 07:00:44 +0000 (18:00 +1100)]
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

13 years agoAdd output-json option to arc feature
Chris Dentel [Mon, 25 Nov 2013 19:50:11 +0000 (11:50 -0800)]
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

13 years agoRemove debugging output from xUnit.NET test engine
James Rhodes [Sun, 24 Nov 2013 00:36:45 +0000 (11:36 +1100)]
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

13 years agoFix issues in C# unit test engine
James Rhodes [Fri, 22 Nov 2013 22:32:48 +0000 (14:32 -0800)]
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

13 years agoArcanistGitAPI: replace 'ls-files -m' with diff-files
Ramkumar Ramachandra [Fri, 22 Nov 2013 16:17:15 +0000 (21:47 +0530)]
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

13 years agoArcanistGitAPI: document a git ls-files bug
Ramkumar Ramachandra [Fri, 22 Nov 2013 13:11:59 +0000 (18:41 +0530)]
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

13 years agoArcanistGitAPI: remove a bogus comment
Ramkumar Ramachandra [Fri, 22 Nov 2013 13:14:50 +0000 (18:44 +0530)]
ArcanistGitAPI: remove a bogus comment

See: <https://github.com/facebook/arcanist/commit/628de7d7a15cd7b5737515ec2831b3b4c3f601a5#commitcomment-4675543>

This comment is indecipherable even if it originally meant something.

Reviewed by: epriestley

13 years agoImprove exception raised when an event listener fails to load
epriestley [Wed, 20 Nov 2013 20:46:38 +0000 (12:46 -0800)]
Improve exception raised when an event listener fails to load

Summary: See IRC. The failing class might not be the listener itself.

Test Plan:
  $ arc list
  ERROR: Failed to load event listener 'depr': Failed to load class or interface 'depr': the class or interface 'depr' is not defined in the library map for any loaded phutil library. If this symbol was recently added or moved, your library map may be out of date. You can rebuild the map by running 'arc liberate'. For more information, see: http://www.phabricator.com/docs/phabricator/article/libphutil_Libraries_User_Guide.html

Reviewers: btrahan

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D7616

13 years agoSet limit for execution in C# linter
James Rhodes [Tue, 19 Nov 2013 21:36:27 +0000 (13:36 -0800)]
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

13 years agoUpgrade C# linter to support linting multiple files at a time
James Rhodes [Mon, 18 Nov 2013 19:32:58 +0000 (11:32 -0800)]
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

13 years agoMake ScriptAndRegexLinter available to ConfigurationDrivenLintEngine
Burak Yigit Kaya [Fri, 15 Nov 2013 20:31:35 +0000 (22:31 +0200)]
Make ScriptAndRegexLinter available to ConfigurationDrivenLintEngine

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

Reviewed by: epriestley

13 years agoFix markup in documentation for arcanist lint engine
Anirudh Sanjeev [Thu, 14 Nov 2013 18:19:08 +0000 (10:19 -0800)]
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

13 years agoHandle empty output from `hg --debug branches` in the parser
epriestley [Mon, 4 Nov 2013 20:15:12 +0000 (12:15 -0800)]
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

13 years agoFilter out messages from included files
Sven Axelsson [Wed, 30 Oct 2013 20:46:30 +0000 (13:46 -0700)]
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

13 years agoSpecify custom arcrc filename
Aviv Eyal [Fri, 25 Oct 2013 22:57:38 +0000 (15:57 -0700)]
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

13 years agorename getConfig -> getProjectConfig, make all linters use getConfigFromAnySource
Aviv Eyal [Tue, 22 Oct 2013 22:34:06 +0000 (15:34 -0700)]
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

13 years agoget Config Manager to Unit engine and use getConfigFromAnySource
Aviv Eyal [Tue, 22 Oct 2013 20:58:32 +0000 (13:58 -0700)]
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

13 years agoProvide ConfigurationManager to LintEngine in Arcanist
epriestley [Mon, 21 Oct 2013 23:57:22 +0000 (16:57 -0700)]
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

13 years agoAutocomplete branch names in `arc feature`
epriestley [Mon, 21 Oct 2013 23:29:08 +0000 (16:29 -0700)]
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

13 years agoFixed typos
Pascal Borreli [Sun, 20 Oct 2013 14:41:48 +0000 (14:41 +0000)]
Fixed typos

See: https://github.com/facebook/arcanist/pull/110

Reviewed by: epriestley

13 years agoMinor, fix a missing config source change.
epriestley [Sat, 19 Oct 2013 20:32:59 +0000 (13:32 -0700)]
Minor, fix a missing config source change.

13 years agoCouple of fixes from refactor
Aviv Eyal [Fri, 18 Oct 2013 23:41:50 +0000 (16:41 -0700)]
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

13 years agoMinor, fix a typo.
epriestley [Fri, 18 Oct 2013 23:19:22 +0000 (16:19 -0700)]
Minor, fix a typo.

13 years agoExtract configuration read/write methods out of BaseWorlkflow
Aviv Eyal [Fri, 18 Oct 2013 23:10:06 +0000 (16:10 -0700)]
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

13 years agoArcanist - make Patch workflow automagically apply dependencies
Bob Trahan [Thu, 17 Oct 2013 21:59:04 +0000 (14:59 -0700)]
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

13 years agoWrite ARCANIST into the environment while running arc
epriestley [Thu, 10 Oct 2013 13:18:37 +0000 (06:18 -0700)]
Write ARCANIST into the environment while running arc

Summary:
Addresses a request to let Git commit hooks react differently when run via `arc`. While executing an `arc` command, write ARCANIST into the environment.

(I wrote the actual command as the value since it seemed like it could plausibly be more useful than `true` or `1`.)

Test Plan: Added `pre-commit` to `.git/hooks` which did `echo $ARCANIST`, verified the envvar was accessible when running via arc.

Reviewers: btrahan, frgtn

Reviewed By: frgtn

CC: aran
Differential Revision: https://secure.phabricator.com/D7281

13 years agoRemove spurious +x from arcanist
epriestley [Sat, 5 Oct 2013 12:20:05 +0000 (05:20 -0700)]
Remove spurious +x from arcanist

Summary: A few files here have +x, but should not. Also correct a
spelling mistake.

13 years agoKeep Arcanist from mistaking paths that look like svn:externals as svn:externals
root [Sat, 5 Oct 2013 00:31:18 +0000 (17:31 -0700)]
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

13 years agoget jshint error codes
Tal Shiri [Fri, 4 Oct 2013 13:29:47 +0000 (06:29 -0700)]
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

13 years agoStrip comments from all diffs before parsing them
epriestley [Thu, 3 Oct 2013 22:06:35 +0000 (15:06 -0700)]
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

13 years agoadded getLinterConfigurationName() to ArcanistJSHintLinter.
Tal Shiri [Thu, 3 Oct 2013 02:02:40 +0000 (19:02 -0700)]
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

13 years agoAdd C# linter for Arcanist.
James Rhodes [Tue, 1 Oct 2013 18:37:26 +0000 (11:37 -0700)]
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

13 years agoFix coverage for NoseTestEngine
Aviv Eyal [Mon, 30 Sep 2013 17:44:38 +0000 (10:44 -0700)]
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

13 years agoExtract xUnit test results parser
Aviv Eyal [Mon, 30 Sep 2013 17:43:08 +0000 (10:43 -0700)]
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

13 years agoFix a stiring issue in the External linter
epriestley [Sun, 29 Sep 2013 14:44:33 +0000 (07:44 -0700)]
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

13 years agoSet the CWD before applying a git patch
Gareth Evans [Sat, 28 Sep 2013 13:53:15 +0000 (06:53 -0700)]
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

13 years agoAdding arc lint flag that will show lint only on changed lines - even when paths...
Chris Dentel [Fri, 20 Sep 2013 23:08:59 +0000 (16:08 -0700)]
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

13 years agoAdd `https.blindly-trust-domains` to Arcanist
epriestley [Wed, 25 Sep 2013 22:26:38 +0000 (15:26 -0700)]
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

13 years agoFix an issue where method prototypes have different signatures
epriestley [Mon, 23 Sep 2013 15:34:28 +0000 (08:34 -0700)]
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

13 years agoAdd C# tools and xUnit unit test engines.
James Rhodes [Mon, 23 Sep 2013 12:32:34 +0000 (05:32 -0700)]
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

13 years agoPrevent detailed code coverage from accessing missing report.
James Rhodes [Fri, 20 Sep 2013 16:18:02 +0000 (09:18 -0700)]
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

13 years agoPerform case-insensitive check for PHPUnit test finder to not return original file
Eric Stern [Thu, 19 Sep 2013 22:14:44 +0000 (15:14 -0700)]
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

13 years agoPluralize add files questions
Jakub Vrana [Sat, 14 Sep 2013 15:06:50 +0000 (08:06 -0700)]
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

13 years agoCorrect capitalization of "new" in lint
epriestley [Thu, 12 Sep 2013 20:01:25 +0000 (13:01 -0700)]
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

13 years agoIgnore errors from "svn upgrade" in unit tests
epriestley [Thu, 12 Sep 2013 04:23:30 +0000 (21:23 -0700)]
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

13 years agoparse ls-tree with git-submodule correctly
Aviv Eyal [Wed, 11 Sep 2013 17:36:23 +0000 (10:36 -0700)]
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

13 years agoFix an issue with PHPCS output formatting
epriestley [Tue, 10 Sep 2013 22:10:34 +0000 (15:10 -0700)]
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

13 years ago[lint][spelling] delimeter -> delimiter
katherine [Mon, 9 Sep 2013 19:16:22 +0000 (12:16 -0700)]
[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

13 years agoMerge pull request #90 from dcramer/pytest
Evan Priestley [Fri, 6 Sep 2013 18:49:56 +0000 (11:49 -0700)]
Merge pull request #90 from dcramer/pytest

Add PytestTestEngine

13 years agoList all DOM extension classes as extension classes for static analysis purposes
epriestley [Fri, 6 Sep 2013 00:28:19 +0000 (17:28 -0700)]
List all DOM extension classes as extension classes for static analysis purposes

Summary: See D6895. We currenty whitelist one of the DOM classes, but should whitelist them all. Classes not in this whitelist raise warnings when users who don't have the corresponding extensions installed lint code. We don't want to require you to install every extension just to send diffs, so we whitelist stuff that we know would exist if you did install everything.

Test Plan: bwahaha

Reviewers: btrahan, Firehed

Reviewed By: Firehed

CC: aran
Differential Revision: https://secure.phabricator.com/D6896

13 years agoFix arc + svn + delted binary file with properties + image heuristic
epriestley [Thu, 5 Sep 2013 22:05:26 +0000 (15:05 -0700)]
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