-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathdebug_example.py
More file actions
43 lines (31 loc) · 1.53 KB
/
Copy pathdebug_example.py
File metadata and controls
43 lines (31 loc) · 1.53 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
"""
Do you want to run a test on a specific example? If so, this is the script for you.
Modify as you please, just remember not to commit your changes.
"""
import os
import importlib
from testing.comparison_tests import compare_files
if __name__ == "__main__":
example = "ellipse"
test_name = "basic_usage"
test_type = ["comparison", "other"][0]
if test_type == "comparison":
run_test = importlib.import_module(f"testing.comparison_tests.{test_name}.test").run_test
input_path = os.path.join("examples", f"{example}.svg")
correct_path = os.path.join("comparison_tests", test_name, f"{example}.gcode")
output_path = os.path.join("comparison_tests", test_name, f"{example}-unverified.gcode")
with open(input_path, 'rb') as svg_file:
svg_string = svg_file.read()
with open(output_path, 'w') as gcode_file:
gcode_file.write(run_test(svg_string))
print(f"Saved output to {output_path}")
if os.path.isfile(correct_path):
if compare_files(correct_path, output_path):
print("Success, outputs are within operational tolerance")
else:
print("Oops, the outputs are different")
if test_type == "other":
svg_file_name = os.path.join("examples", f"{example}.svg")
debug_file_name = os.path.join("other_tests", test_name, f"{example}.svg")
run_test = importlib.import_module(f"testing.other_tests.{test_name}.test").run_test
print(run_test(svg_file_name, debug_file_name))