From 6af42b523ddb87f9f3adb729124da59db33ac5c3 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 19 Jan 2023 13:56:17 +0100 Subject: [PATCH] feat(tests): generate index on demand when looking at results through show_results.py --- tests/show_results.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/show_results.py b/tests/show_results.py index 3255593c6..95f2b785f 100755 --- a/tests/show_results.py +++ b/tests/show_results.py @@ -5,6 +5,7 @@ import json import multiprocessing import os import posixpath +import sys import time import webbrowser from pathlib import Path @@ -13,9 +14,13 @@ from urllib.parse import unquote import click ROOT = Path(__file__).resolve().parent.parent -TEST_RESULT_PATH = ROOT / "tests" / "ui_tests" / "reporting" / "reports" / "test" +UI_TESTS_PATH = ROOT / "tests" / "ui_tests" +TEST_RESULT_PATH = UI_TESTS_PATH / "reporting" / "reports" / "test" FIXTURES_PATH = ROOT / "tests" / "ui_tests" / "fixtures.json" +sys.path.append(str(UI_TESTS_PATH)) +from reporting import testreport # noqa: E402 + class NoCacheRequestHandler(http.server.SimpleHTTPRequestHandler): def end_headers(self) -> None: @@ -53,6 +58,12 @@ class NoCacheRequestHandler(http.server.SimpleHTTPRequestHandler): if trailing_slash: path += "/" return path + + def do_GET(self) -> None: + if self.path in ("/", "/index.html"): + testreport.index() + + return super().do_GET() def do_POST(self) -> None: if self.path == "/fixtures.json" and FIXTURES_PATH.exists():