From cea1432782d0f8157ae268d99e3bd90cd8af80ec Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 29 Dec 2014 16:15:37 -0800 Subject: [PATCH] Skip Mercurial tests if `hg` is not present Summary: I don't have `hg` yet on my new laptop; we should just skip tests if the user is missing binaries. Add a convenience method to do this. Test Plan: Got clean `arc unit --everything` with no `hg` installed. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11051 --- .../__tests__/PhabricatorWorkingCopyDiscoveryTestCase.php | 2 ++ .../__tests__/PhabricatorWorkingCopyPullTestCase.php | 1 + .../worker/__tests__/PhabricatorChangeParserTestCase.php | 2 ++ src/infrastructure/testing/PhabricatorTestCase.php | 7 +++++++ 4 files changed, 12 insertions(+) diff --git a/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyDiscoveryTestCase.php b/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyDiscoveryTestCase.php index b46fb4188b..1e9c83da26 100644 --- a/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyDiscoveryTestCase.php +++ b/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyDiscoveryTestCase.php @@ -15,6 +15,8 @@ final class PhabricatorWorkingCopyDiscoveryTestCase } public function testMercurialCommitDiscovery() { + $this->requireBinaryForTest('hg'); + $refs = $this->discoverRefs('HT'); $this->assertEqual( array( diff --git a/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php b/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php index 58a6590871..83568f3496 100644 --- a/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php +++ b/src/applications/repository/engine/__tests__/PhabricatorWorkingCopyPullTestCase.php @@ -10,6 +10,7 @@ final class PhabricatorWorkingCopyPullTestCase } public function testHgPullBasic() { + $this->requireBinaryForTest('hg'); $repo = $this->buildPulledRepository('HT'); $this->assertTrue(Filesystem::pathExists($repo->getLocalPath().'/.hg')); diff --git a/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php b/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php index bcb21a6de8..7efc3a4a18 100644 --- a/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php +++ b/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php @@ -203,6 +203,8 @@ final class PhabricatorChangeParserTestCase } public function testMercurialParser() { + $this->requireBinaryForTest('hg'); + $repository = $this->buildDiscoveredRepository('CHB'); $viewer = PhabricatorUser::getOmnipotentUser(); diff --git a/src/infrastructure/testing/PhabricatorTestCase.php b/src/infrastructure/testing/PhabricatorTestCase.php index effec47d86..53950ddf73 100644 --- a/src/infrastructure/testing/PhabricatorTestCase.php +++ b/src/infrastructure/testing/PhabricatorTestCase.php @@ -218,5 +218,12 @@ abstract class PhabricatorTestCase extends ArcanistPhutilTestCase { } } + protected function requireBinaryForTest($binary) { + if (!Filesystem::binaryExists($binary)) { + $this->assertSkipped( + pht('No binary "%s" found on this system, skipping test.', $binary)); + } + } + }