summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-04-19 22:33:18 +0300
committerLars Wirzenius <liw@liw.fi>2015-04-19 22:33:18 +0300
commita1b9ab55aba382406fa98d04795e1d6942ae3c4b (patch)
treea5fc950fc972c5d85e9e730bce0eb4bbcc5f706d
parent09c08b9194e76405e84c510662b693975ef83545 (diff)
downloadcmdtest-a1b9ab55aba382406fa98d04795e1d6942ae3c4b.tar.gz
Indent steps when running in verbose mode
-rwxr-xr-xyarn23
1 files changed, 12 insertions, 11 deletions
diff --git a/yarn b/yarn
index 0896f8d..cff8e88 100755
--- a/yarn
+++ b/yarn
@@ -84,10 +84,11 @@ class YarnRunner(cliapp.Application):
'allow scenarios to reference steps that do not exist, '
'by warning about them, but otherwise ignoring the scenarios')
- def info(self, msg):
+ def info(self, indent, msg):
if self.settings['verbose']:
logging.info(msg)
- self.output.write('%s\n' % msg)
+ indent_size = 4
+ self.output.write('%*s%s\n' % (indent * indent_size, '', msg))
def warning(self, msg):
if self.settings['verbose']:
@@ -125,7 +126,7 @@ class YarnRunner(cliapp.Application):
scenarios = self.connect_implementations(scenarios, implementations)
shell_prelude = self.load_shell_libraries()
- self.info('Found %d scenarios' % len(scenarios))
+ self.info(0, 'Found %d scenarios' % len(scenarios))
all_steps = []
for scenario in scenarios:
@@ -168,7 +169,7 @@ class YarnRunner(cliapp.Application):
def parse_scenarios(self, filenames):
mdparser = yarnlib.MarkdownParser()
for filename in filenames:
- self.info('Parsing scenario file %s' % filename)
+ self.info(0, 'Parsing scenario file %s' % filename)
blocks = mdparser.parse_file(filename)
if not blocks:
self.warning('No scenario code blocks in %s' % filename)
@@ -250,12 +251,12 @@ class YarnRunner(cliapp.Application):
def load_shell_libraries(self):
if not self.settings['shell-library']:
- self.info('No shell libraries defined')
+ self.info(0, 'No shell libraries defined')
return ''
libs = []
for filename in self.settings['shell-library']:
- self.info('Loading shell library %s' % filename)
+ self.info(0, 'Loading shell library %s' % filename)
with open(filename) as f:
text = f.read()
libs.append('# Loaded from %s\n\n%s\n\n' % (filename, text))
@@ -285,12 +286,12 @@ class YarnRunner(cliapp.Application):
self.start_scenario_timing(scenario.name)
started = time.time()
- self.info('Running scenario %s' % scenario.name)
+ self.info(0, 'Running scenario %s' % scenario.name)
self.ts['scenario_name'] = scenario.name
self.scenarios_run += 1
if self.settings['no-act']:
- self.info('Pretending everything went OK')
+ self.info(0, 'Pretending everything went OK')
for step in scenario.steps:
self.ts['current_step'] = step
self.remember_scenario_timing(time.time() - started)
@@ -306,10 +307,10 @@ class YarnRunner(cliapp.Application):
os.mkdir(self.scenario_dir(tempdir, scenario))
datadir = self.datadir(tempdir, scenario)
os.mkdir(datadir)
- self.info('DATADIR is %s' % datadir)
+ self.info(1, 'DATADIR is %s' % datadir)
homedir = self.homedir(datadir)
os.mkdir(homedir)
- self.info('HOME for tests is %s' % homedir)
+ self.info(1, 'HOME for tests is %s' % homedir)
assuming = [s for s in scenario.steps if s.what == 'ASSUMING']
cleanup = [s for s in scenario.steps if s.what == 'FINALLY']
@@ -397,7 +398,7 @@ class YarnRunner(cliapp.Application):
def run_step(self, datadir, scenario, step, shell_prelude, report_error):
started = time.time()
- self.info('Running step "%s %s"' % (step.what, step.text))
+ self.info(1, 'Running step "%s %s"' % (step.what, step.text))
self.ts['current_step'] = step
self.ts['step_name'] = '%s %s' % (step.what, step.text)
self.steps_run += 1