Skip to content

Commit 9cbd073

Browse files
committed
test: fix tests with --no-cache
1 parent b31a5ef commit 9cbd073

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/robocop/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def list_commands(self, ctx: typer.Context) -> list[str]: # noqa: ARG002
147147
cache_option = Annotated[
148148
bool,
149149
typer.Option(
150-
"--cache",
150+
"--cache/--no-cache",
151151
help="Disable file caching. All files will be processed regardless of modifications.",
152152
rich_help_panel="Caching",
153153
),

tests/formatter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def run_tidy(
9999
overwrite=True,
100100
check=not_modified,
101101
output=output_path,
102-
no_cache=True,
102+
cache=False,
103103
**kwargs,
104104
)
105105
if exit_code is not None:

tests/linter/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def check_rule( # noqa: PLR0915
113113
test_fn = check_project
114114
else:
115115
test_fn = check_files
116-
kwargs["no_cache"] = True
116+
kwargs["cache"] = False
117117
test_data = test_dir or self.test_class_dir
118118
sort_lines = output_format == "simple"
119119
issue_format = self.get_issue_format(issue_format)

tests/performance/generate_reports.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ def formatter_report(formatter: str, report_name: str, cache: bool = True) -> in
9595
main_dir = Path(__file__).parent.parent.parent
9696
formatter_dir = main_dir / "tests" / "formatter" / "formatters" / formatter
9797
with working_directory(formatter_dir):
98-
format_files(
99-
["source"], select=[formatter], overwrite=False, return_result=True, silent=True, no_cache=not cache
100-
)
98+
format_files(["source"], select=[formatter], overwrite=False, return_result=True, silent=True, cache=cache)
10199
source_dir = formatter_dir / "source"
102100
return len(list(source_dir.iterdir()))
103101

@@ -114,7 +112,7 @@ def linter_report(report_name: str, **kwargs) -> int: # noqa: ARG001
114112
@performance_report(runs=2)
115113
def lint_large_file(report_name: str, lint_dir: Path, **kwargs) -> int: # noqa: ARG001
116114
with working_directory(lint_dir):
117-
check_files(return_result=True, select=["ALL"], no_cache=True, **kwargs)
115+
check_files(return_result=True, select=["ALL"], cache=False, **kwargs)
118116
return 1
119117

120118

@@ -142,10 +140,10 @@ def generate_large_file(template_path: Path, output_dir: Path) -> None:
142140
# So we can generate reports for multiple past versions. It is important since the actual seconds change depending
143141
# on where we run the script from, but the % change between version should be comparable. Also we can use new tests
144142
# on old versions
145-
linter_report(report_name="with_print_cache", no_cache=False)
146-
linter_report(report_name="with_print_no_cache", no_cache=True)
147-
linter_report(report_name="without_print_cache", silent=True, no_cache=False)
148-
linter_report(report_name="without_print_no_cache", silent=True, no_cache=True)
143+
linter_report(report_name="with_print_cache", cache=True)
144+
linter_report(report_name="with_print_no_cache", cache=False)
145+
linter_report(report_name="without_print_cache", silent=True, cache=True)
146+
linter_report(report_name="without_print_no_cache", silent=True, cache=False)
149147
for formatter in FORMATTERS:
150148
formatter_report(formatter=formatter, report_name=formatter)
151149
formatter_report(formatter=formatter, report_name=f"{formatter}_no_cache", cache=False)

tests/test_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_reports_with_silent(self, tmp_path):
124124
],
125125
)
126126
def test_check_exit_code(self, check, will_format, expected_exit_code):
127+
# Arrange
127128
test_data = Path(__file__).parent / "formatter" / "formatters" / "NormalizeSeparators"
128129
if will_format:
129130
test_data = test_data / "source"
@@ -132,8 +133,10 @@ def test_check_exit_code(self, check, will_format, expected_exit_code):
132133
command = ["format", "--select", "NormalizeSeparators", "--no-overwrite", "--no-cache"]
133134
if check:
134135
command += ["--check"]
136+
# Act
135137
with working_directory(test_data):
136138
result = CliRunner().invoke(app, [*command, "test.robot"])
139+
# Assert
137140
assert result.exit_code == expected_exit_code
138141

139142
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)