]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Restore directory after executing ArcanistBundleTestCase
authorepriestley <git@epriestley.com>
Wed, 30 Jan 2013 19:24:41 +0000 (11:24 -0800)
committerepriestley <git@epriestley.com>
Wed, 30 Jan 2013 19:24:41 +0000 (11:24 -0800)
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

src/parser/__tests__/ArcanistBundleTestCase.php

index 0652e166a4d0b297bb8109197dce1ba8393b13d2..db0b01a1d05be6d56a158a657d8813fa659e30eb 100644 (file)
@@ -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');