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
|
# run_api_test.py
import json
import os
import glob
from pathlib import Path
output_dir = "/tmp/dory-file-output"
results = []
doryStepFail = False
doryOutputFiles = []
for name in glob.glob("./**/*.robot", recursive = True):
path = str(Path(name).parent)
file = Path(name).name
log_file = path + "/" + file.replace(".robot", "-log.html")
output_file = path + "/" + file.replace(".robot", "-output.xml")
report_file = path + "/" + file.replace(".robot", "-report.html")
prefix = "./"
if name.startswith("./"):
name = name[len(prefix):]
if log_file.startswith("./"):
log_file = log_file[len(prefix):]
if output_file.startswith("./"):
output_file = output_file[len(prefix):]
if report_file.startswith("./"):
report_file = report_file[len(prefix):]
os.system("mkdir -p {0}/{1}".format(output_dir, path))
cmd = "robot -l {0}/{1} -o {0}/{2} -r {0}/{3} {4}".format(output_dir, log_file, output_file, report_file, name)
print(cmd)
ok = os.system(cmd)
isOK = False
if ok == 0:
isOK = True
else:
doryStepFail = True
result = {"name": name, "log_file": log_file, "output_file": output_file, "report_file": report_file, "ok": isOK}
results.append(result)
doryOutputFiles.append(log_file)
doryOutputFiles.append(output_file)
doryOutputFiles.append(report_file)
print(result)
test_results = {"results": results, "doryStepFail": doryStepFail, "doryOutputFiles": doryOutputFiles}
test_results_pretty = json.dumps(test_results, indent=4, sort_keys=True)
print(test_results_pretty)
f = open("/tmp/dory-param-output.json", "w")
f.write(test_results_pretty)
f.close()
|