From 08b53c3803061eb35d1aefa18c3f083fbe2b8d51 Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 8 Jun 2012 14:22:23 -0700 Subject: [PATCH] Pass for phutil test that was expected to fail and skip 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 | 2 ++ .../PhutilUnitTestEngineTestCase.php | 23 +++++++++---- .../engine/phutil/ArcanistPhutilTestCase.php | 2 +- .../ArcanistPhutilTestCaseTestCase.php | 34 +++++++++++++++++++ 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 src/unit/engine/phutil/testcase/ArcanistPhutilTestCaseTestCase.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ad8d6b6a..2f3825ee 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php b/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php index d7efb573..79654020 100644 --- a/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php +++ b/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php @@ -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() { diff --git a/src/unit/engine/phutil/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/ArcanistPhutilTestCase.php index 9d46e457..cea863d0 100644 --- a/src/unit/engine/phutil/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/ArcanistPhutilTestCase.php @@ -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 index 00000000..70a32b8a --- /dev/null +++ b/src/unit/engine/phutil/testcase/ArcanistPhutilTestCaseTestCase.php @@ -0,0 +1,34 @@ +assertFailure('This test is expected to fail.'); + } + + public function testSkip() { + $this->assertSkipped('This test is expected to skip.'); + } + +}