#!/usr/bin/env python3 """ This script will create a new test file and expectations in the Tests/LibWeb directory """ import argparse from pathlib import Path TEST_DIR = Path(__file__).resolve().parent def create_test(test_name: str, test_type: str, is_async: bool = False) -> None: """ Create a test of a given type with the given test name Args: test_name (str): Name of the test. test_type (str): Type of the test. Currently supports "Text", "Layout", "Screenshot" and "Ref"" is_async (bool, optional): Whether it is an async test. Defaults to False. """ input_prefix = TEST_DIR / test_type / "input" / test_name input_file = input_prefix.with_suffix(".html") input_dir = input_prefix.parent output_prefix = TEST_DIR / test_type / "expected" / test_name if test_type in ["Layout", "Text"]: output_file = output_prefix.with_suffix(".txt") else: output_file = output_prefix.with_name(Path(test_name).stem + "-ref.html") output_dir = output_prefix.parent # Create directories if they don't exist input_dir.mkdir(parents=True, exist_ok=True) output_dir.mkdir(parents=True, exist_ok=True) num_sub_levels = len(Path(test_name).parents) - 1 path_to_include_js = "../" * num_sub_levels + "include.js" def generate_boilerplate(): """ return a tuple of strings with the input and output boilerplate for a given test type """ generic_boilerplate = R"""
""" if test_type == "Text": input_boilerplate = Rf""" """ expected_boilerplate = "Expected println() output\n" elif test_type == "Ref": input_boilerplate = Rf""" """ expected_boilerplate = f"Put equivalently rendering HTML for {test_name} here." elif test_type == "Screenshot": input_boilerplate = Rf""" """ expected_boilerplate = f"""