Files
OrcaSlicer/tests
Lam Wei Lun 45a29d391b Fix Full Publish variant layout and project round trip (#17014)
* fix: keep a Full Publish copy's variant vectors and list in step

A published Full entry clones the receiver's filament preset and overlays
the author's values, but the copy's variant list was rewritten to the
author's columns even when a variant-bearing key could not be filled from
the file. That key kept the receiver's width while every reader sizes the
layout from the list, so one variant silently read another variant's
value.

Copy a variant key only when the file carries all of the author's
columns, then drop any remaining variant key whose length disagrees with
the author's column count, and set the list last. filament_extruder_variant
is itself a member of filament_options_with_variant and is skipped by that
cleanup. The layout joins the entry's dedup key, so two entries naming one
preset but carrying different variants cannot share a copy.

A Full copy is detached and parentless, which also meant it never reached
the receiver's saved project: get_preset_differed_for_save stored no diff
without a parent, and load_project_embedded_presets dropped a preset whose
inherits did not resolve. Embed a parentless preset with its whole config
and resolve it over the default preset on load, mirroring the custom-root
branch of the user-preset loader. A preset naming a missing parent is
still dropped.

Tests: a Full copy drops a variant key the file cannot fill; a parentless
project-embedded preset keeps its own variants on reload.

* fix: stop relabelling and truncating published filament variants

Review of the previous commit found three paths that still let a Full
Publish copy or a loaded preset describe variants its vectors do not
hold.

set_num_filaments resizes every key in m_filament_option_keys to the
filament count, and two of those keys (filament_retract_length_nc and
volumetric_speed_coefficients) are variant-bearing. Loading a
multi-variant preset, including a saved Full copy, truncated them to the
first variant, which readers then hid by clamping. Skip variant-bearing
keys there, as Preset::normalize's own pass already does.

A variant key the file did not carry was kept whenever its width matched
the author's column count, then relabelled with the author's variant
names. When the receiver lists the variants in another order, that puts
one variant's value under another's name. Keep the key only when the
receiver's list is the same layout, or it holds a single value; otherwise
drop it and report it in skipped_keys.

An imported material key that names a file column but is per-slot in this
build was read positionally, returning another slot's column. Skip and
report it instead.

Also narrow the parentless project-embedded preset path to a filament
preset that carries a variant layout, and keep a failed apply from
aborting the whole project load.

* test: store filament_retract_length_nc as the nullable option it is

The filament count test set the key through the non-nullable accessor.
The option's default is ConfigOptionFloatsNullable although the
definition says coFloats, so the value was written through the wrong
dynamic type and the later lookup returned null. Use the nullable
accessor and assert the lookups succeed instead of dereferencing blindly.
2026-10-29 13:37:23 +08:00
..
2025-12-08 22:42:11 +08:00

OrcaSlicer tests

Building, running and writing tests is documented on the wiki, under How to Test.

Two files here rather than there, because coding agents only read what is in the repository:

  • AGENTS.md is the same guidance in short form, and is what an agent working under tests/ picks up.
  • CATCH2.md is the Catch2 reference, including the mistakes that break a test at runtime.