Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ The Gradle wrapper lives inside `de.peeeq.wurstscript/` (not the repo root); run
* The test JVMs run ParallelGC (`-PtestGc='-XX:+UseG1GC'` or another flag overrides it): G1 spent 9-11% of a serial run in pauses, mostly mixed collections of data which lives for one test, and ParallelGC about 3%.
* Tests fetch the pinned stdlib first (`ensureStdLib`, about a minute on a fresh checkout). `InitialBuildProgressTest` and `LanguageWorkerTest` are in package `de.peeeq.wurstio.languageserver`, so a `--tests` filter needs that prefix.

### Cross-OS responsibility

PR CI deliberately runs only Ubuntu to keep feedback cheap; master tests Windows and both macOS architectures too.
**A green Ubuntu PR is not evidence of cross-OS compatibility.** Before finishing a change, inspect the changed code
and tests for host assumptions, run focused checks on the available host, and report which relevant platforms remain
unverified. Keep PR CI slim; do not expand its matrix or add full builds to compensate for missing portability work.
Read [`docs/CROSS_OS_FOOTGUNS.md`](docs/CROSS_OS_FOOTGUNS.md) when changing filesystem assertions, process execution,
tool discovery, map-build fixtures, or runtime packaging. Regressions have repeatedly escaped through those paths.

* Compare existing file identity with `Files.isSameFile`, not `File.equals` or path strings. Windows temp paths can
use `RUNNER~1` while `WFile` canonicalises them to `runneradmin`; `Path.normalize()` does not resolve that alias.
Exercise an alias such as `./` in the repro so Linux can catch a spelling-dependent assertion too.
* Use path APIs, explicit text encodings, and argument lists for subprocesses. Account for CRLF, executable suffixes,
executable bits, case sensitivity, open-file locks, and subprocess cleanup where the changed code depends on them.
* Compile-only tests must not discover an installed game or open a folder chooser. Override discovery and fail if it
is reached; Linux's lack of a dialog does not prove that Windows/macOS cannot hang.
* Verify tools and runtime images on their actual OS/architecture: JDK vendors, CDS archives, Lua executables and
native-library dependencies differ. Inspect the produced image, not just the build JVM or a passing compiler test.

### Runtime-executing tests

* `test().executeProg()` runs the compiled program in the interpreter and requires a `testSuccess()` call.
Expand Down Expand Up @@ -162,8 +181,8 @@ runtime's own base archive, which `deploy.gradle` makes (`jlink --generate-cds-a
usually has one, and `assembleSlimCompilerDist` dumps one with `java -Xshare:dump` when the JDK has none: the Temurin
for macOS x64 on CI does not). `assembleSlimCompilerDist` then starts the runtime with `-Xshare:on`, which fails when
there is no usable archive. Without one the JVM silently runs without any, which is how the earlier attempt went
unnoticed. Pull-request CI packages nothing (only pushes to master do, on every host), so a change here is not tested
on macOS before it merges. Java 27 enables compact object headers by default. The build clears the JVM option
unnoticed. Pull-request CI packages nothing; the versioned release workflow packages every supported host, so a change
here is not tested on macOS before it merges. Java 27 enables compact object headers by default. The build clears the JVM option
environment variables when making and validating the base archive so it matches the shipped runtime defaults.
The extension passes `-Xlog:disable` because the JVM reports archive trouble on stdout, which is the protocol stream:
never print anything of your own there.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ native createObjectDefinition(string fileType, int newUnitId, int deriveFrom) re
}
};
File published = new File((String) command.execute(project.manager));
assertEquals(published, new File(project.root, "_build/wurstCreatedObjects.w3o"));
// Exercise an aliased path on every host, like Windows' short temp-directory names.
File expected = new File(project.root, "./_build/wurstCreatedObjects.w3o");
assertTrue(Files.isSameFile(published.toPath(), expected.toPath()), "Export must publish to the build directory");
assertEquals(Files.readAllBytes(published.toPath()), Files.readAllBytes(generated.toPath()));
}

Expand Down
54 changes: 54 additions & 0 deletions docs/CROSS_OS_FOOTGUNS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Cross-OS footguns

PR CI intentionally runs Ubuntu only. Master runs compiler tests on Windows x64, Linux x64, macOS arm64 and
macOS x64; the versioned release workflow also packages those hosts. Keep that inexpensive PR loop. Agents own
portability in both production code and tests: inspect the affected host boundaries, construct a focused regression
that exposes the assumption, run the relevant test class, and state any platform-specific validation still missing.
One passing host is not a completed portability review.

## File identity is not path spelling

[The object-export master failure](https://github.com/wurstscript/WurstScript/actions/runs/38700366418)
was a test assertion, not a failed export. Windows created a temp path under `C:\Users\RUNNER~1`; `WFile.create`
canonicalised it to `C:\Users\runneradmin`. `File.equals` compares the path spelling, so it rejected the correct
output file. Content assertions had already passed.

Use `Files.isSameFile(actual, expected)` for existing files. For a contract about canonical paths, canonicalise both
sides explicitly. `toAbsolutePath()` and `normalize()` do not resolve short names or symbolic links. Include `./`
in an expected path to make a spelling-dependent identity assertion fail on every host, without requiring Windows
short-name support or privileges to create symlinks. Keep assertions about exact user-visible spelling separate
from assertions about which file was written.

Build paths with `Path.resolve` or `File` constructors. Check case sensitivity, spaces and non-ASCII characters
when filenames enter a parser or subprocess. Close files and archives before replacing or deleting them: a successful
unlink on Unix does not establish that Windows can replace an open file.

## A compile-only test must never launch installation discovery

[The map-model fixture fix](https://github.com/wurstscript/WurstScript/pull/1461) prevents tests from opening
Warcraft folder choosers on Windows/macOS runners. A runner has no game installation, and a modal chooser can
hang until the job times out. Supply the fixture's installation/discovery boundary explicitly; install throwing
`WinGameExeFinder` and `MacGameExeFinder` services when testing that discovery cannot occur, and restore them in
`finally`. See `MapModelReuseTests.runProbeDoesNotDiscoverAnInstalledGame`. Timeouts bound damage but do not fix
an unintended interactive call.

## Test tools and packaged runtimes differ by host

The [Intel macOS packaging failure](https://github.com/wurstscript/WurstScript/actions/runs/37778085905)
is one example of a host-specific runtime problem. See `deploy.gradle` and AGENTS.md's startup-archive notes:
macOS copies a signed full JDK, other hosts use jlink, and a copied JDK need not contain a base CDS archive.
Generate one when absent and verify the shipped runtime with `-Xshare:on`. Check the actual runtime image, and
clear JVM option environment variables when generating/validating its archive. JDK availability also differs:
the workflows use Zulu for Java 27 on Intel macOS.

The checked-in Linux Lua fallback needs `libreadline.so.6`, absent on current Ubuntu images. CI installs Lua 5.3
instead. Windows uses bundled `.exe` tools; macOS installs Homebrew Lua, whose version is not pinned to 5.3.
Never assume that a command in PATH, a checked-in binary, or a successful Lua run means another host has the same
interpreter, shared libraries, permissions or arithmetic. Inspect `WurstScriptTest` discovery and the runtime notes
before changing these assumptions.

When changing process execution, pass arguments individually and check exit status. Specify text encodings and
handle CRLF at text-protocol boundaries; the release workflow already strips Java's trailing Windows carriage
return before comparing its version. Preserve executable permissions where required, account for `.exe`/`.cmd`,
and reap subprocesses on cancellation. Run a focused packaging check for packaging changes, rather than treating
an Ubuntu compiler test as validation of a macOS or Windows distribution.
Loading