-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunner.py
More file actions
59 lines (54 loc) · 1.82 KB
/
runner.py
File metadata and controls
59 lines (54 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import argparse
import os
import subprocess
if __name__ == "__main__":
parser = argparse.ArgumentParser()
# commandline arguments
parser.add_argument(
"--env",
required=True,
help="The environment the tests are going to run in.",
)
parser.add_argument(
"--product",
required=True,
help="The product under test",
)
parser.add_argument(
"--tags",
action="append", # allow multiple tags as behave does
dest="tags",
required=False,
help="Tags to include or exclude. use ~tag_name to exclude tags",
)
parser.add_argument(
"--arm64",
required=False,
type=str,
help="Run tests using Chromium to support arm64 architecture",
)
argument = parser.parse_args()
product_tag = argument.product.lower().replace("-", "_")
tags = [tag.split(":") for tag in argument.tags] if argument.tags else []
# Prepend product_tag to flattened list of tags
tags = [product_tag] + [item for sublist in tags for item in sublist]
PRODUCT = f" -D product={argument.product}"
ENV = f" -D env={argument.env}"
ARM64 = f" -D arm64={argument.arm64}"
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
# complete command
command = (
f"behave{PRODUCT}{ENV}{ARM64}"
f" -f behave_cucumber_formatter:PrettyCucumberJSONFormatter"
f" -o reports/cucumber_json.json"
f" -f allure_behave.formatter:AllureFormatter"
f" -o allure-results"
f" -f pretty features"
f" --no-logcapture"
f" --no-skipped "
f" --expand"
f" --logging-level={LOG_LEVEL}"
f" {" ".join(f"--tags {tag}" for tag in tags)}"
)
print(f"Running subprocess with command: '{command}'")
subprocess.run(command, shell=True, check=True)