Skip to content

Commit

Permalink
Fix error reporting in CLI
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1530
  • Loading branch information
treiher committed Feb 12, 2024
1 parent e34f8c7 commit 65f163c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ test_language_coverage:
timeout -k 60 7200 $(PYTEST) --cov=rflx/lang --cov-branch --cov-fail-under=73.8 --cov-report=term-missing:skip-covered tests/language

test_end_to_end:
$(PYTEST) tests/end-to-end
$(PYTEST) tests/end_to_end

test_property:
$(PYTEST) tests/property
Expand Down
4 changes: 2 additions & 2 deletions rflx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def __call__( # type: ignore [no-untyped-def]
setattr(namespace, self.dest, values)


def run() -> None:
main(sys.argv)
def run() -> Union[int, str]:
return main(sys.argv)


def main( # noqa: PLR0915
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The executability and provability tests require the definition of a session call

Session functions can be defined by putting a custom implementation of the `Session` package inside the `src` directory.

### End-to-End Tests (`tests/end-to-end`)
### End-to-End Tests (`tests/end_to_end`)

End-to-end tests verify the functionality of the entire application. These tests ensure that the application behaves as intended, particularly focusing on its primary use cases.

Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions tests/end-to-end/cli_test.py → tests/end_to_end/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ def test_check() -> None:
)


def test_check_error() -> None:
p = subprocess.run(
["rflx", "--no-caching", "check", SPEC_DIR / "invalid" / "incorrect_name.rflx"],
capture_output=True,
)
assert p.returncode == 1
assert p.stdout.decode("utf-8") == ""
assert p.stderr.decode("utf-8") == textwrap.dedent(
"""\
Parsing tests/data/specs/invalid/incorrect_name.rflx
Processing Test
Verifying __BUILTINS__::Boolean
Verifying __INTERNAL__::Opaque
tests/data/specs/invalid/incorrect_name.rflx:1:9: parser: error: file name does not match\
unit name "Test", should be "test.rflx"
""",
)


def test_check_no_verification() -> None:
p = subprocess.run(
[
Expand Down

0 comments on commit 65f163c

Please sign in to comment.