summaryrefslogtreecommitdiff
path: root/python/helpers/pycharm/lettuce_runner.py
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-09-18 13:38:58 -0700
committerTor Norbye <tnorbye@google.com>2014-09-18 13:38:58 -0700
commitb5fb31ef6a38f19404859755dbd2e345215b97bf (patch)
treee8787c45e494dfcc558faf0f75956f8785c39b94 /python/helpers/pycharm/lettuce_runner.py
parente222a9e1e66670a56e926a6b0f3e10231eeeb1fb (diff)
parente782c57d74000722f9db4c9426317410520670c6 (diff)
downloadidea-b5fb31ef6a38f19404859755dbd2e345215b97bf.tar.gz
Merge remote-tracking branch 'aosp/upstream-master' into merge
Conflicts: .idea/libraries/asm_tools.xml .idea/libraries/bouncy_castle.xml .idea/libraries/builder_model.xml .idea/libraries/commons_compress.xml .idea/libraries/easymock_tools.xml .idea/libraries/freemarker_2_3_20.xml .idea/libraries/guava_tools.xml .idea/libraries/kxml2.xml .idea/libraries/lombok_ast.xml .idea/libraries/mockito.xml .idea/modules.xml .idea/vcs.xml build/scripts/layouts.gant updater/src/com/intellij/updater/Runner.java Change-Id: I8e1c173e00cd76c855b8a98543b0a0edfdd99d12
Diffstat (limited to 'python/helpers/pycharm/lettuce_runner.py')
-rw-r--r--python/helpers/pycharm/lettuce_runner.py51
1 files changed, 33 insertions, 18 deletions
diff --git a/python/helpers/pycharm/lettuce_runner.py b/python/helpers/pycharm/lettuce_runner.py
index f0a4b5dbb873..2f64afc956d9 100644
--- a/python/helpers/pycharm/lettuce_runner.py
+++ b/python/helpers/pycharm/lettuce_runner.py
@@ -2,13 +2,14 @@
"""
BDD lettuce framework runner
TODO: Support other params (like tags) as well.
-Supports only 1 param now: folder to search "features" for.
+Supports only 2 params now: folder to search "features" for or file and "-s scenario_index"
"""
+import argparse
+import os
import _bdd_utils
__author__ = 'Ilya.Kazakevich'
from lettuce.exceptions import ReasonToFail
-import sys
import lettuce
from lettuce import core
@@ -18,31 +19,43 @@ class _LettuceRunner(_bdd_utils.BddRunner):
Lettuce runner (BddRunner for lettuce)
"""
- def __init__(self, base_dir, what_to_run):
+ def __init__(self, base_dir, what_to_run, scenarios):
"""
+ :param scenarios scenario numbers to run
+ :type scenarios list
:param base_dir base directory to run tests in
:type base_dir: str
:param what_to_run folder or file to run
:type what_to_run str
+
"""
super(_LettuceRunner, self).__init__(base_dir)
- self.__runner = lettuce.Runner(what_to_run)
+ self.__runner = lettuce.Runner(what_to_run, ",".join(scenarios))
def _get_features_to_run(self):
super(_LettuceRunner, self)._get_features_to_run()
- if self.__runner.single_feature: # We need to run one and only one feature
- return [core.Feature.from_file(self.__runner.single_feature)]
-
- # Find all features in dir
features = []
- for feature_file in self.__runner.loader.find_feature_files():
- feature = core.Feature.from_file(feature_file)
- assert isinstance(feature, core.Feature), feature
- # TODO: cut out due to https://github.com/gabrielfalcao/lettuce/issues/451 Fix when this issue fixed
- feature.scenarios = filter(lambda s: not s.outlines, feature.scenarios)
- if feature.scenarios:
- features.append(feature)
+ if self.__runner.single_feature: # We need to run one and only one feature
+ features = [core.Feature.from_file(self.__runner.single_feature)]
+ else:
+ # Find all features in dir
+ for feature_file in self.__runner.loader.find_feature_files():
+ feature = core.Feature.from_file(feature_file)
+ assert isinstance(feature, core.Feature), feature
+ # TODO: cut out due to https://github.com/gabrielfalcao/lettuce/issues/451 Fix when this issue fixed
+ feature.scenarios = filter(lambda s: not s.outlines, feature.scenarios)
+ if feature.scenarios:
+ features.append(feature)
+
+ # Choose only selected scenarios
+ if self.__runner.scenarios:
+ for feature in features:
+ filtered_feature_scenarios = []
+ for index in [i - 1 for i in self.__runner.scenarios]: # decrease index by 1
+ if index < len(feature.scenarios):
+ filtered_feature_scenarios.append(feature.scenarios[index])
+ feature.scenarios = filtered_feature_scenarios
return features
def _run_tests(self):
@@ -108,6 +121,8 @@ class _LettuceRunner(_bdd_utils.BddRunner):
if __name__ == "__main__":
- (base_dir, what_to_run) = _bdd_utils.get_path_by_args(sys.argv)
- _bdd_utils.fix_win_drive(what_to_run)
- _LettuceRunner(base_dir, what_to_run).run() \ No newline at end of file
+ (base_dir, scenarios, what_to_run) = _bdd_utils.get_what_to_run_by_env(os.environ)
+ if len(what_to_run) > 1:
+ raise Exception("Lettuce can't run more than one file now")
+ _bdd_utils.fix_win_drive(what_to_run[0])
+ _LettuceRunner(base_dir, what_to_run[0], scenarios).run() \ No newline at end of file