]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Pass for phutil test that was expected to fail and skip
authorvrana <jakubv@fb.com>
Fri, 8 Jun 2012 21:22:23 +0000 (14:22 -0700)
committervrana <jakubv@fb.com>
Fri, 8 Jun 2012 21:29:51 +0000 (14:29 -0700)
Summary:
I just hope that we will not create `ArcanistPhutilTestCaseTestCaseTestCase`.

Also fix a copy/paste error (@edward's this time).

Test Plan: `arc unit`

Reviewers: epriestley

Reviewed By: epriestley

CC: edward, aran, Korvin
Differential Revision: https://secure.phabricator.com/D2692

src/__phutil_library_map__.php
src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php
src/unit/engine/phutil/ArcanistPhutilTestCase.php
src/unit/engine/phutil/testcase/ArcanistPhutilTestCaseTestCase.php [new file with mode: 0644]

index ad8d6b6a7bdda3ea06dce352288746a0c8a1aa23..2f3825eee950a726ccb3b0e26fdb19e12fffb539 100644 (file)
@@ -92,6 +92,7 @@ phutil_register_library_map(array(
     'ArcanistPhutilLibraryLinter' => 'lint/linter/ArcanistPhutilLibraryLinter.php',
     'ArcanistPhutilModuleLinter' => 'lint/linter/ArcanistPhutilModuleLinter.php',
     'ArcanistPhutilTestCase' => 'unit/engine/phutil/ArcanistPhutilTestCase.php',
+    'ArcanistPhutilTestCaseTestCase' => 'unit/engine/phutil/testcase/ArcanistPhutilTestCaseTestCase.php',
     'ArcanistPhutilTestSkippedException' => 'unit/engine/phutil/testcase/ArcanistPhutilTestSkippedException.php',
     'ArcanistPhutilTestTerminatedException' => 'unit/engine/phutil/testcase/ArcanistPhutilTestTerminatedException.php',
     'ArcanistPyFlakesLinter' => 'lint/linter/ArcanistPyFlakesLinter.php',
@@ -196,6 +197,7 @@ phutil_register_library_map(array(
     'ArcanistPhpcsLinter' => 'ArcanistLinter',
     'ArcanistPhutilLibraryLinter' => 'ArcanistLinter',
     'ArcanistPhutilModuleLinter' => 'ArcanistLinter',
+    'ArcanistPhutilTestCaseTestCase' => 'ArcanistPhutilTestCase',
     'ArcanistPhutilTestSkippedException' => 'Exception',
     'ArcanistPhutilTestTerminatedException' => 'Exception',
     'ArcanistPyFlakesLinter' => 'ArcanistLinter',
index d7efb573a086b9da94f8adb1e6c38433c1064ef2..796540207cb171ee40f977e32c71dd366dae5830 100644 (file)
@@ -40,7 +40,7 @@ final class PhutilUnitTestEngineTestCase extends ArcanistPhutilTestCase {
 
     self::$allTestsCounter--;
 
-    $actual_test_count = 5;
+    $actual_test_count = 4;
 
     $this->assertEqual(
       $actual_test_count,
@@ -82,12 +82,21 @@ final class PhutilUnitTestEngineTestCase extends ArcanistPhutilTestCase {
     $this->assertEqual(1, 1, 'This test is expected to pass.');
   }
 
-  public function testFail() {
-    $this->assertFailure('This test is expected to fail.');
-  }
-
-  public function testSkip() {
-    $this->assertSkipped('This test is expected to skip.');
+  public function testFailSkip() {
+    $failed = 0;
+    $skipped = 0;
+    $test_case = new ArcanistPhutilTestCaseTestCase();
+    foreach ($test_case->run() as $result) {
+      if ($result->getResult() == ArcanistUnitTestResult::RESULT_FAIL) {
+        $failed++;
+      } else if ($result->getResult() == ArcanistUnitTestResult::RESULT_SKIP) {
+        $skipped++;
+      } else {
+        $this->assertFailure('These tests should either fail or skip.');
+      }
+    }
+    $this->assertEqual(1, $failed, 'One test was expected to fail.');
+    $this->assertEqual(1, $skipped, 'One test was expected to skip.');
   }
 
   public function testTryTestCases() {
index 9d46e457b2b7d3fd54b35003541a91e88b8b9b6f..cea863d01392327425f0da27b5f7af5e8daa5b62 100644 (file)
@@ -119,7 +119,7 @@ abstract class ArcanistPhutilTestCase {
    */
   final protected function assertSkipped($message) {
     $this->skipTest($message);
-    throw new ArcanistPhutilTestTerminatedException($message);
+    throw new ArcanistPhutilTestSkippedException($message);
   }
 
 
diff --git a/src/unit/engine/phutil/testcase/ArcanistPhutilTestCaseTestCase.php b/src/unit/engine/phutil/testcase/ArcanistPhutilTestCaseTestCase.php
new file mode 100644 (file)
index 0000000..70a32b8
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * Copyright 2012 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test for @{class:PhutilUnitTestEngineTestCase}.
+ *
+ * @group testcase
+ */
+final class ArcanistPhutilTestCaseTestCase extends ArcanistPhutilTestCase {
+
+  public function testFail() {
+    $this->assertFailure('This test is expected to fail.');
+  }
+
+  public function testSkip() {
+    $this->assertSkipped('This test is expected to skip.');
+  }
+
+}