Skip to content

Run the unit tests on Windows - #13

Draft
joshyunho wants to merge 1 commit into
mainfrom
foldersync/windows-unit-tests
Draft

joshyunho wants to merge 1 commit into
mainfrom
foldersync/windows-unit-tests

Conversation

@joshyunho

Copy link
Copy Markdown
Collaborator

Summary

Before

On Windows 11, 15 unit tests and 2 Go tests failed, and npm run build:tokenserver wrote out/tokenserver with no .exe, which Windows won't run.

After

  • The token server builds as tokenserver.exe on Windows (go build -o ../out/), and start.mjs looks for that name.
  • Hashing and uploading a local file use openNoFollow. Windows has no O_NOFOLLOW, so reading went through symlinks there. openNoFollow refuses a symlink, and after opening checks that the path is still the same file and not a symlink.
  • Tests that need chmod to block access skip where it can't (Windows, or as root), found by a probe in test/fsSupport.ts. Tests that need FIFOs, POSIX file modes, or renaming a folder whose sync database is open skip on Windows. Each skip gives its reason.
  • Tests that assumed / paths use the platform's separator, in TypeScript and Go.

One test, "waits for running transfers and skips queued ones when an action throws", still fails now and then on Windows. It fails on main too. Windows file times change only about every 15 ms, so a same-size edit right after a sync can look unchanged. That's a sync bug to fix separately, so this PR leaves the test alone.

Test plan

  • macOS: npm test, 298 passed. Lint, format, typecheck, and go test pass.
  • Windows 11: lint, format, typecheck, go vet, and go test pass. Unit tests: 284 passed and 14 skipped in two of three runs. The third failed only the test above.
  • Ubuntu 24.04: all unit tests pass except the case-rename test that Write to the renamed folder's new name in the case-rename test #12 fixes.
  • The new openNoFollow tests fail when their checks are removed: on macOS for each, and on Windows for the symlink swap.

The token server builds as tokenserver.exe on Windows, and start.mjs looks
for it there. Reading a local file no longer follows a symlink on Windows,
which has no O_NOFOLLOW: openNoFollow checks that the file opened is the one
lstat saw, and that the path wasn't replaced by another file or a symlink.

Tests that need chmod to block access skip where it can't. Tests that need
FIFOs, POSIX modes, or renaming a folder with an open file skip on Windows.
Each says why. Path checks use the platform's separator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant