From: epriestley Date: Fri, 29 Apr 2016 12:59:24 +0000 (-0700) Subject: When running XHPAST unit tests, include the "syntax error" lint rule X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=768e1a56bc5f73c0e15610c74b7d0c023beee4e0;p=arcanist.git When running XHPAST unit tests, include the "syntax error" lint rule Summary: See rARC3ffed59bd7. Currently, when a unit test includes a syntax error, it is raised in an unclear way ("error at line 10, char 1: XHP1 Unknown lint message!"). This is because each test case only activates rules it wants to test, so we lose the ID/name for the syntax message. However, we always want to test this and the lint engine can always raise it. To get a better error message, include it unconditionally. So a test for rule `X` really tests two rules: syntax, and `X`. Test Plan: Ran `arc unit` at HEAD, got a better test failure: ``` FAIL ArcanistCallTimePassByReferenceXHPASTLinterRuleTestCase::testLinter In 'call-time-pass-by-reference.lint-test', expected lint to raise error on line 10 at char 8, but no error was raised. Actually raised: error at line 10, char 1: XHP1 PHP Syntax Error! ``` NOTE: This doesn't pass tests yet, it just makes the test failure easier to understand. I'll see about fixing the test in the next change. Reviewers: chad, richardvanvelzen Reviewed By: richardvanvelzen Differential Revision: https://secure.phabricator.com/D15819 --- diff --git a/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php b/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php index 342d059b..faf349bf 100644 --- a/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php +++ b/src/lint/linter/xhpast/rules/__tests__/ArcanistXHPASTLinterRuleTestCase.php @@ -8,8 +8,19 @@ abstract class ArcanistXHPASTLinterRuleTestCase extends ArcanistLinterTestCase { final protected function getLinter() { + // Always include this rule so we get good messages if a test includes + // a syntax error. No normal test should contain syntax errors. + $syntax_rule = new ArcanistSyntaxErrorXHPASTLinterRule(); + + $test_rule = $this->getLinterRule(); + + $rules = array( + $syntax_rule, + $test_rule, + ); + return id(new ArcanistXHPASTLinter()) - ->setRules(array($this->getLinterRule())); + ->setRules($rules); } /**