Repository: servo/servo
File: python/servo/testing_commands.py (Python)

Code before:
    @CommandArgument("--base", default=None, help="the base URL for testcases")
    @CommandArgument("--date", default=None, help="the datestamp for the data")
    @CommandArgument("--submit", "-a", default=False, action="store_true", help="submit the data to perfherder")
    def test_perf(self, base: str | None = None, date: str | None = None, submit: bool = False) -> int:
        env = self.build_env()
        cmd = ["bash", "test_perf.sh"]
        if base:
            cmd += ["--base", base]
        if date:
            cmd += ["--date", date]
        if submit:
            cmd += ["--submit"]
        return call(cmd, env=env, cwd=path.join("etc", "ci", "performance"))

    @Command("test-unit", description="Run unit tests", category="testing")
    @CommandArgument("test_name", nargs=argparse.REMAINDER, help="Only run tests that match this pattern or file path")
    @CommandArgument("--package", "-p", default=None, help="Specific package to test")
    @CommandArgument("--bench", default=False, action="store_true", help="Run in bench mode")
    @CommandArgument(
        "--nocapture", default=False, action="store_true", help="Run tests with nocapture ( show test stdout )"
    )
    @CommandArgument("--code-coverage", default=False, action="store_true", help="Run in code coverage mode")
    @CommandArgument("--llvm-cov-option", default=None, action="append", help="Additional options for llvm-cov")
    @CommandArgument("--nextest-profile", default=None, help="Specify the Nextest profile to use")
    @CommandArgument("params", nargs="...", help="Command-line arguments to be passed through to Cargo nextest")
    @CommandBase.common_command_arguments(build_configuration=True, build_type=True)
    def test_unit(
        self,
        build_type: BuildType,
        test_name: list[str] | None = None,
        params: list[str] | None = None,
        package: str | None = None,
        bench: bool = False,
        code_coverage: bool = False,
        llvm_cov_option: Optional[List[str]] = None,
        nocapture: bool = False,
        nextest_profile: str | None = None,
        **kwargs: Any,
    ) -> int:
        if test_name is None:
            test_name = []

        self.ensure_bootstrapped()

        if package:
            packages = {package}
        else:
            packages = set()

        test_patterns = []
        for test in test_name:

Review comment (suggestion):
`params` is not strictly related to this PR, but it allows passing through parameters to nextest, like `--stress-count` to rerun tests x amount of time, which is quite useful when trying to reproduce flaky tests. 

Code after:
    @Command("test-perf", description="Run the page load performance test", category="testing")
    @CommandArgument("--base", default=None, help="the base URL for testcases")
    @CommandArgument("--date", default=None, help="the datestamp for the data")
    @CommandArgument("--submit", "-a", default=False, action="store_true", help="submit the data to perfherder")
    def test_perf(self, base: str | None = None, date: str | None = None, submit: bool = False) -> int:
        env = self.build_env()
        cmd = ["bash", "test_perf.sh"]
        if base:
            cmd += ["--base", base]
        if date:
            cmd += ["--date", date]
        if submit:
            cmd += ["--submit"]
        return call(cmd, env=env, cwd=path.join("etc", "ci", "performance"))

    @Command("test-unit", description="Run unit tests", category="testing")
    @CommandArgument("test_name", nargs=argparse.REMAINDER, help="Only run tests that match this pattern or file path")
    @CommandArgument("--package", "-p", default=None, help="Specific package to test")
    @CommandArgument("--bench", default=False, action="store_true", help="Run in bench mode")
    @CommandArgument(
        "--nocapture", default=False, action="store_true", help="Run tests with nocapture ( show test stdout )"
    )
    @CommandArgument("--code-coverage", default=False, action="store_true", help="Run in code coverage mode")
    @CommandArgument("--llvm-cov-option", default=None, action="append", help="Additional options for llvm-cov")
    @CommandArgument("--nextest-profile", default=None, help="Specify the Nextest profile to use")
    @CommandArgument("params", nargs="...", help="Command-line arguments to be passed through to Cargo nextest")
    @CommandBase.common_command_arguments(build_configuration=True, build_type=True)
    def test_unit(
        self,
        build_type: BuildType,
        test_name: list[str] | None = None,
        params: list[str] | None = None,
        package: str | None = None,
        bench: bool = False,
        code_coverage: bool = False,
        llvm_cov_option: Optional[List[str]] = None,
        nocapture: bool = False,
        nextest_profile: str | None = None,
        **kwargs: Any,
    ) -> int:
        if test_name is None:
            test_name = []

        self.ensure_bootstrapped()

        if package:
            packages = {package}
        else:
            packages = set()

        test_patterns = []