fix(builder): build-driver's tests pass on Windows: hard links, cache use marks, dev mod folders, send lock #2587
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2587
Loading…
Reference in a new issue
No description provided.
Delete branch "pmwork-personal/Longshot:fix/build-driver-windows-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
cargo test --locked -p build-driverfails on Windows onmain(CI runs these tests on Linux only; the Windows jobbuilds them,
--no-run): 8 failures onmain@d9fa80cd. For each one the cause was found and the side that was wrongwas fixed. At
97683bbe, build-driver's tests all passed on Windows; the current head has not been tested.The code was wrong on Windows (4 fixes):
build_core::fsx::same_filecompared canonical paths on Windows, so a file and itshard link counted as different files. On Windows, a build from a dump folder refused a game folder whose romfs an
older build had linked (
romfs_folder_theirs:folder::romfs_made_heretook the links for the player's own copy).It now compares the volume serial number and the 128-bit file id (
GetFileInformationByHandleEx,FileIdInfo;ReFS, as in a Dev Drive, needs all 128 bits). If the identity query fails or gives no serial or no id (zero), it compares the
paths, as before.
.usedmark kept its first time.storage::mark_usedwrote the empty mark again; on Windows thatleaves the file's time unchanged. To the cache's budget, the unpacked tree, the tools, a from-source Rust toolchain
and the shader caches looked unused since their first use, so over the budget a folder in daily use could go first
and be unpacked or made again. It now also sets the time (the write stays: on Unix it needs only write access, where
setting a time needs the file's owner, as in a cache shared by two users). The unpack (
sources.rs) andfrom-source's tools and Rust (
longshot-builder/src/from_source/) wrote the mark the same way and now callmark_used.;in its name.modhook::dev_mods_valueusedstd::env::join_paths, which refuses afolder with
:on Unix but puts a Windows folder with;in quotes. The game splitsLONGSHOT_DEV_MODSat eachseparator and reads no quotes, so such a folder is now refused on every OS (
docs/dev/reference/build.mdsays so)."access denied", not "already exists", so
perf::take_send_locksent without a lock every time. A directory at thelock's name now counts as "there", as on Unix, and the takeover clears it.
The test was wrong on Windows (4 tests):
channel::tests::profile_says_the_folder_and_the_known_keysandmodhook::tests::a_context_resolves_the_profile_and_its_gamewrote their scratch folder as
<crate>/../../../target/...and compared it with the folder the code gives backthrough
std::path::absolute, which drops the..on Windows (Unix keeps it). Both now usecrate::scratch,which spells the folder as
std::path::absolutedoes.perf::tests::one_sender_at_a_timemade the lock a directory over the running holder's lock file, which only theLinux-only takeover step had removed (os error 183). The file goes first; the test then showed the send lock bug
above.
read::tests::manifest_mods_are_found_and_ordered_as_the_game_does(#2607) made the modsAanda/inner. On acase-insensitive file system (Windows, macOS's default) those are one folder:
a/innerwent into the modA, whichthe code rightly does not look below. It is
ab/innernow, which keeps each order the test checks.Read first:
builder/crates/build-core/src/fsx.rs(same_file),builder/crates/build-core/src/sys.rs(file_id),builder/crates/build-driver/src/storage.rs(
mark_used),modhook.rs(dev_mods_value),perf.rs(lock_there).Commits: the test fixes, then two new checks that fail on Windows on
main(fsx::tests::a_hard_link_is_the_same_file_and_a_copy_is_not,storage::tests::a_use_marks_a_folder_and_a_file_now_each_time), then the fixes; thenmainmerged in (d9fa80cd) andthe manifest mods test.
Testing
Tested: Windows 11 (10.0.26300), Rust 1.99.1
x86_64-pc-windows-gnullvmwith llvm-mingw, each run through thePC's job queue in its own cargo target folder, no game:
cargo test --lockedd9fa80cd97683bbe-p build-driver-p build-core-p longshot-buildermain@ d9fa80cd's build-driver numbers are from5619426a: the two commits between them change nothing underbuilder/.)main@fd68f82c, before the merge), each failed for its bug:a_hard_link_is_the_same_file_and_a_copy_is_not("a hard link of it"),a_use_marks_a_folder_and_a_file_now_each_time(the
.usedmark "still a month old"),the_dev_mod_folders_are_joined_by_the_os_separator(/a;baccepted),one_sender_at_a_time(no lock written over the directory), and the existingromfs_made_hereandsame_filechecks in
folder.rsandread.rs.cargo fmt --checkandcargo clippy --locked -p build-core -p build-driver -p longshot-builder --all-targets -- -D warningson Windows @97683bbe: clean.tests/run_all.py(every game-free check, Windows, 16 at once, without--strict: the 52 skips need Linux tools) @97683bbe: 793 passed, 23 failed. 21 of the 23 also fail onmain@d9fa80cd, run alone:test_auto_handheld,test_bug_report,test_builder_channel(its C fixture is POSIX:fcntl,setenv),test_control_picture,test_coverage_run,test_crash_record,test_dev_ab(a Δ printed to a cp1252 console),test_dev_build,test_dev_migrate,test_float_add_subgroup,test_game_menu_mouse_buttons,test_input_movie,test_job_queue,test_oot_menu_mouse,test_pads_after_menu,test_parity_gates,test_perf_send(its C++ fixture has noorganized_game, on both),test_run_all_mingw,test_screensaver,test_switch_table,test_xinput_thread. Theother 2 read only
gpu/andtests/code, which this PR does not change, and pass alone here:test_fg_scale_sharpen, andtest_sampler_admission, whose "id concurrent" case fails at random onmaintoo.fd68f82cwith #2581's PE padding fix on top):longshot-builder(release) anddev.py packover the shared base:pack bd-wintests-wt: longshot.exe, longshot_vk.dll; 2 generated files, in 52 s. A dev pack marks no.usedfolders (it builds from the checkout, withits own store):
mark_usedis checked by the tests above,each_unpack_marks_its_folders_usedwith a real unpackinto a cache.
Still to test: The current head on Windows.
Linux is not run here: the Rust CI job (
cargo test --workspace) runs it. The Unix code paths change only indev_mods_value(the same refusal, a new message),mark_used(the time set, where the write already moved it) andlock_there(a directory counts as there, asAlreadyExistsalready said).Measurements
Nothing to measure: no change to the game, the build's output or its speed (
same_fileopens each file once, ascanonicalizedid).Risks
same_filedecides whetherlink_or_copyskips a file as already in place. A file system whose file ids are notunique would skip a copy; the id is the volume serial number with the 128-bit id, and a failed identity query or one that gives no
serial or no id (zero) falls back to the path, as before. Two volumes with one serial (a cloned disk) are the case
left, as two devices with one
st_devwould be on Unix.mark_usedwrites the mark as before and now sets its time too: on Linux the same result.;in its name is refused on Windows (it was passed on in quotes, which the game does notread). A revert undoes all of it. A player notices nothing after updating, except that the cache's budget keeps
the folders they use.
Checklist
Ready for review
main; the title is a Conventional Commit. (This PR combines four production fixes.)the builder's tests and checks, as Testing says.)
mise run testpasses (any failure that also fails onmainis named). (On Windows: each failure is named inTesting, with its result on
main.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (On Windows; Linux passes on both.)tests/that reads changed source is updated, not weakened. (None needed a change:test_log_redact,test_ngx_sdk,test_no_release_lookup,test_perf_report,test_prepare_journal,test_recomplauncher_json,test_ship_state_listandtest_longshot_exitpass;test_builder_channelandtest_dev_abfail onmaintoo, as Testing says.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
WIP: fix(builder): build-driver's tests pass on Windows: hard links, cache use marks, dev mod folders, send lockto fix(builder): build-driver's tests pass on Windows: hard links, cache use marks, dev mod folders, send lockPossibly related, for context:
d9fa80cd) into fix/build-driver-windows-tests 290b0d35d6Merged
main(d9fa80cd) into the branch. The PE padding test passes onmainsince #2581. One new test fails on Windows onmain:read::tests::manifest_mods_are_found_and_ordered_as_the_game_does(#2607). Its modsAanda/innerare one folder on a case-insensitive file system (Windows, macOS's default), so the test now usesab/inner, which keeps each order it checks.On Windows @
97683bbe:cargo test -p build-driver150 passed, 0 failed (main: 141 passed, 8 failed); build-core 34 passed; longshot-builder the same 7 failures asmain; fmt and clippy clean. The description has the new numbers and the suite's results againstmain.The first CI run failed in 0 to 1 s in every job: the runner could not pull the CI image (its registry answered HTTP to an HTTPS request). This push runs CI again.
@review
Recommendation: Request changes. The Windows fixes have test evidence, but the change adds unsafe code outside the repository’s permitted locations and combines unrelated fixes that the project requires to be separate.
The change fixes Windows file identity, cache-use timestamps, dev-mod path handling and stale send-lock recovery, and repairs several platform-sensitive tests. These fixes improve builder behavior, at the cost of broadening this pull request across unrelated causes.
Blocking (1): must change before merging.
builder/crates/build-core/src/fsx.rs:61: This adds an unsafe Windows API call outside the locations permitted by the builder’s code rules. (more on the line) Do: Move the Windows file identity system call into the permitted sys.rs Windows module and expose a safe wrapper to fsx.rs.Should fix (1): not blocking, but worth doing before merging.
@fixcan do L1 and L2.Checks: Failing on this head, which is behind its base, where it passes:
CI / Third-party parts and guide screenshots (pull_request).@rebase(or@fix) brings it up to date and runs it again; not held against it. Still running: 7 checks.More: does it help, other systems, switches, what was read
Does it help: Yes. The author reports build-driver tests changing from 141 passed and 8 failed on the base to 150 passed and 0 failed on Windows at HEAD; the targeted fix tests also failed for their respective bugs before the fixes. This is not a game performance change.
Other systems: The file identity check also affects linking or copying build files and compiler toolchain identification. Cache marks affect sources, tools, Rust, runtimes and shader caches on Windows and Linux; the author reports Windows tests, while Linux CI is still running. The dev-mod and send-lock paths do not affect GPU rendering.
Switches: None added, changed or removed.
Reviewed:
97683bbeadagainstd9fa80cd12: Read the repository rules, PR template, standards, diff and commit messages; inspected the changed functions, their tests and relevant callers. Large changed files and their unrelated tests were skimmed rather than read in full; Tooling’s AGENTS.md was unavailable in the checkout. No generated files or recorded game runs were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code or tests were run. The author reports Windows test results; the supplied CI status shows checks still running.
Overlaps and merge order: Not determined; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -49,0 +58,4 @@/// The file at `p`'s volume serial and file id (links followed, as `fs::metadata` does); none when it can't be read,/// or the file system fills in no serial or no id (zero: files of two such volumes, or two files, would be one).#[cfg(windows)]#[allow(unsafe_code)]L1 (blocking): This adds an unsafe Windows API call outside the locations permitted by the builder’s code rules.
When: The new file identity query opts out of the workspace’s unsafe-code restriction in fsx.rs, while docs/dev/standards.md permits builder unsafe code only in build-core’s sys.rs Windows module and game-files’ disk system calls.
Do: Move the Windows file identity system call into the permitted sys.rs Windows module and expose a safe wrapper to fsx.rs.
@fix
Recommendation: Approve. The pull request still combines four unrelated production fixes, contrary to the repository’s one-topic rule. Moving the Windows identity query preserves its behavior but does not address that issue. Nothing blocking is left. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
b1fb288972. I mergedmain(a845154d34) into it, as it has merge commits. I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The builder fixes hard-link detection, cache-use marks, developer mod paths and stale send locks on Windows. They address separate problems and should be reviewed and merged separately.
Should fix (1): not blocking, but worth doing before merging.
@fixcan do L2.Checks: they run again on this head (
CI / Third-party parts and guide screenshots (pull_request)failed on the last one); a failure shows on the pull request.Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on the current head. The author reports 150 build-driver tests passing on Windows at
97683bbe, compared with 141 passing and 8 failing on the base; the subsequent file-identity move has not been tested.Other systems: The identity query is Windows-only; its safe wrapper preserves the previous query and path fallback. Linux retains its existing identity comparison. The current-head Windows and CI results are pending.
Switches: The fix adds or changes no switches. The base-to-HEAD diff also contains RX_VK_FG_GAME_CLOCK, default on, from a merged main change; its default and measurements were not assessed in this re-check.
Reviewed:
b1fb288972againsta845154d34: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the file-identity fix and its surrounding code, and the builder diff. Skimmed the remaining base-to-HEAD diff and recorded test results; not all changed files were read in full. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author’s Windows results are for
97683bbe; CI has not run on the current head.Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.