2022-02-13 15:51:24 +00:00
|
|
|
"""
|
|
|
|
Extract the GNU logs into a JSON file.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import json
|
2023-02-01 09:56:16 +00:00
|
|
|
import re
|
2022-02-13 15:51:24 +00:00
|
|
|
import sys
|
2023-02-01 09:56:16 +00:00
|
|
|
from pathlib import Path
|
2022-02-13 15:51:24 +00:00
|
|
|
|
|
|
|
out = {}
|
|
|
|
|
|
|
|
test_dir = Path(sys.argv[1])
|
|
|
|
for filepath in test_dir.glob("**/*.log"):
|
|
|
|
path = Path(filepath)
|
|
|
|
current = out
|
|
|
|
for key in path.parent.relative_to(test_dir).parts:
|
|
|
|
if key not in current:
|
|
|
|
current[key] = {}
|
|
|
|
current = current[key]
|
|
|
|
try:
|
2023-03-13 07:33:07 +00:00
|
|
|
with open(path, errors="ignore") as f:
|
2022-02-13 15:51:24 +00:00
|
|
|
content = f.read()
|
2023-02-01 09:56:16 +00:00
|
|
|
result = re.search(
|
|
|
|
r"(PASS|FAIL|SKIP|ERROR) [^ ]+ \(exit status: \d+\)$", content
|
|
|
|
)
|
|
|
|
if result:
|
|
|
|
current[path.name] = result.group(1)
|
2022-02-13 15:51:24 +00:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2022-08-14 10:45:42 +00:00
|
|
|
print(json.dumps(out, indent=2, sort_keys=True))
|