Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15399057
D13855.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13855.diff
View Options
diff --git a/.arcconfig b/.arcconfig
--- a/.arcconfig
+++ b/.arcconfig
@@ -1,6 +1,5 @@
{
"phabricator.uri": "https://secure.phabricator.com/",
- "unit.engine": "ArcanistConfigurationDrivenUnitTestEngine",
"load": [
"src/"
]
diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php
--- a/src/workflow/ArcanistUnitWorkflow.php
+++ b/src/workflow/ArcanistUnitWorkflow.php
@@ -113,21 +113,8 @@
}
public function run() {
-
$working_copy = $this->getWorkingCopy();
- $engine_class = $this->getArgument(
- 'engine',
- $this->getConfigurationManager()->getConfigFromAnySource('unit.engine'));
-
- if (!$engine_class) {
- throw new ArcanistNoEngineException(
- pht(
- 'No unit test engine is configured for this project. Edit %s '.
- 'to specify a unit test engine.',
- '.arcconfig'));
- }
-
$paths = $this->getArgument('paths');
$rev = $this->getArgument('rev');
$everything = $this->getArgument('everything');
@@ -145,18 +132,7 @@
$paths = $this->selectPathsForWorkflow($paths, $rev);
}
- if (!class_exists($engine_class) ||
- !is_subclass_of($engine_class, 'ArcanistUnitTestEngine')) {
- throw new ArcanistUsageException(
- pht(
- "Configured unit test engine '%s' is not a subclass of '%s'.",
- $engine_class,
- 'ArcanistUnitTestEngine'));
- }
-
- $this->engine = newv($engine_class, array());
- $this->engine->setWorkingCopy($working_copy);
- $this->engine->setConfigurationManager($this->getConfigurationManager());
+ $this->engine = $this->newUnitTestEngine($this->getArgument('engine'));
if ($everything) {
$this->engine->setRunAllTests(true);
} else {
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -1878,6 +1878,59 @@
return $engine;
}
+ /**
+ * Build a new unit test engine for the current working copy.
+ *
+ * Optionally, you can pass an explicit engine class name to build an engine
+ * of a particular class. Normally this is used to implement an `--engine`
+ * flag from the CLI.
+ *
+ * @param string Optional explicit engine class name.
+ * @return ArcanistUnitTestEngine Constructed engine.
+ */
+ protected function newUnitTestEngine($engine_class = null) {
+ $working_copy = $this->getWorkingCopy();
+ $config = $this->getConfigurationManager();
+
+ if (!$engine_class) {
+ $engine_class = $config->getConfigFromAnySource('unit.engine');
+ }
+
+ if (!$engine_class) {
+ if (Filesystem::pathExists($working_copy->getProjectPath('.arcunit'))) {
+ $engine_class = 'ArcanistConfigurationDrivenUnitTestEngine';
+ }
+ }
+
+ if (!$engine_class) {
+ throw new ArcanistNoEngineException(
+ pht(
+ "No unit test engine is configured for this project. Create an ".
+ "'%s' file, or configure an advanced engine with '%s' in '%s'.",
+ '.arcunit',
+ 'unit.engine',
+ '.arcconfig'));
+ }
+
+ $base_class = 'ArcanistUnitTestEngine';
+ if (!class_exists($engine_class) ||
+ !is_subclass_of($engine_class, $base_class)) {
+ throw new ArcanistUsageException(
+ pht(
+ 'Configured unit test engine "%s" is not a subclass of "%s", '.
+ 'but must be.',
+ $engine_class,
+ $base_class));
+ }
+
+ $engine = newv($engine_class, array())
+ ->setWorkingCopy($working_copy)
+ ->setConfigurationManager($config);
+
+ return $engine;
+ }
+
+
protected function openURIsInBrowser(array $uris) {
$browser = $this->getBrowserCommand();
foreach ($uris as $uri) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 2:38 AM (4 d, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7386695
Default Alt Text
D13855.diff (3 KB)
Attached To
Mode
D13855: Automatically use the configuration driven unit test engine
Attached
Detach File
Event Timeline
Log In to Comment