Revive the disabled fff_print test suite (#14196)

* Fix null-deref and arranger bugs that gate headless slicing tests

export_gcode dereferenced a null result out-param, enum serialization
dereferenced a null keys_map, and get_arrange_polys left bed_idx unseeded so
the arranger dropped items. All only affect the headless test/CLI path.

* Fix the headless test harness and add G-code test helpers

Use the real arranger, fix temp-file handling with an RAII guard, and add
layers_with_role / max_z for inspecting sliced G-code.

* Re-enable the Model construction test

* Re-enable SupportMaterial tests and add an enforced-support test

* Re-enable and extend PrintObject layer-height and perimeter tests

* Re-enable Print skirt, brim, and solid-surface tests

* Re-enable and extend PrintGCode tests

Un-hide the basic scenario (dead-key fixes, reframes, trimmed trivia) and add
initial-layer-height, sequential-order, and null-result export tests.

* Re-enable and reframe the skirt/brim tests

Detect skirt/brim by G-code role comment instead of a sentinel speed, and
resolve the previously-unfinished skirt-enclosure test.

* Replace the stale lift()/unlift() test with a z_hop test

* Delete the stub and broken Flow tests
This commit is contained in:
raistlin7447
2026-06-14 04:42:53 -05:00
committed by GitHub
parent abb4eddb9c
commit 5fafbb59fc
16 changed files with 419 additions and 676 deletions

View File

@@ -10,10 +10,11 @@
#include <cstdlib>
#include <string>
#include <boost/nowide/cstdio.hpp>
#include <boost/filesystem.hpp>
#include <libslic3r/ModelArrange.hpp>
#include "test_utils.hpp"
using namespace std;
namespace Slic3r { namespace Test {
@@ -282,16 +283,36 @@ void init_and_process_print(std::initializer_list<TriangleMesh> meshes, Slic3r::
std::string gcode(Print & print)
{
boost::filesystem::path temp = boost::filesystem::unique_path();
ScopedTemporaryFile temp(".gcode");
print.set_status_silent();
print.process();
print.export_gcode(temp.string(), nullptr, nullptr);
std::ifstream t(temp.string());
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
boost::nowide::remove(temp.string().c_str());
return str;
}
std::set<double> layers_with_role(const std::string &gcode, const std::string &role)
{
std::set<double> layers;
GCodeReader parser;
parser.parse_buffer(gcode, [&layers, &role](GCodeReader &self, const GCodeReader::GCodeLine &line) {
if (line.extruding(self) && line.comment().find(role) != std::string_view::npos)
layers.insert(self.z());
});
return layers;
}
double max_z(const std::string &gcode)
{
double z = 0.0;
GCodeReader parser;
parser.parse_buffer(gcode, [&z](GCodeReader &self, const GCodeReader::GCodeLine &) {
z = std::max(z, static_cast<double>(self.z()));
});
return z;
}
Slic3r::Model model(const std::string &model_name, TriangleMesh &&_mesh)
{
Slic3r::Model result;
@@ -338,7 +359,7 @@ std::string slice(std::initializer_list<TriangleMesh> meshes, std::initializer_l
#include <catch2/catch_all.hpp>
SCENARIO("init_print functionality", "[test_data][.]") {
SCENARIO("init_print functionality", "[test_data]") {
GIVEN("A default config") {
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
WHEN("init_print is called with a single mesh.") {