Revision: 3239
Author: janne.t.harkonen
Date: Fri May 7 14:05:39 2010
Log: initial, naive implementation of dry run, issue 452
http://code.google.com/p/robotframework/source/detail?r=3239
Modified:
/trunk/src/robot/common/model.py
/trunk/src/robot/output/readers.py
/trunk/src/robot/running/handlers.py
/trunk/src/robot/running/keywords.py
/trunk/src/robot/running/model.py
=======================================
--- /trunk/src/robot/common/model.py Thu Apr 22 00:13:41 2010
+++ /trunk/src/robot/common/model.py Fri May 7 14:05:39 2010
@@ -275,6 +275,8 @@
runmode = runmode.upper()
if runmode == 'EXITONFAILURE':
self._run_mode_exit_on_failure = True
+ elif runmode == 'DRYRUN':
+ self._run_mode_dry_run = True
elif runmode == 'RANDOM:TEST':
random.shuffle(self.tests)
elif runmode == 'RANDOM:SUITE':
=======================================
--- /trunk/src/robot/output/readers.py Tue Mar 2 02:57:25 2010
+++ /trunk/src/robot/output/readers.py Fri May 7 14:05:39 2010
@@ -91,7 +91,7 @@
except AttributeError:
status = _MissingStatus()
self.status = status.get_attr('status','').upper()
- if self.status not in ['PASS','FAIL']:
+ if self.status not in ['PASS','FAIL', 'NOT_RUN']:
raise DataError("Item '%s' has invalid status '%s'"
% (self.name, status))
self.message = status.text
=======================================
--- /trunk/src/robot/running/handlers.py Fri May 7 05:25:59 2010
+++ /trunk/src/robot/running/handlers.py Fri May 7 14:05:39 2010
@@ -89,6 +89,8 @@
pass
def run(self, context, args):
+ if context.dry_run:
+ return None
output = context.output
positional, named = self.arguments.resolve(args,
context.get_current_vars(),
output)
=======================================
--- /trunk/src/robot/running/keywords.py Fri May 7 05:25:59 2010
+++ /trunk/src/robot/running/keywords.py Fri May 7 14:05:39 2010
@@ -77,7 +77,8 @@
except ExecutionFailed, err:
self.status = 'FAIL'
else:
- self.status = 'PASS'
+ if not (context.dry_run and handler.type == 'library'):
+ self.status = 'PASS'
self.endtime = utils.get_timestamp()
self.elapsedtime = utils.get_elapsed_time(self.starttime,
self.endtime)
context.end_keyword(self)
@@ -245,7 +246,7 @@
def _run(self, context):
items = self._replace_vars_from_items(context.get_current_vars())
errors = []
- for i in range(0, len(items), len(self.vars)):
+ for i in self._iteration_steps(items, context):
values = items[i:i+len(self.vars)]
err = self._run_one_round(context, self.vars, values)
if err:
@@ -255,6 +256,11 @@
if errors:
raise ExecutionFailures(errors)
+ def _iteration_steps(self, items, context):
+ if context.dry_run:
+ return [0]
+ return range(0, len(items), len(self.vars))
+
def _run_one_round(self, context, variables, values):
foritem = ForItemKeyword(variables, values)
context.output.start_keyword(foritem)
=======================================
--- /trunk/src/robot/running/model.py Fri May 7 05:25:59 2010
+++ /trunk/src/robot/running/model.py Fri May 7 14:05:39 2010
@@ -37,9 +37,10 @@
class ExecutionContext(object):
- def __init__(self, namespace, output):
+ def __init__(self, namespace, output, dry_run=False):
self.namespace = namespace
self.output = output
+ self.dry_run = dry_run
def get_current_vars(self):
return self.namespace.variables
@@ -127,6 +128,7 @@
for test in data.tests:
RunnableTestCase(test, testdefaults, parent=self)
self._run_mode_exit_on_failure = False
+ self._run_mode_dry_run = False
def run(self, output, parent=None, errors=None):
context = self._start_run(output, parent, errors)
@@ -145,7 +147,8 @@
self.status = 'RUNNING'
self.starttime = utils.get_timestamp()
parent_vars = parent.context.get_current_vars() if parent else None
- self.context = ExecutionContext(Namespace(self, parent_vars),
output)
+ self.context = ExecutionContext(Namespace(self, parent_vars),
output,
+ self._run_mode_dry_run)
self._set_variable_dependent_metadata(self.context)
output.start_suite(self)
return self.context