Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assemble markers from job and cli #188

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,29 @@ def build_pytest_cmd(job_data, hosts=None, pytest_args=[]):

job_params = dict(job_data["params"])

def _join_pytest_args(arg, option):
cli_args = []
try:
while True:
i = pytest_args.index(option)
value = pytest_args[i + 1]
del pytest_args[i + 1]
del pytest_args[i]
cli_args.append(value)
except ValueError:
pass
joined_cli_args = ") and (".join(cli_args)
if arg and joined_cli_args:
return f"({arg}) and ({joined_cli_args})"
if joined_cli_args:
return f"({joined_cli_args})"
return arg

# Merge name filter
cli_name_filters = []
try:
while True:
i = pytest_args.index("-k")
value = pytest_args[i + 1]
del pytest_args[i + 1]
del pytest_args[i]
cli_name_filters.append(value)
except ValueError:
pass

joined_cli_filters = ") and (".join(cli_name_filters)
if name_filter and joined_cli_filters:
name_filter = f"({name_filter}) and ({joined_cli_filters})"
elif joined_cli_filters:
name_filter = f"({joined_cli_filters})"
name_filter = _join_pytest_args(name_filter, "-k")

# Merge markers
markers = _join_pytest_args(markers, "-m")

# pytest_args may override job_params
pytest_args_keys = []
Expand Down
Loading