From 0da0eb42be3ec77416d154336e36a2c6c19b1c6b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 21 Jan 2014 21:01:53 +0000 Subject: Add --allow-missing-steps --- NEWS | 4 ++++ yarn | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 555c610..5c99718 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,10 @@ For yarn: but don't use the user's real home directory, which is important for test environment hygiene. +* New option `--allow-missing-steps` to allow running a test suite + with some steps missing. The scenarios with missing steps will be + skipped. Suggested by Pete Fotheringham. + For cmdtest: * The `--test` (`-t`) option should now work again. Thank you diff --git a/yarn b/yarn index ef19b94..af25d21 100755 --- a/yarn +++ b/yarn @@ -79,6 +79,11 @@ class YarnRunner(cliapp.Application): ['timings'], 'report wall clock time for each scenario and step') + self.settings.boolean( + ['allow-missing-steps'], + 'allow scenarios to reference steps that do not exist, ' + 'by warning about them, but otherwise ignoring the scenarios') + def info(self, msg): if self.settings['verbose']: logging.info(msg) @@ -117,7 +122,7 @@ class YarnRunner(cliapp.Application): self.check_there_are_scenarios(scenarios) self.check_for_duplicate_scenario_names(scenarios) self.check_for_thens(scenarios) - self.connect_implementations(scenarios, implementations) + scenarios = self.connect_implementations(scenarios, implementations) shell_prelude = self.load_shell_libraries() self.info('Found %d scenarios' % len(scenarios)) @@ -204,9 +209,17 @@ class YarnRunner(cliapp.Application): ''.join(' "%s"\n' % s.name for s in no_thens)) def connect_implementations(self, scenarios, implementations): + new_list = [] for scenario in scenarios: + missing_step = False for step in scenario.steps: - self.connect_implementation(scenario, step, implementations) + self.connect_implementation( + scenario, step, implementations) + if step.implementation is None: + missing_step = True + if not missing_step: + new_list.append(scenario) + return new_list def connect_implementation(self, scenario, step, implementations): matching = [i for i in implementations @@ -214,6 +227,11 @@ class YarnRunner(cliapp.Application): self.implements_matches_step(i, step)] if len(matching) == 0: + if self.settings['allow-missing-steps']: + self.warning( + 'Scenario %s has missing step %s %s' % + (scenario.name, step.what, step.text)) + return raise cliapp.AppException( 'Scenario "%s", step "%s %s" has no matching ' 'implementation' % -- cgit v1.2.1