Skip to content

Commit

Permalink
Add info message for skipped verifications
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1723
  • Loading branch information
treiher committed Jul 9, 2024
1 parent a9d7c65 commit 5acacd6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Support for FSF GNAT 14.1 (eng/recordflux/RecordFlux#1679)
- CLI flag `--legacy-errors` to restore previous error message format (eng/recordflux/RecordFlux#1685)
- Info message for skipped verifications (eng/recordflux/RecordFlux#1723)

### Changed

Expand Down
8 changes: 8 additions & 0 deletions rflx/model/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def __init__(self, file: Path = DEFAULT_FILE) -> None:

self._load_cache()

@property
def is_verified_reason(self) -> str:
return "cached"

def is_verified(self, digest: Digest) -> bool:
return digest.key in self._verified and digest.value in self._verified[digest.key]

Expand Down Expand Up @@ -161,6 +165,10 @@ def is_verified(self, digest: Digest) -> bool: # noqa: ARG002
def add_verified(self, digest: Digest) -> None:
pass

@property
def is_verified_reason(self) -> str:
return "verification disabled"


class Digest:
def __init__(self, declaration: TopLevelDeclaration) -> None:
Expand Down
5 changes: 5 additions & 0 deletions rflx/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def checked(
unverified = d.checked(declarations, skip_verification=True)
digest = Digest(unverified)
if cache.is_verified(digest):
logging.info(
"Skipping verification of {identifier} ({reason})",
identifier=d.identifier,
reason=cache.is_verified_reason,
)
checked = unverified
else:
logging.info("Verifying {identifier}", identifier=d.identifier)
Expand Down
7 changes: 7 additions & 0 deletions tests/end_to_end/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def test_check_no_verification() -> None:
warning: model verification skipped
info: Parsing tests/data/specs/ethernet.rflx
info: Processing Ethernet
info: Skipping verification of __BUILTINS__::Boolean (verification disabled)
info: Skipping verification of __INTERNAL__::Opaque (verification disabled)
info: Skipping verification of Ethernet::Address (verification disabled)
info: Skipping verification of Ethernet::Type_Length (verification disabled)
info: Skipping verification of Ethernet::TPID (verification disabled)
info: Skipping verification of Ethernet::TCI (verification disabled)
info: Skipping verification of Ethernet::Frame (verification disabled)
""",
)

Expand Down

0 comments on commit 5acacd6

Please sign in to comment.