PE tests: read a synthetic import library so ImportLibrary is covered #268

Closed
SkippySteve wants to merge 1 commit from upstream-pr/268 into main
SkippySteve commented 2026-11-24 01:55:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T01:55:43Z.


crates/victory-pe/src/implib.rs (the reader behind victory lib-exports) had no tests. This adds two. Each builds an in-memory !<arch> archive of short-format import objects, so the tests need no SDK .lib and no game data and run on every host.

  • reads_short_imports_sorted_and_deduplicated: covers each name type: by name, no-prefix (_Prefixed → Prefixed), undecorated (_Stdcall@8 → Stdcall) and by ordinal. Each export keeps its code/data/const kind. The output is sorted. A repeat of an export under a different hint becomes one entry, because the hint is not part of the key. A member that is not a short import object is counted in other_members instead of being dropped.
  • rejects_what_is_not_an_archive: a file that is not an archive returns an error, and an empty archive has no imports.

This is a test-only change; no library code changes.

Testing on Linux:

  • cargo test -p victory-pe implib: 2 passed.
  • cargo clippy -p victory-pe --all-targets -- -D warnings: clean.
  • cargo fmt --check: clean.
  • cargo xtask policy: ok.

The other four image::tests failures under cargo test -p victory-pe on Linux already fail on main, because those tests parse the host test binary as a PE. #257 deals with them, and this PR does not touch them.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572834675 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/268). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T01:55:43Z. --- `crates/victory-pe/src/implib.rs` (the reader behind `victory lib-exports`) had no tests. This adds two. Each builds an in-memory `!<arch>` archive of short-format import objects, so the tests need no SDK `.lib` and no game data and run on every host. - **reads_short_imports_sorted_and_deduplicated**: covers each name type: by name, no-prefix (`_Prefixed` → `Prefixed`), undecorated (`_Stdcall@8` → `Stdcall`) and by ordinal. Each export keeps its code/data/const kind. The output is sorted. A repeat of an export under a different hint becomes one entry, because the hint is not part of the key. A member that is not a short import object is counted in `other_members` instead of being dropped. - **rejects_what_is_not_an_archive**: a file that is not an archive returns an error, and an empty archive has no imports. This is a test-only change; no library code changes. Testing on Linux: - `cargo test -p victory-pe implib`: 2 passed. - `cargo clippy -p victory-pe --all-targets -- -D warnings`: clean. - `cargo fmt --check`: clean. - `cargo xtask policy`: ok. The other four `image::tests` failures under `cargo test -p victory-pe` on Linux already fail on `main`, because those tests parse the host test binary as a PE. #257 deals with them, and this PR does not touch them.
upstream-sync closed this pull request 2026-11-24 06:52:08 +00:00
SkippySteve commented 2026-11-24 06:55:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T02:27:48Z.


superseded by #287 (combined PE/loader hermetic synthetic tests)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120168154 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/268#issuecomment-7120168154). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T02:27:48Z. --- superseded by #287 (combined PE/loader hermetic synthetic tests)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!268
No description provided.