summaryrefslogtreecommitdiff
path: root/yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-07-14 19:23:43 +0100
committerLars Wirzenius <liw@liw.fi>2013-07-14 19:23:43 +0100
commitfc0481c1d8a33a7efa0a2247f897671a118bba75 (patch)
treedf729389109b490c052365327f5215bcb1ff74ae /yarn
parent9daf600f77ecc116ff345e4f53c50994443e0973 (diff)
downloadcmdtest-fc0481c1d8a33a7efa0a2247f897671a118bba75.tar.gz
Implement ASSUMING
Diffstat (limited to 'yarn')
-rwxr-xr-xyarn42
1 files changed, 27 insertions, 15 deletions
diff --git a/yarn b/yarn
index fb6e5a3..6845345 100755
--- a/yarn
+++ b/yarn
@@ -22,6 +22,7 @@ import logging
import os
import re
import shutil
+import sys
import tempfile
import time
import ttystatus
@@ -225,36 +226,47 @@ class YarnRunner(cliapp.Application):
os.mkdir(datadir)
self.info('DATADIR is %s' % datadir)
+ assuming = [s for s in scenario.steps if s.what == 'ASSUMING']
cleanup = [s for s in scenario.steps if s.what == 'FINALLY']
- normal = [s for s in scenario.steps if s not in cleanup]
+ normal = [s for s in scenario.steps if s not in assuming + cleanup]
ok = True
step_number = 0
- for step in normal:
- exit = self.run_step(datadir, scenario, step, shell_prelude)
+ for step in assuming:
+ exit = self.run_step(datadir, scenario, step, shell_prelude, False)
step_number += 1
self.snapshot_datadir(
tempdir, datadir, scenario, step_number, step)
if exit != 0:
- ok = False
- break
-
- for step in cleanup:
- exit = self.run_step(datadir, scenario, step, shell_prelude)
- step_number += 1
- self.snapshot_datadir(
- tempdir, datadir, scenario, step_number, step)
- if exit != 0:
- ok = False
break
+ else:
+ for step in normal:
+ exit = self.run_step(
+ datadir, scenario, step, shell_prelude, True)
+ step_number += 1
+ self.snapshot_datadir(
+ tempdir, datadir, scenario, step_number, step)
+ if exit != 0:
+ ok = False
+ break
+
+ for step in cleanup:
+ exit = self.run_step(
+ datadir, scenario, step, shell_prelude, True)
+ step_number += 1
+ self.snapshot_datadir(
+ tempdir, datadir, scenario, step_number, step)
+ if exit != 0:
+ ok = False
+ break
if not self.settings['snapshot']:
shutil.rmtree(tempdir)
return ok
- def run_step(self, datadir, scenario, step, shell_prelude):
+ def run_step(self, datadir, scenario, step, shell_prelude, report_error):
self.info('Running step "%s %s"' % (step.what, step.text))
self.ts['step'] = step
self.ts['step_name'] = '%s %s' % (step.what, step.text)
@@ -281,7 +293,7 @@ class YarnRunner(cliapp.Application):
else:
logging.debug('Standard error: empty')
- if exit != 0:
+ if exit != 0 and report_error:
self.error(
'ERROR: In scenario "%s"\nstep "%s %s" failed,\n'
'with exit code %d:\n'