'PhutilLintEngine' => 'lint/engine/phutil',
'PhutilModuleRequirements' => 'staticanalysis/parsers/phutilmodule',
'PhutilUnitTestEngine' => 'unit/engine/phutil',
+ 'PhutilUnitTestEngineTestCase' => 'unit/engine/phutil/__tests__',
'UnitTestableArcanistLintEngine' => 'lint/engine/test',
),
'function' =>
'ArcanistXHPASTLinterTestCase' => 'ArcanistPhutilTestCase',
'PhutilLintEngine' => 'ArcanistLintEngine',
'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
+ 'PhutilUnitTestEngineTestCase' => 'ArcanistPhutilTestCase',
'UnitTestableArcanistLintEngine' => 'ArcanistLintEngine',
),
'requires_interface' =>
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 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.
+ */
+
+class PhutilUnitTestEngineTestCase extends ArcanistPhutilTestCase {
+
+ public function testPass() {
+ $this->assertEqual(1, 1, 'This test is expected to pass.');
+ }
+
+ public function testFail() {
+ $this->assertEqual(1, 2, 'This test is expected to fail.');
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * This file is automatically generated. Lint this module to rebuild it.
+ * @generated
+ */
+
+
+
+phutil_require_module('arcanist', 'unit/engine/phutil/testcase');
+
+
+phutil_require_source('PhutilUnitTestEngineTestCase.php');
if ($lint_result === ArcanistLintWorkflow::RESULT_OKAY) {
$lint = 'okay';
- } else if ($lint_result === ArcanistLintWorkflow::RESULT_WARNINGS) {
+ } else if ($lint_result === ArcanistLintWorkflow::RESULT_ERRORS) {
$lint = 'fail';
+ } else if ($lint_result === ArcanistLintWorkflow::RESULT_WARNINGS) {
+ $lint = 'warn';
} else if ($lint_result === ArcanistLintWorkflow::RESULT_SKIP) {
$lint = 'skip';
} else {
if ($unit_result === ArcanistUnitWorkflow::RESULT_OKAY) {
$unit = 'okay';
- } else if ($unit_result === ArcanistUnitWorkflow::RESULT_UNSOUND ||
- $unit_result === ArcanistUnitWorkflow::RESULT_FAIL) {
+ } else if ($unit_result === ArcanistUnitWorkflow::RESULT_FAIL) {
$unit = 'fail';
+ } else if ($unit_result === ArcanistUnitWorkflow::RESULT_UNSOUND) {
+ $unit = 'warn';
} else if ($unit_result === ArcanistUnitWorkflow::RESULT_SKIP) {
$unit = 'skip';
} else {
));
}
+ if ($this->unresolvedTests) {
+ $data = array();
+ foreach ($this->unresolvedTests as $test) {
+ $data[] = array(
+ 'name' => $test->getName(),
+ 'result' => $test->getResult(),
+ 'userdata' => $test->getUserData(),
+ );
+ }
+ $conduit->callMethodSynchronous(
+ 'differential.setdiffproperty',
+ array(
+ 'diff_id' => $diff_info['diffid'],
+ 'name' => 'arc:unit',
+ 'data' => json_encode($data),
+ ));
+ }
+
if ($this->shouldOnlyCreateDiff()) {
echo phutil_console_format(
"Created a new Differential diff:\n".
if (!$continue) {
throw new ArcanistUserAbortException();
}
- $this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
break;
case ArcanistLintWorkflow::RESULT_ERRORS:
echo phutil_console_format(
"<bg:red>** LINT ERRORS **</bg> Lint raised errors!\n");
- throw new ArcanistUsageException(
- "Resolve lint errors or run with --nolint.");
+ $continue = phutil_console_confirm(
+ "Lint issued unresolved errors! Ignore lint errors?");
+ if (!$continue) {
+ throw new ArcanistUserAbortException();
+ }
break;
}
+ $this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
+
return $lint_result;
} catch (ArcanistNoEngineException $ex) {
echo "No lint engine configured for this project.\n";
case ArcanistUnitWorkflow::RESULT_FAIL:
echo phutil_console_format(
"<bg:red>** UNIT ERRORS **</bg> Unit testing raised errors!\n");
- throw new ArcanistUsageException(
- "Resolve unit test errors or run with --nounit.");
+ $continue = phutil_console_confirm(
+ "Unit test results include failures! Ignore test failures?");
+ if (!$continue) {
+ throw new ArcanistUserAbortException();
+ }
break;
}
+ $this->unresolvedTests = $unit_workflow->getUnresolvedTests();
+
return $unit_result;
} catch (ArcanistNoEngineException $ex) {
echo "No unit test engine is configured for this project.\n";
const RESULT_FAIL = 2;
const RESULT_SKIP = 3;
+ private $unresolvedTests;
+
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
**unit**
' <bg:yellow>** UNSOUND **</bg>'),
);
+ $unresolved = array();
foreach ($results as $result) {
$result_code = $result->getResult();
echo $status_codes[$result_code].' '.$result->getName()."\n";
if ($result_code != ArcanistUnitTestResult::RESULT_PASS) {
echo $result->getUserData()."\n";
+ $unresolved[] = $result;
}
}
+ $this->unresolvedTests = $unresolved;
$overall_result = self::RESULT_OKAY;
foreach ($results as $result) {
$result_code == ArcanistUnitTestResult::RESULT_BROKEN) {
$overall_result = self::RESULT_FAIL;
break;
- }
- if ($result_code == ArcanistUnitTestResult::RESULT_UNSOUND) {
+ } else if ($result_code == ArcanistUnitTestResult::RESULT_UNSOUND) {
$overall_result = self::RESULT_UNSOUND;
- break;
}
}
return $overall_result;
}
+
+ public function getUnresolvedTests() {
+ return $this->unresolvedTests;
+ }
+
}