Skip to content

Commit

Permalink
Merge pull request #15 from rstcheck/global-error-message
Browse files Browse the repository at this point in the history
Global error message at finish
  • Loading branch information
Cielquan committed May 30, 2022
2 parents ee35b8e + d7f5cc7 commit 68d12db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NOTE: please use them in this order.
- Add tox envs to test with sphinx v5.
- Wide version range for `sphinx` extra to include v5.
- Update `sphinx` `extlinks` config for v5.
- Print error message on non-zero exit code ([#15](https://github.com/rstcheck/rstcheck-core/pull/15))

## 1.0.1.post2 (2022-05-30)

Expand Down
1 change: 1 addition & 0 deletions src/rstcheck_core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def print_result(self, output_file: t.Optional[t.TextIO] = None) -> int:

print(message, file=output_file or sys.stderr)

print("Error! Issues detected.", file=output_file or sys.stderr)
return 1

def run(self) -> int: # pragma: no cover
Expand Down
13 changes: 13 additions & 0 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,19 @@ def test_success_message_on_success(capsys: pytest.CaptureFixture[str]) -> None:

assert "Success! No issues detected." in capsys.readouterr().out

@staticmethod
def test_error_message_on_error(
tmp_path: pathlib.Path, capsys: pytest.CaptureFixture[str]
) -> None:
"""Test error message is printed to stderr by default if errors are found."""
test_file = tmp_path / "nonexisting.rst"
init_config = config.RstcheckConfig()
_runner = runner.RstcheckMainRunner([test_file], init_config)

_runner.print_result() # act

assert "Error! Issues detected." in capsys.readouterr().err

@staticmethod
def test_success_message_print_to_file(tmp_path: pathlib.Path) -> None:
"""Test success message is printed to given file."""
Expand Down

0 comments on commit 68d12db

Please sign in to comment.