mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Fail Arcanist tests when they make zero assertions
Summary: Fixes T4570. When a test case doesn't make any assertions, fail it: - A tiny fraction of tests pass by not throwing. These tests can easily make a trivial assertion. It took about 5 minutes to fix them all (D8435, D8436). - In other cases, no assertions means a test construction problem, as with T4570. In these cases, failing loudly catches a severe error. - Fixes the no-assertion test cases in `arcanist/` - Makes the PHP 5.4 test pass for the moment, see discussion in T4334. Test Plan: Ran `arc unit --everything`. Reviewers: leebyron, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4570 Differential Revision: https://secure.phabricator.com/D8437
This commit is contained in:
parent
22f6207920
commit
c6b1f3f070
3 changed files with 16 additions and 1 deletions
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
f()[0];
|
||||
$o->m()[0];
|
||||
m()[0];
|
||||
|
||||
// The check above should be this, see T4334.
|
||||
// $o->m()[0];
|
||||
|
||||
~~~~~~~~~~
|
||||
disabled:3:5
|
||||
|
|
|
@ -37,6 +37,8 @@ final class XUnitTestResultParserTestCase extends ArcanistTestCase {
|
|||
} catch (Exception $e) {
|
||||
// OK
|
||||
}
|
||||
|
||||
$this->assertEqual(true, true);
|
||||
}
|
||||
|
||||
public function testInvalidXmlInputFailure() {
|
||||
|
@ -50,6 +52,8 @@ final class XUnitTestResultParserTestCase extends ArcanistTestCase {
|
|||
} catch (Exception $e) {
|
||||
// OK
|
||||
}
|
||||
|
||||
$this->assertEqual(true, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -464,6 +464,14 @@ abstract class ArcanistPhutilTestCase {
|
|||
$exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->assertions) {
|
||||
$this->failTest(
|
||||
pht(
|
||||
'This test case made no assertions. Test cases must make at '.
|
||||
'least one assertion.'));
|
||||
}
|
||||
|
||||
} catch (ArcanistPhutilTestTerminatedException $ex) {
|
||||
// Continue with the next test.
|
||||
} catch (ArcanistPhutilTestSkippedException $ex) {
|
||||
|
|
Loading…
Reference in a new issue