From: epriestley Date: Wed, 30 Jan 2013 19:24:41 +0000 (-0800) Subject: Restore directory after executing ArcanistBundleTestCase X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=51f32bdde710f9452aeddaced4d419c14b61bd9c;p=arcanist.git Restore directory after executing ArcanistBundleTestCase Summary: This test currently chdir()'s into a directory which is later removed. If another test tries to run a shell script while the CWD is invalid, the shell may emit this to stderr: shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory Among other things, this can cause the XHPAST test to fail, because it detects syntax errors by examining stderr. Instead, retore the directory. Test Plan: Ran "arc unit --everything", which could previously fail if XHPAST ran after Bundle. Reviewers: btrahan, vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4738 --- diff --git a/src/parser/__tests__/ArcanistBundleTestCase.php b/src/parser/__tests__/ArcanistBundleTestCase.php index 0652e166..db0b01a1 100644 --- a/src/parser/__tests__/ArcanistBundleTestCase.php +++ b/src/parser/__tests__/ArcanistBundleTestCase.php @@ -40,11 +40,28 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { } $archive = dirname(__FILE__).'/bundle.git.tgz'; - $patches = dirname(__FILE__).'/patches/'; $fixture = PhutilDirectoryFixture::newFromArchive($archive); + $old_dir = getcwd(); chdir($fixture->getPath()); + $caught = null; + try { + $this->runGitRepositoryTests($fixture); + } catch (Exception $ex) { + $caught = $ex; + } + + chdir($old_dir); + + if ($caught) { + throw $ex; + } + } + + private function runGitRepositoryTests(PhutilDirectoryFixture $fixture) { + $patches = dirname(__FILE__).'/patches/'; + list($commits) = execx( 'git log --format=%s', '%H %T %s');