mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-10 17:21:10 +00:00
test: rely on upstream's tests for the variant truncation guard
Remove three update_non_diff_values_to_base_config scenarios that tested the truncation guard from upstream #13316. IMEX does not change that code, and upstream's own tests cover it: removing the guard fails #13316's test, and loosening it to `>=` fails #16107's. The equal-size scenario broke when #16107 changed how variants are matched, and the scalar-key scenario could not fail at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7fdfea6efa
commit
dbaec929bc
@@ -338,143 +338,6 @@ SCENARIO("DynamicPrintConfig serialization", "[Config]") {
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("update_non_diff_values_to_base_config does not truncate stride=2 child vectors when child has more extruders than parent",
|
||||
"[Config][Variant]") {
|
||||
GIVEN("A 2-extruder child with stride=2 machine limits inheriting from a 1-extruder parent") {
|
||||
// Stride=2 keys store (normal, silent) pairs per variant: a 2-extruder child has size 4,
|
||||
// a 1-extruder parent has size 2. The truncation guard must fire here too.
|
||||
Slic3r::DynamicPrintConfig child;
|
||||
Slic3r::DynamicPrintConfig parent;
|
||||
|
||||
child.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2}));
|
||||
child.set_key_value("printer_extruder_variant", new Slic3r::ConfigOptionStrings({"Direct Drive Standard", "Direct Drive Standard"}));
|
||||
child.set_key_value("machine_max_acceleration_x", new Slic3r::ConfigOptionFloats({500.0, 200.0, 600.0, 300.0}));
|
||||
|
||||
parent.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1}));
|
||||
parent.set_key_value("printer_extruder_variant", new Slic3r::ConfigOptionStrings({"Direct Drive Standard"}));
|
||||
parent.set_key_value("machine_max_acceleration_x", new Slic3r::ConfigOptionFloats({1000.0, 400.0}));
|
||||
|
||||
const Slic3r::t_config_option_keys keys = {
|
||||
"machine_max_acceleration_x", "printer_extruder_id", "printer_extruder_variant"
|
||||
};
|
||||
const std::set<std::string> different_keys = {
|
||||
"machine_max_acceleration_x", "printer_extruder_id", "printer_extruder_variant"
|
||||
};
|
||||
|
||||
WHEN("update_non_diff_values_to_base_config is called") {
|
||||
std::string id_name = "printer_extruder_id";
|
||||
std::string var_name = "printer_extruder_variant";
|
||||
child.update_non_diff_values_to_base_config(
|
||||
parent, keys, different_keys, id_name, var_name,
|
||||
Slic3r::printer_options_with_variant_1,
|
||||
Slic3r::printer_options_with_variant_2);
|
||||
|
||||
THEN("machine_max_acceleration_x retains size 4 (2 variants × 2 silent modes)") {
|
||||
REQUIRE(child.option<Slic3r::ConfigOptionFloats>("machine_max_acceleration_x")->values.size() == 4);
|
||||
}
|
||||
THEN("machine_max_acceleration_x preserves both extruders' normal and silent values") {
|
||||
auto* v = child.option<Slic3r::ConfigOptionFloats>("machine_max_acceleration_x");
|
||||
REQUIRE_THAT(v->values[0], Catch::Matchers::WithinAbs(500.0, 1e-9));
|
||||
REQUIRE_THAT(v->values[1], Catch::Matchers::WithinAbs(200.0, 1e-9));
|
||||
REQUIRE_THAT(v->values[2], Catch::Matchers::WithinAbs(600.0, 1e-9));
|
||||
REQUIRE_THAT(v->values[3], Catch::Matchers::WithinAbs(300.0, 1e-9));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("update_non_diff_values_to_base_config runs the merge path in the equal-size case",
|
||||
"[Config][Variant]") {
|
||||
// Distinguishes the fix's `cur > target` guard from a stricter `cur >= target`.
|
||||
// With `cur > target` (correct): equal-size does NOT fire the guard; merge runs via
|
||||
// set_with_restore, which builds variant_index by matching (extruder_variant, extruder_id)
|
||||
// pairs between child and parent. When the variants don't match, variant_index positions
|
||||
// stay at -1, and set_with_restore overwrites those child positions with parent values.
|
||||
// With `cur >= target` (regressed): guard fires; merge is skipped; child values stay intact.
|
||||
// Using mismatched variants makes the two outcomes observably different.
|
||||
GIVEN("A 2-extruder child and parent with matching extruder counts but mismatched variant names") {
|
||||
Slic3r::DynamicPrintConfig child;
|
||||
Slic3r::DynamicPrintConfig parent;
|
||||
|
||||
child.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2}));
|
||||
child.set_key_value("printer_extruder_variant", new Slic3r::ConfigOptionStrings({"Bowden Standard", "Bowden Standard"}));
|
||||
child.set_key_value("retraction_length", new Slic3r::ConfigOptionFloats({1.5, 2.5}));
|
||||
|
||||
parent.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2}));
|
||||
parent.set_key_value("printer_extruder_variant", new Slic3r::ConfigOptionStrings({"Direct Drive Standard", "Direct Drive Standard"}));
|
||||
parent.set_key_value("retraction_length", new Slic3r::ConfigOptionFloats({0.8, 0.8}));
|
||||
|
||||
const Slic3r::t_config_option_keys keys = {
|
||||
"retraction_length", "printer_extruder_id", "printer_extruder_variant"
|
||||
};
|
||||
const std::set<std::string> different_keys = {
|
||||
"retraction_length", "printer_extruder_id", "printer_extruder_variant"
|
||||
};
|
||||
|
||||
WHEN("update_non_diff_values_to_base_config is called") {
|
||||
std::string id_name = "printer_extruder_id";
|
||||
std::string var_name = "printer_extruder_variant";
|
||||
child.update_non_diff_values_to_base_config(
|
||||
parent, keys, different_keys, id_name, var_name,
|
||||
Slic3r::printer_options_with_variant_1,
|
||||
Slic3r::printer_options_with_variant_2);
|
||||
|
||||
THEN("retraction_length retains size 2") {
|
||||
REQUIRE(child.option<Slic3r::ConfigOptionFloats>("retraction_length")->values.size() == 2);
|
||||
}
|
||||
THEN("retraction_length gets parent values — proves the merge ran (guard did not fire)") {
|
||||
// If the guard regressed to `cur >= target`, this path would be skipped and
|
||||
// retraction_length would remain {1.5, 2.5}. The correct `cur > target` guard
|
||||
// does not fire for equal-size, the merge proceeds, and with mismatched
|
||||
// variants the child positions receive parent values.
|
||||
auto* rl = child.option<Slic3r::ConfigOptionFloats>("retraction_length");
|
||||
REQUIRE_THAT(rl->values[0], Catch::Matchers::WithinAbs(0.8, 1e-9));
|
||||
REQUIRE_THAT(rl->values[1], Catch::Matchers::WithinAbs(0.8, 1e-9));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("update_non_diff_values_to_base_config truncation guard does not affect non-variant scalar keys",
|
||||
"[Config][Variant]") {
|
||||
// The fix is scoped to options in printer_options_with_variant_1 / _2. A non-variant scalar
|
||||
// listed in `keys` and `different_keys` should hit the "nothing to do" branch and remain
|
||||
// untouched regardless of child/parent extruder count mismatch.
|
||||
GIVEN("A 2-extruder child inheriting from a 1-extruder parent, with a non-variant scalar key in `keys`") {
|
||||
Slic3r::DynamicPrintConfig child;
|
||||
Slic3r::DynamicPrintConfig parent;
|
||||
|
||||
child.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2}));
|
||||
child.set_key_value("printer_extruder_variant", new Slic3r::ConfigOptionStrings({"Direct Drive Standard", "Direct Drive Standard"}));
|
||||
child.set_key_value("layer_height", new Slic3r::ConfigOptionFloat(0.20));
|
||||
|
||||
parent.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1}));
|
||||
parent.set_key_value("printer_extruder_variant", new Slic3r::ConfigOptionStrings({"Direct Drive Standard"}));
|
||||
parent.set_key_value("layer_height", new Slic3r::ConfigOptionFloat(0.28));
|
||||
|
||||
const Slic3r::t_config_option_keys keys = {
|
||||
"layer_height", "printer_extruder_id", "printer_extruder_variant"
|
||||
};
|
||||
const std::set<std::string> different_keys = {
|
||||
"layer_height", "printer_extruder_id", "printer_extruder_variant"
|
||||
};
|
||||
|
||||
WHEN("update_non_diff_values_to_base_config is called") {
|
||||
std::string id_name = "printer_extruder_id";
|
||||
std::string var_name = "printer_extruder_variant";
|
||||
child.update_non_diff_values_to_base_config(
|
||||
parent, keys, different_keys, id_name, var_name,
|
||||
Slic3r::printer_options_with_variant_1,
|
||||
Slic3r::printer_options_with_variant_2);
|
||||
|
||||
THEN("the non-variant scalar layer_height is left unchanged on the child") {
|
||||
REQUIRE_THAT(child.option<Slic3r::ConfigOptionFloat>("layer_height")->value,
|
||||
Catch::Matchers::WithinAbs(0.20, 1e-9));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("update_non_diff_values_to_base_config preserves child vectors when child has more extruders than parent",
|
||||
"[Config][Variant]") {
|
||||
GIVEN("A 2-extruder child printer config inheriting from a 1-extruder parent") {
|
||||
|
||||
Reference in New Issue
Block a user