Skip to content

Commit ca8bfeb

Browse files
author
Davide Moro
committed
fix issues with parameters -m and -k expressions in jenkins
1 parent a1997e7 commit ca8bfeb

File tree

1 file changed

+46
-21
lines changed
  • {{cookiecutter.project_slug}}

1 file changed

+46
-21
lines changed

{{cookiecutter.project_slug}}/ci.py

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env python
2+
23
import os
4+
from shlex import split
5+
36
try:
47
from shlex import quote
58
except ImportError:
@@ -16,8 +19,8 @@ def prettify_path(path):
1619

1720
if __name__ == "__main__":
1821
environment = os.getenv('ENVIRONMENT')
19-
markers = quote(os.getenv('MARKERS'))
20-
keywords = quote(os.getenv('KEYWORDS'))
22+
markers = os.getenv('MARKERS')
23+
keywords = os.getenv('KEYWORDS')
2124
os_version = os.getenv('OS')
2225
browser = os.getenv('BROWSER')
2326
parallel_sessions = os.getenv('PARALLEL_SESSIONS')
@@ -41,29 +44,46 @@ def prettify_path(path):
4144
assert os.path.isfile(credentials_file)
4245

4346
pytest_cmd = [
44-
'tox',
45-
'-epy36',
46-
'--',
47-
'-vvv',
48-
'--variables=capabilities/project.json',
49-
'--variables={0}'.format(os_file),
50-
'--variables={0}'.format(browser_file),
51-
'--variables={0}'.format(resolution_file),
52-
'--splinter-webdriver=remote',
53-
'--splinter-remote-url={0}'.format(
47+
"tox",
48+
"-epy36",
49+
"--",
50+
"-vvv",
51+
"--variables",
52+
"capabilities/project.json",
53+
"--variables",
54+
"{0}".format(os_file),
55+
"--variables",
56+
"{0}".format(browser_file),
57+
"--variables",
58+
"{0}".format(resolution_file),
59+
"--splinter-webdriver",
60+
"remote",
61+
"--splinter-remote-url",
62+
"{0}".format(
5463
selenium_grid_url),
55-
'--variables={0}'.format(credentials_file),
56-
'--junitxml={0}'.format(build_id),
64+
"--variables",
65+
"{0}".format(credentials_file),
66+
"--junitxml",
67+
"{0}".format(build_id),
5768
]
5869

5970
if markers:
60-
pytest_cmd.append('-m={0}'.format(markers))
71+
pytest_cmd.extend([
72+
"-m",
73+
quote(markers),
74+
])
6175

6276
if keywords:
63-
pytest_cmd.append('-k={0}'.format(keywords))
77+
pytest_cmd.extend([
78+
"-k",
79+
quote(keywords)
80+
])
6481

6582
if os.getenv('DEBUG') == 'true':
66-
pytest_cmd.append('--variables=capabilities/debug.json')
83+
pytest_cmd.extend([
84+
"--variables",
85+
"capabilities/debug.json"
86+
])
6787

6888
if os.getenv('TESTRAIL_ENABLE') == 'true':
6989
if 'pcmw' in environment:
@@ -79,16 +99,21 @@ def prettify_path(path):
7999
prettify_path(browser), markers, keywords))
80100

81101
pytest_cmd.extend([
82-
'--testrail={0}'.format(testrail_file),
83-
'--tr_name={0}"'.format(tr_name),
102+
"--testrail",
103+
testrail_file,
104+
"--tr_name",
105+
tr_name,
84106
])
85107

86108
if os.getenv('BLOCK_FIRST_FAILURE') == 'true':
87109
pytest_cmd.append('-x')
88110

89111
if parallel_sessions:
90112
assert isinstance(parallel_sessions, int)
91-
pytest_cmd.append('-n {0}'.format(parallel_sessions))
113+
pytest_cmd.extend([
114+
"-n",
115+
parallel_sessions,
116+
])
92117

93118
print(str(pytest_cmd))
94-
run(pytest_cmd)
119+
run(split(" ".join(pytest_cmd)))

0 commit comments

Comments
 (0)