-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.py
More file actions
32 lines (27 loc) · 815 Bytes
/
Copy pathtest_runner.py
File metadata and controls
32 lines (27 loc) · 815 Bytes
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
#!/bin/env python3
import sys
import subprocess
import random
modes = {"1": "-s", "2": "-si", "3": "-sh"}
command, mode, count, floor, ceil = sys.argv[-1].split()
mode = modes[mode]
count = int(count)
floor = float(floor)
ceil = float(ceil)
array = [random.uniform(floor, ceil) for _ in range(count)]
output = f" ".join(f"{n:.6f}".replace(".", ",") for n in sorted(array))
result = subprocess.run(
[command, mode, *(f"{n:.6f}".replace(".", ",") for n in array)], capture_output=True
)
if bytes(output, encoding="UTF-8") not in result.stdout.splitlines()[-1]:
print(
"> Expected output:",
output,
"> Test has not passed. Program output:",
result.stdout.decode(),
"> Error log:",
result.stderr.decode(),
sep="\n",
)
sys.exit(1)
sys.exit(0)