• Joshua Spence's avatar
    Test XHPAST linter rules in isolation · 4d512c51
    Joshua Spence authored
    Separate XHPAST linter rules in isolation from other rules and formalize the concept of a "linter rule". As the number of XHPAST linter rules grows (we currently have around 80), it becomes increasingly difficult to manage all of the test cases because `ArcanistXHPASTLinterTestCase` currently tests the entire linter (i.e. //all// linter rules) rather than testing individual rules in isolation. See D13534 for a situation in which this is painful. This is particularly bad for third party development because unit tests could break at any time depending on upstream changes.
    Basically, in order to facilitate the unit testing of XHPAST linter rules in isolation, I have made the following  changes:
      # Added a `setRules()` method to `ArcanistXHPASTLinter`. Currently, `ArcanistXHPASTLinter` loads all `ArcanistXHPASTLinterRule` subclasses unconditionally. The `setRules()` method provides a way to override the configured linter rules.
      # Formalize the concept of a "linter rule". The `ArcanistXHPASTLinterRule` class was introduced in D10541. I feel that the modularization of `ArcanistXHPASTLinter` has made the linter much more maintainable and easily testable and I intend to extend this concept to other linters, such as `ArcanistTextLinter`.
    Test Plan: Ran unit tests.
    Reviewers: #blessed_reviewers, epriestley
    Reviewed By: #blessed_reviewers, epriestley
    Subscribers: Korvin
    Differential Revision: https://secure.phabricator.com/D14010