Fix APT CLI roundtrip visual and script preservation

Preserve edittext channels, alpha/color transforms, inactive placement fields,
zero ratio/clipping and null ClipAction presence. Keep unlabelled flag bits,
quoted/escaped script strings, export declarations and correctly typed CONST
and pushdata values. Validate signed integers and write byte-aligned UTF-8.

Add 23 public CLI regressions and record the native 174-resource batch plus
bounded retests: four discovered pages are repaired, while the sound placeholder
and native float formatting remain explicit accuracy limits. Rebuild the 1.0.1
Windows executable and leave unrelated SDK changes untouched.
This commit is contained in:
2026-10-13 02:40:37 +02:00
parent 5511354783
commit e0b8dedc04
18 changed files with 5111 additions and 115 deletions
+16
View File
@@ -0,0 +1,16 @@
# Public CLI regression tests
Run `npm test` from `ra3apt-cli/` after installing the normal dependencies. All 23 tests invoke the real `bin/ra3apt.js` dispatcher and public expand/build paths in child Node processes. They exercise production XML transformation, assembly parsing, constant pooling and CONST writing. Private conversion functions are not exposed or mocked.
`fake-cc3tools.cjs` intercepts only the two external converter calls. It transports raw XML in an unmistakable `RA3_CLI_TEST_RAW_XML_ENVELOPE` file and refuses real APT binaries. It performs no flags, color, string, numeric, ID or XML transformation and does not generate CONST files. Its outputs are simulated envelopes, not game resources. Real cc3tools compatibility and game behavior require separate validation.
- `visual-state.test.cjs`: six tests covering an active null clip-action pointer without creating an array, actual height/RGB/translation edits, unrelated fields, transparent/dim/additive transforms, Move-only placement, active zero ratio, clipdepth and nonidentity matrices.
- `supported-bytecode.test.cjs`: three tests covering fractional pushfloat, numeric-looking strings versus integers, and correctly typed pushdata/global CONST references.
- `parser-contract.test.cjs`: fourteen tests covering converter-unimplemented character rejection and unlabelled flag bits, quotes, backslashes, commas, ampersands, entity-looking text, LF/CR, inherited-object-key names, UTF-8 byte lengths/pointers, signed type-7 constants, fractional/overflow rejection, export declarations, literal CDATA delimiters and manifest ampersands.
- `public-cli-helper.cjs` and `visual-state.raw.xml`: process isolation and independent raw XML/CONST assertions.
By default artifacts go into a unique child of `ra3apt-cli/.work/tests/`, which is Git-ignored. Set `RA3_CLI_TEST_ARTIFACT_ROOT` to direct all artifacts to a task-specific directory. TEMP/TMP/TMPDIR are bound inside that directory. Set `RA3_APT_CLI_ROOT` to test a different source checkout and `NODE_PATH` to reuse existing dependencies without copying them. Do not commit generated files or dependency copies.
All 23 tests passed on 2026-10-13. Assertions check edited and unrelated values, actual string/integer types, UTF-8 lengths, pointer alignment and relevant bit patterns; they permit legitimate constant-pool reordering. Fractional pool operands such as `pushconst 1.25` are rejected because existing type 7 is signed32; fractional values use `pushfloat`. UTF-8 tests prove stored bytes, not game font support.
The real converter emits many float32 fields to six decimal places. Equal expanded XML does not prove bit-exact preservation of the original float32 values. See the CLI README and roundtrip report for this limit and the separate native resource regression.