Conditionally compile gix-revision at_symbol fuzzed test #1434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows compilation to succeed when building tests on 32-bit Windows systems, and probably other 32-bit systems/builds.
This test function had been set as ignored in 32-bit builds with the
cfg_attr
attribute. But it was still compiled, and the compilation failed on systems where the literal 9223372036854775808 is too big forusize
.This was due to the implicit
#[deny(overflowing_literals)]
. While that could be conditionally suppressed for 32-bit builds, the test would not really be meaningful. So this leaves that diagnostic in place, and turns the conditional ignore into conditional compilation.Due to rust-lang/libz-sys#197, I ran the tests on the 32-but Windows 10 test system with:
At the current tip of
main
(1e79c5c), no test cases actually ran, due to this compile error:See this file in this gist for full output. With the change made here, the build succeeds; although some tests fail, all of them are able to build (and most pass). It seems to me that the failures, which this change does not cause, should be considered outside the scope of this PR. The output on the 32-bit test system after the change here can be seen in this other file in the gist.
It seems to me that the value of compiling this test function on 32-bit systems where it is ignored is fairly small, such that it would not justify weakening the compiler's diagnostics, adding an explicit conversion, or significant changes to the test code. Furthermore, I don't think this can be fixed by adding a suffix to change the type of the literal. The literal will be accepted if suffixed with
u64
, but then compilation still fails because the comparison cannot be performed.To decide whether the
#[test]
or#[cfg(...)]
attribute should appear first, I examined which style was more common in the codebase by counting matches of the regular expressions#\[test.+\n#\[cfg\(
and#\[cfg\(.+\n#\[test
. I did not include any style cleanup here, and I am not convinced the small number of cases where#[cfg(...)]
comes first are unintentional, but I went with the prevailing style.I don't know of a way to include the explanation as metadata when using
#[cfg(...)]
so I just made it a comment.