Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TESTSUITE: Extract cmake logs in testresults. #8235

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 104 additions & 52 deletions Testsuite/test/post_process_ctest_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import re
import os

report_file=sys.argv[1]
report_name=sys.argv[2]
global_report_name=sys.argv[3]
rx=re.compile('(.*Configuring (examples|demo|test)*( in )*(test\/|examples\/|demo\/)*)((?!done)\w+)')
rx_demo=re.compile('.*in demo\/')
rx_examples=re.compile('.*in examples\/')
input_report_file=sys.argv[1]
lrineau marked this conversation as resolved.
Show resolved Hide resolved
report_file_name=sys.argv[2]
global_report_file_name=sys.argv[3]
config_regex=re.compile('(.*Configuring (examples|demo|test)*( in )*(test\/|examples\/|demo\/)*)((?!done)\w+)')
demo_regex=re.compile('.*in demo\/')
examples_regex=re.compile('.*in examples\/')
lrineau marked this conversation as resolved.
Show resolved Hide resolved
Separator = "------------------------------------------------------------------"


#open the Installation report
Expand All @@ -20,52 +21,103 @@
name=""
is_writing=False
is_ignored=False
global_report=open(global_report_name, "a+")
with open(report_file, "rt") as test_report:
for myline in test_report:
m=rx.match(myline)

if is_writing:
if m:
is_writing=False
test_report.close()
if is_ignored:
print("{label} {result}".format(label=name, result='r'), file=global_report)
is_ignored=False
else:
test_report.write(myline)
if not is_writing:
if m:
name=m.group(0).replace(m.group(1), "")
if rx_demo.match(myline):
name="{str}_Demo".format(str=name)
elif rx_examples.match(myline):
name="{str}_Examples".format(str=name)
elif name == "libCGAL":
name="libCGAL_shared"
elif name == "libCGAL_Core":
name="libCGALCore_shared"
elif name == "libCGAL_ImageIO":
name="libCGALimageIO_shared"
elif name == "libCGAL_Qt6":
name="libCGALQt6_shared"
if name=="incomplete":
is_writing=False
is_ignored=False
continue
else:
if not os.path.isdir(name):
is_ignored=True
os.mkdir(name)
test_report=open("{dir}/{file}".format(dir=name, file=report_name), "w+")
print("""
{scm_branch}
""" .format(scm_branch=open("{}/../../../../../.scm-branch".format(os.getcwd()), 'r').read()),file=test_report)
else:
is_ignored=False
test_report=open("{dir}/{file}".format(dir=name, file=report_name), "a+")
test_report.write(" --- CMake Results: --- \n\n")
is_writing=True
position = 0
lines_to_write = []
installation_cmake_logs = []



def find_third_separator(contents):
separator_count = 0
for i, line in enumerate(contents):
if line.strip() == Separator:
separator_count += 1
if separator_count == 3:
return i
return len(contents) + 2

def find_last_separator(contents):
for i, line in enumerate(contents):
if line.strip() == Separator:
position = i
return position

with open ("{dir}/{file}".format(dir="Installation",file=report_file_name), "r") as file:
contents = file.readlines()
position = find_last_separator(contents)
for i, line in enumerate(contents):
if i > position:
installation_cmake_logs.append(line)
if line.strip() == "== Generating build files for tests ==":
break
contents = []

global_report = open(global_report_file_name, "a+")
with open(input_report_file, "rt") as test_report:
for myline in test_report:
match = config_regex.match(myline)
if is_writing:
if match:
is_writing = False
if lines_to_write:
file_path = "{dir}/{file}".format(dir=name, file=report_file_name)
if os.path.exists(file_path):
with open(file_path, "r") as file:
contents = file.readlines()
else:
contents = []

position = find_third_separator(contents)

if Separator + "\n- CMake Results \n" + Separator not in lines_to_write:
lines_to_write.insert(0,Separator + "\n- CMake Results \n" + Separator + "\n")
if Separator + "\n- CMake Logs \n" + Separator not in contents:
contents.insert(position - 1, Separator + "\n- CMake Logs \n" + Separator + "\n\n")
for log in installation_cmake_logs:
contents.insert(position, log)
position += 1
lines_to_write.insert(0, "\n")
contents[position:position] = lines_to_write

with open(file_path, "w") as file:
file.write("".join(contents))

lines_to_write = []

if is_ignored:
is_ignored = False
else:
if myline.strip() != "":
lines_to_write.append(myline)
if not is_writing:
if match:
name=match.group(0).replace(match.group(1), "")
if demo_regex.match(myline):
name="{str}_Demo".format(str=name)
elif examples_regex.match(myline):
name="{str}_Examples".format(str=name)
elif name == "libCGAL":
name="libCGAL_shared"
elif name == "libCGAL_Core":
name="libCGALCore_shared"
elif name == "libCGAL_ImageIO":
name="libCGALimageIO_shared"
elif name == "libCGAL_Qt6":
name="libCGALQt6_shared"
if name=="incomplete":
is_writing=False
is_ignored=False
continue
else:
if not os.path.isdir(name):
is_ignored = True
os.mkdir(name)
with open("{dir}/{file}".format(dir=name, file=report_file_name), "w") as test_report:
test_report.write(open("{}/../../../../../.scm-branch".format(os.getcwd()), 'r').read())
else:
is_ignored = False
is_writing = True

if is_writing:
is_writing=False
test_report.close()
Expand Down