]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve detection of invalid unit and lint engines
authorepriestley <git@epriestley.com>
Wed, 21 Dec 2011 16:51:34 +0000 (08:51 -0800)
committerepriestley <git@epriestley.com>
Wed, 21 Dec 2011 17:02:04 +0000 (09:02 -0800)
Summary: We fatal confusingly if you specify a valid class that isn't of the
right subclass (like a linter rather than a lint engine). Improve the error
message.

Test Plan:
  - Ran "arc lint --engine PhutilSymbolLoader", "arc unit --engine
PhutilSymbolLoader", got expected failures.
  - Ran "arc diff" normally without errors.

Reviewers: btrahan, jungejason, aran

Reviewed By: aran

CC: aran
Differential Revision: https://secure.phabricator.com/D1259

src/workflow/lint/ArcanistLintWorkflow.php
src/workflow/unit/ArcanistUnitWorkflow.php
src/workflow/unit/__init__.php

index df923d1b5c11034838cea9a72db45b2da13d00cf..f50a88cfc86fc60542fc02aadaa2f48ecdebc690 100644 (file)
@@ -159,6 +159,11 @@ EOTEXT
     }
 
     PhutilSymbolLoader::loadClass($engine);
+    if (!is_subclass_of($engine, 'ArcanistLintEngine')) {
+      throw new ArcanistUsageException(
+        "Configured lint engine '{$engine}' is not a subclass of ".
+        "'ArcanistLintEngine'.");
+    }
 
     $engine = newv($engine, array());
     $engine->setWorkingCopy($working_copy);
index bf976ec5468c4e4c962be125b3b325091c2cf727..50a402848eb5d00d58498904904db33e951d376c 100644 (file)
@@ -97,8 +97,13 @@ EOTEXT
       $paths = array_keys($paths);
     }
 
-
     PhutilSymbolLoader::loadClass($engine_class);
+    if (!is_subclass_of($engine_class, 'ArcanistBaseUnitTestEngine')) {
+      throw new ArcanistUsageException(
+        "Configured unit test engine '{$engine_class}' is not a subclass of ".
+        "'ArcanistBaseUnitTestEngine'.");
+    }
+
     $this->engine = newv($engine_class, array());
     $this->engine->setWorkingCopy($working_copy);
     $this->engine->setPaths($paths);
index 3b79182747c67b656b676743db54493d1d7e533c..cafa3c73d5f3840bdb78b024e3b6c8c974b86495 100644 (file)
@@ -6,6 +6,7 @@
 
 
 
+phutil_require_module('arcanist', 'exception/usage');
 phutil_require_module('arcanist', 'exception/usage/noengine');
 phutil_require_module('arcanist', 'repository/api/base');
 phutil_require_module('arcanist', 'unit/result');