Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and document behavior of sumfiles with duplicate entries #39

Merged
merged 2 commits into from
Mar 23, 2024

Conversation

ericcornelissen
Copy link
Collaborator

@ericcornelissen ericcornelissen commented Mar 21, 2024

Closes #32

Summary

Add explicitly the expected behavior when a sumfile contains duplicate entries and test for this as well. This also fixes a related bug in the line number for syntax errors.

@ericcornelissen ericcornelissen added bug Something isn't working enhancement New feature or request labels Mar 21, 2024
Add tests that verify the `ghasum update` and `ghasum verify` commands
both reject sumfiles with duplicate (non-header) entries. Additionally
test that `ghasum update -force` fixes duplicate (non-header) entries.
To support this change some test re-organization was in order. The pre-
existing "invalid sumfile" tests were specifically testing against a
sumfile with a syntax error, hence these have been renamed (given the
new tests are also for an "invalid sumfile").

Additionally, the implementation for sumfile parsing has been updated to
improve the error messages produced, which are asserted in the new and
changed tests. Similarly, the `SPECIFICATION.md` is updated to make
explicit that duplicate sumfile entries should be rejected.

As an aside, this uncovered a off-by-one bug in the line number formula
in the implementation for sumfile parsing and corresponding incorrectly
implemented unit test - both of which are fixed here.
Add tests that verify the `ghasum update` and `ghasum verify` commands
both reject sumfiles with duplicate headers. To support this change some
test re-organization was in order. The existing "Sumfile with ..." tests
were specifically testing against problems with (non-header) entries but
now there are (separate) tests for problems with headers and entries.
Also, duplicate headers are unit tested for regardless of the sumfile
version.

The behavior of `ghasum update -force` is not covered here because there
is currently no defined behavior for what `ghasum update` should do with
headers.

Additionally, the implementation for sumfile parsing has been updated to
improve the error messages produced, which are asserted in the new and
changed tests. Similarly, the `SPECIFICATION.md` is updated to make
explicit that duplicate headers in a sumfile should be rejected.

As an aside, this (also) uncovered a off-by-one bug in the line number
formula in the implementation for sumfile header parsing which is fixed
here as well.
@ericcornelissen ericcornelissen merged commit 9df42b0 into main Mar 23, 2024
10 checks passed
@ericcornelissen ericcornelissen deleted the 32-duplicate-sumfile-entries branch March 23, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define behavior for duplicate entries in sumfiles
1 participant