From 2354d544e35e002bd1a5eaee33ae9d42baa3608e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 16 Feb 2011 11:53:34 -0800 Subject: [PATCH] Restore hook configuration in lint unit tests. Make working copy setup an external. Summary: Test Plan: Reviewers: CC: --- .../__tests__/ArcanistApacheLicenseLinterTestCase.php | 6 +++++- src/lint/linter/base/test/ArcanistLinterTestCase.php | 11 ++++------- .../xhpast/__tests__/ArcanistXHPASTLinterTestCase.php | 6 +++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/lint/linter/apachelicense/__tests__/ArcanistApacheLicenseLinterTestCase.php b/src/lint/linter/apachelicense/__tests__/ArcanistApacheLicenseLinterTestCase.php index b06c3ec1..96643aea 100644 --- a/src/lint/linter/apachelicense/__tests__/ArcanistApacheLicenseLinterTestCase.php +++ b/src/lint/linter/apachelicense/__tests__/ArcanistApacheLicenseLinterTestCase.php @@ -20,7 +20,11 @@ class ArcanistApacheLicenseLinterTestCase extends ArcanistLinterTestCase { public function testApacheLicenseLint() { $linter = new ArcanistApacheLicenseLinter(); - return $this->executeTestsInDirectory(dirname(__FILE__).'/data/', $linter); + $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__); + return $this->executeTestsInDirectory( + dirname(__FILE__).'/data/', + $linter, + $working_copy); } } diff --git a/src/lint/linter/base/test/ArcanistLinterTestCase.php b/src/lint/linter/base/test/ArcanistLinterTestCase.php index 10d6a291..8b02bdf1 100644 --- a/src/lint/linter/base/test/ArcanistLinterTestCase.php +++ b/src/lint/linter/base/test/ArcanistLinterTestCase.php @@ -18,17 +18,15 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase { - public function executeTestsInDirectory($root, $linter) { + public function executeTestsInDirectory($root, $linter, $working_copy) { foreach (Filesystem::listDirectory($root, $hidden = false) as $file) { - $this->lintFile($root.$file, $linter); + $this->lintFile($root.$file, $linter, $working_copy); } } - private function lintFile($file, $linter) { + private function lintFile($file, $linter, $working_copy) { $linter = clone $linter; - $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__); - $contents = Filesystem::readFile($file); $contents = explode("~~~~~~~~~~\n", $contents); if (count($contents) < 2) { @@ -77,8 +75,7 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase { $engine->setWorkingCopy($working_copy); $engine->setPaths(array($path)); -// TODO: restore this -// $engine->setCommitHookMode(idx($config, 'hook', false)); + $engine->setCommitHookMode(idx($config, 'hook', false)); $linter->addPath($path); $linter->addData($path, $data); diff --git a/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLinterTestCase.php b/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLinterTestCase.php index e04eec3b..ccc71831 100644 --- a/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLinterTestCase.php +++ b/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLinterTestCase.php @@ -20,7 +20,11 @@ class ArcanistXHPASTLinterTestCase extends ArcanistLinterTestCase { public function testXHPASTLint() { $linter = new ArcanistXHPASTLinter(); - return $this->executeTestsInDirectory(dirname(__FILE__).'/data/', $linter); + $working_copy = ArcanistWorkingCopyIdentity::newFromPath(__FILE__); + return $this->executeTestsInDirectory( + dirname(__FILE__).'/data/', + $linter, + $working_copy); } } -- 2.43.0