-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtest_visualize_log.py
More file actions
35 lines (33 loc) · 1.32 KB
/
Copy pathtest_visualize_log.py
File metadata and controls
35 lines (33 loc) · 1.32 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
import os
import subprocess
import rift_expect_session
def test_visualize_log_file():
# Delete the rift.log file from previous runs, if any
log_file_name = "rift.log"
if os.path.exists(log_file_name):
os.remove(log_file_name)
# If rift.log.html still exists from a previous run, remove it
html_file_name = "rift.log.html"
if os.path.exists(html_file_name):
os.remove(html_file_name)
# Briefly run RIFT to produce a valid log file
res = rift_expect_session.RiftExpectSession("2n_l0_l1")
res.stop()
# Run the visualization tool, and makes sure it exits without an error
return_code = subprocess.call("rift/visualize_log.py")
assert return_code == 0
# Check that a visualization file was indeed produced
assert os.path.exists(html_file_name)
# We can't really check that the visualization "looks good" So, instead we just check that there
# is at least <svg ...> and </svg> tags, which is a decent indication that the tool ran to
# completion.
found_start = False
found_end = False
with open(html_file_name, encoding='utf-8') as infile:
for line in infile:
if line.startswith("<svg"):
found_start = True
if line.startswith("</svg>"):
found_end = True
assert found_start
assert found_end