Skip to content

Commit

Permalink
Add environment update needed for issue #510 test
Browse files Browse the repository at this point in the history
  • Loading branch information
jenisys committed Nov 24, 2016
1 parent 1a483ab commit 698b29a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions issue.features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,48 @@
* active tags
"""

from __future__ import print_function
from behave.tag_matcher import ActiveTagMatcher, setup_active_tag_values
from behave4cmd0.setup_command_shell import setup_command_shell_processors4behave
import six
import sys
import platform
import os.path


def require_tool(tool_name):
"""Check if a tool (an executable program) is provided on this platform.
:params tool_name: Name of the tool to check if it is available.
:return: True, if tool is found.
:return: False, if tool is not available (or not in search path).
"""
# print("CHECK-TOOL: %s" % tool_name)
path = os.environ.get("PATH")
if not path:
return False

for searchdir in path.split(os.pathsep):
executable1 = os.path.normpath(os.path.join(searchdir, tool_name))
executables = [executable1]
if sys.platform.startswith("win"):
executables.append(executable1 + ".exe")

for executable in executables:
# print("TOOL-CHECK: %s" % os.path.abspath(executable))
if os.path.isfile(executable):
# print("TOOL-FOUND: %s" % os.path.abspath(executable))
return True
# -- OTHERWISE: Tool not found
# print("TOOL-NOT-FOUND: %s" % tool_name)
return False

def as_bool_string(value):
if bool(value):
return "yes"
else:
return "no"


# -- MATCHES ANY TAGS: @use.with_{category}={value}
# NOTE: active_tag_value_provider provides category values for active tags.
Expand All @@ -21,6 +58,7 @@
"python.implementation": platform.python_implementation().lower(),
"pypy": str("__pypy__" in sys.modules).lower(),
"os": sys.platform,
"xmllint": as_bool_string(require_tool("xmllint")),
}
active_tag_matcher = ActiveTagMatcher(active_tag_value_provider)

Expand All @@ -38,3 +76,4 @@ def before_feature(context, feature):
def before_scenario(context, scenario):
if active_tag_matcher.should_exclude_with(scenario.effective_tags):
scenario.skip(reason=active_tag_matcher.exclude_reason)

0 comments on commit 698b29a

Please sign in to comment.