Testing & fixtures

Physical machines actually stitch the files this tool produces. Every reader and writer is therefore covered by round-trip tests against real fixtures, with pyembroidery as an independent external oracle. Building the core without green tests is not an option.

What's in fixtures/

FileRole
001s-A.vip / 001s-A.zhsGround-truth VIP↔ZHS pair (single color).
028-B.vip / 028-B.zhsThe gem: byte-identical round-trip except 0x83.
052-Z.vipThird VIP with no ZHS twin — good for "open & verify".
zhs-samples/SHE2215A_003.zhsMulticolor factory sample (6 colors / 10 blocks / 9302 stitches + .pes twin).
lobster.pes / octopus.dst / octopus.pes / unicorn-6x10.jefFixtures for the other formats' tests.

Safety: these are benign binary files (stitch geometry + thread colors). No executables, no macros, nothing sensitive. Open them, hex-dump them, decompress them, run code against every one: it is normal, expected, required work.

Golden Path

Every reader has a golden path generated with Python scripts (packages/core/scripts/gen_format_golden.py, gen_hus_golden.py, gen_readonly_golden.py, gen_vip_table.py) using pyembroidery as the oracle. The resulting JSON files live in packages/core/test/golden/ and represent the Pattern exactly as pyembroidery reads it from the real fixture. The TS tests:

  1. read the fixture,
  2. run read(bytes) with our reader,
  3. compare against the golden.

Equal stitch-for-stitch, equal threads. If pyembroidery changes, we regenerate.

Byte round-trip

For writers where the format is fully known (ZHS, XXX):

expect(write(read(sample), settings)).toEqual(sample)
//  ZHS: except the known word at 0x83, explicit assert on that diff

For the others (HUS, VIP, VP3, PEC, PES, DST, JEF, EXP) where pyembroidery can read them back: read-back. We write with our writer, read the result back with pyembroidery, and compare the resulting path against the original fixture's path — equal up to zero-length duplicates and 0.1 mm rounding.

Suite

Verifying everything from scratch

pip install pyembroidery --break-system-packages
python3 reference/zhs_vip_reference.py verify fixtures/028-B.vip fixtures/028-B.zhs
# expect: functional path match: True
#         byte-identical: False | diffs at ['0x83'] | len 764 vs 764

The TS core replicates the same checks with Vitest, with exactly the same result.

← EmbCompress Privacy →