From ca879150c8a4d9c132de892f14c248d09ba1ae82 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 21 Dec 2011 08:51:34 -0800 Subject: [PATCH] Improve detection of invalid unit and lint engines 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 | 5 +++++ src/workflow/unit/ArcanistUnitWorkflow.php | 7 ++++++- src/workflow/unit/__init__.php | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/workflow/lint/ArcanistLintWorkflow.php b/src/workflow/lint/ArcanistLintWorkflow.php index df923d1b..f50a88cf 100644 --- a/src/workflow/lint/ArcanistLintWorkflow.php +++ b/src/workflow/lint/ArcanistLintWorkflow.php @@ -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); diff --git a/src/workflow/unit/ArcanistUnitWorkflow.php b/src/workflow/unit/ArcanistUnitWorkflow.php index bf976ec5..50a40284 100644 --- a/src/workflow/unit/ArcanistUnitWorkflow.php +++ b/src/workflow/unit/ArcanistUnitWorkflow.php @@ -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); diff --git a/src/workflow/unit/__init__.php b/src/workflow/unit/__init__.php index 3b791827..cafa3c73 100644 --- a/src/workflow/unit/__init__.php +++ b/src/workflow/unit/__init__.php @@ -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'); -- 2.43.0