mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 22:31:02 +00:00
* Ignore Clipper, libpng, mcut and Boost.Polygon Internals in clang-tidy Each only works through a wrapper or umbrella header: libslic3r/clipper.hpp or clipper_z.hpp configure Clipper before including it, png.h pulls in libpng's config headers, and Boost.Polygon's headers only compile through polygon.hpp or voronoi.hpp. * Ignore minilzo's Config Headers in clang-tidy lzoconf.h and lzodefs.h are internal to minilzo.h, which is what the code includes. * Add Missing Includes Across the Remaining Sources and Tests Covers src/slic3r/Utils, src/slic3r/plugin, src/slic3r/Config, src/libvgcode, src/dev-utils, src/OrcaSlicer.cpp and tests/, the directories left after src/slic3r/GUI and src/libslic3r. Generated with clang-tidy misc-include-cleaner. libvgcode's own headers are included by relative path as in the rest of that library, and Catch2 and pybind11 with angle brackets as elsewhere in the repo. * Make the GUI and Test Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Headers that only compile on one platform, or that nothing built includes, are left alone. * Keep Windows and nanosvg Setup Ahead of the Added Includes OrcaSlicer.cpp and several tests set _WIN32_WINNT, WIN32_LEAN_AND_MEAN or NOMINMAX before including Windows.h, and the profile validator defines NANOSVG_IMPLEMENTATION before any libslic3r header. The added includes had landed above those blocks, which broke the Windows build. * Add the GUI Includes the First Pass Missed Covers headers that only became editable once they compiled on their own, and wx symbols whose suggested header changed as the clang-tidy ignore list grew after the src/slic3r/GUI pass. * Keep the Added Test Includes Below the NOMINMAX Guard test_marchingsquares.cpp and test_texture_displacement.cpp had includes inside #ifndef NOMINMAX, which the tests inherit as defined on Windows from libslic3r, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory, as in #16068.
82 lines
3.1 KiB
C++
82 lines
3.1 KiB
C++
#include <catch2/catch_all.hpp>
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/generators/catch_generators.hpp>
|
|
#include "libslic3r/libslic3r.h"
|
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using namespace Slic3r;
|
|
|
|
// Bambu firmware uses the " FEATURE: " style reserved tags, everything else the Slic3r-compatible
|
|
// "TYPE:" style, so which list applies depends on the printer kind passed in.
|
|
TEST_CASE("Reserved keyword detection follows the printer kind it is given", "[GCodeProcessor]")
|
|
{
|
|
struct Case
|
|
{
|
|
const char* name;
|
|
std::string gcode;
|
|
bool reserved_on_bbl;
|
|
bool reserved_on_non_bbl;
|
|
};
|
|
|
|
const auto test_case = GENERATE(values<Case>({
|
|
{"compatible feature tag", ";TYPE:Prime tower", false, true},
|
|
{"compatible layer tag", ";LAYER_CHANGE", false, true},
|
|
{"bbl feature tag", "; FEATURE: Outer wall", true, false},
|
|
{"tag shared by both lists", ";_GP_FIRST_LINE_M73_PLACEHOLDER", true, true},
|
|
{"bbl spells this one with a leading space", ";COLOR_CHANGE", false, true},
|
|
{"ordinary comment", "; heat the bed", false, false},
|
|
{"not a comment at all", "G1 X10 Y10 F3000", false, false},
|
|
// A tag counts only as the whole comment's prefix, so neither a tag mentioned mid-comment
|
|
// nor one trailing a real command is a reserved use.
|
|
{"tag text later in the comment", "; the TYPE:Prime tower marker", false, false},
|
|
{"tag trailing a command", "G1 X10 ;TYPE:Prime tower", false, false},
|
|
}));
|
|
|
|
DYNAMIC_SECTION(test_case.name)
|
|
{
|
|
std::vector<std::string> tags;
|
|
REQUIRE(GCodeProcessor::contains_reserved_tags(test_case.gcode, 5, tags, true) == test_case.reserved_on_bbl);
|
|
|
|
tags.clear();
|
|
REQUIRE(GCodeProcessor::contains_reserved_tags(test_case.gcode, 5, tags, false) == test_case.reserved_on_non_bbl);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("Reserved keyword detection reports every offending line", "[GCodeProcessor]")
|
|
{
|
|
const std::string gcode = ";TYPE:Prime tower\nG1 X10\n;LAYER_CHANGE\n";
|
|
|
|
std::vector<std::string> tags;
|
|
REQUIRE(GCodeProcessor::contains_reserved_tags(gcode, 5, tags, false));
|
|
REQUIRE(tags.size() == 2);
|
|
// Reported in the order they appear, which is what makes the max_count cut-off meaningful.
|
|
CHECK(tags[0] == "TYPE:Prime tower");
|
|
CHECK(tags[1] == "LAYER_CHANGE");
|
|
|
|
SECTION("the reported count is capped at max_count")
|
|
{
|
|
tags.clear();
|
|
REQUIRE(GCodeProcessor::contains_reserved_tags(gcode, 1, tags, false));
|
|
CHECK(tags.size() == 1);
|
|
CHECK(tags[0] == "TYPE:Prime tower");
|
|
}
|
|
|
|
SECTION("a max_count of zero still reports the first tag")
|
|
{
|
|
tags.clear();
|
|
REQUIRE(GCodeProcessor::contains_reserved_tags(gcode, 0, tags, false));
|
|
CHECK(tags.size() == 1);
|
|
}
|
|
|
|
SECTION("g-code with nothing reserved in it reports nothing")
|
|
{
|
|
tags.clear();
|
|
CHECK_FALSE(GCodeProcessor::contains_reserved_tags("G28\n; home all axes\n", 5, tags, false));
|
|
CHECK(tags.empty());
|
|
}
|
|
}
|