diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5edb111c6..ec0851f10 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,8 +3,8 @@ name: Tests on: push: branches: [main] - pull_request_target: - branches: [main] + pull_request: + branches: [ main ] jobs: build: diff --git a/src/robocop/run.py b/src/robocop/run.py index 627bd1d2c..08a89e2db 100644 --- a/src/robocop/run.py +++ b/src/robocop/run.py @@ -147,7 +147,7 @@ def list_commands(self, ctx: typer.Context) -> list[str]: # noqa: ARG002 cache_option = Annotated[ bool, typer.Option( - "--cache", + "--cache/--no-cache", help="Disable file caching. All files will be processed regardless of modifications.", rich_help_panel="Caching", ), diff --git a/tests/formatter/__init__.py b/tests/formatter/__init__.py index d434bae1e..7f4573316 100644 --- a/tests/formatter/__init__.py +++ b/tests/formatter/__init__.py @@ -99,7 +99,7 @@ def run_tidy( overwrite=True, check=not_modified, output=output_path, - no_cache=True, + cache=False, **kwargs, ) if exit_code is not None: diff --git a/tests/linter/utils/__init__.py b/tests/linter/utils/__init__.py index 18a6d9d5f..f4f07e4b1 100644 --- a/tests/linter/utils/__init__.py +++ b/tests/linter/utils/__init__.py @@ -113,7 +113,7 @@ def check_rule( # noqa: PLR0915 test_fn = check_project else: test_fn = check_files - kwargs["no_cache"] = True + kwargs["cache"] = False test_data = test_dir or self.test_class_dir sort_lines = output_format == "simple" issue_format = self.get_issue_format(issue_format) diff --git a/tests/performance/generate_reports.py b/tests/performance/generate_reports.py index c1384fe5b..0adf97f40 100644 --- a/tests/performance/generate_reports.py +++ b/tests/performance/generate_reports.py @@ -95,9 +95,7 @@ def formatter_report(formatter: str, report_name: str, cache: bool = True) -> in main_dir = Path(__file__).parent.parent.parent formatter_dir = main_dir / "tests" / "formatter" / "formatters" / formatter with working_directory(formatter_dir): - format_files( - ["source"], select=[formatter], overwrite=False, return_result=True, silent=True, no_cache=not cache - ) + format_files(["source"], select=[formatter], overwrite=False, return_result=True, silent=True, cache=cache) source_dir = formatter_dir / "source" return len(list(source_dir.iterdir())) @@ -114,7 +112,7 @@ def linter_report(report_name: str, **kwargs) -> int: # noqa: ARG001 @performance_report(runs=2) def lint_large_file(report_name: str, lint_dir: Path, **kwargs) -> int: # noqa: ARG001 with working_directory(lint_dir): - check_files(return_result=True, select=["ALL"], no_cache=True, **kwargs) + check_files(return_result=True, select=["ALL"], cache=False, **kwargs) return 1 @@ -142,10 +140,10 @@ def generate_large_file(template_path: Path, output_dir: Path) -> None: # So we can generate reports for multiple past versions. It is important since the actual seconds change depending # on where we run the script from, but the % change between version should be comparable. Also we can use new tests # on old versions - linter_report(report_name="with_print_cache", no_cache=False) - linter_report(report_name="with_print_no_cache", no_cache=True) - linter_report(report_name="without_print_cache", silent=True, no_cache=False) - linter_report(report_name="without_print_no_cache", silent=True, no_cache=True) + linter_report(report_name="with_print_cache", cache=True) + linter_report(report_name="with_print_no_cache", cache=False) + linter_report(report_name="without_print_cache", silent=True, cache=True) + linter_report(report_name="without_print_no_cache", silent=True, cache=False) for formatter in FORMATTERS: formatter_report(formatter=formatter, report_name=formatter) formatter_report(formatter=formatter, report_name=f"{formatter}_no_cache", cache=False) diff --git a/tests/test_cli.py b/tests/test_cli.py index 42c0489cb..ccebe3fba 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -124,6 +124,7 @@ def test_reports_with_silent(self, tmp_path): ], ) def test_check_exit_code(self, check, will_format, expected_exit_code): + # Arrange test_data = Path(__file__).parent / "formatter" / "formatters" / "NormalizeSeparators" if will_format: test_data = test_data / "source" @@ -132,8 +133,10 @@ def test_check_exit_code(self, check, will_format, expected_exit_code): command = ["format", "--select", "NormalizeSeparators", "--no-overwrite", "--no-cache"] if check: command += ["--check"] + # Act with working_directory(test_data): result = CliRunner().invoke(app, [*command, "test.robot"]) + # Assert assert result.exit_code == expected_exit_code @pytest.mark.parametrize(