mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-18 14:32:36 +00:00
CLI: --strict, and a warnings array in result.json (#14601)
# Description
Add `--strict` for CI and scripted pipelines, and a structured
`warnings`
array in `result.json`.
## `--strict`
A NON_CRITICAL slicing warning is logged and the slice succeeds: return
code
`0`, G-code written. That suits interactive use, but a pipeline then
ships a
slice with a warning nobody saw. With `--strict`, such a warning fails
the run
with `CLI_SLICING_ERROR` before the G-code is exported. Without the
flag,
nothing changes.
In FFF the warning that reaches this path is "support needed but
disabled"
(`PrintObject::generate_support_material`). `--no-check` skips that
check, so
`--strict --no-check` is rejected with `CLI_INVALID_PARAMS`.
`--strict` is read before any work, so it doesn't depend on argument
order and
`result.json` reports it for early failures as well.
## `result.json`
Two new top-level fields:
- `warnings`: `[{"class", ...details}]`. One class is wired:
`slicing_warning_non_critical` with `plate_id` and `text`, recorded
whenever
such a warning fires, with or without `--strict`. The array also fills
on
runs that succeed, so `return_code` stays the verdict.
- `strict_mode`: whether `--strict` was on.
`record_exit_reson` writes `result.json` on Linux only, so both fields
exist
only there. The non-zero exit works on every platform.
## Tests
- `tests/fff_print/test_support_material.cpp` (all platforms): an
overhang
sliced with support off raises the NON_CRITICAL support-needed status,
and
the no-check flag suppresses it.
- `tests/cli/test_cli_strict.sh` (Linux only): runs `orca-slicer`
without
flags, with `--strict`, and with `--strict --no-check`, and checks the
shell
status and `result.json` of each. It runs the built binary, so it
carries the
`RequiresApp` label, which `scripts/run_unit_tests.sh` excludes because
the
unit-test job only receives `build/tests`. Run it with
`ctest --test-dir build/tests -C Release -L RequiresApp`.
- CI: `unit_tests.yml` now passes `Release` on Linux too.
`build_linux.sh`
configures Ninja Multi-Config, and without a config ctest drops the
labels of
plain `add_test()` tests, so this test ran as "Not Run" instead of being
excluded. The docs that assumed Linux was single-config are corrected
too.
Built and run locally on Linux (GCC 14) on current `main`: both tests
pass,
and the touched files compile clean under Clang with `-Werror`.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@@ -128,6 +129,49 @@ TEST_CASE("Enforced support layers are generated", "[SupportMaterial]")
|
||||
REQUIRE(enforced.objects().front()->support_layers().size() > 0);
|
||||
}
|
||||
|
||||
// Support-needed statuses raised while slicing support_capital() with support off. The CLI lists these
|
||||
// in result.json and fails on them under --strict. Collected under a lock: generate_support_material()
|
||||
// runs on TBB workers.
|
||||
static std::vector<PrintBase::SlicingStatus> support_needed_statuses(bool no_check)
|
||||
{
|
||||
Slic3r::Print print;
|
||||
Slic3r::Model model;
|
||||
Slic3r::Test::init_print({ support_capital() }, print, model, {
|
||||
{ "enable_support", 0 },
|
||||
{ "enforce_support_layers", 0 }
|
||||
});
|
||||
print.set_no_check_flag(no_check);
|
||||
|
||||
std::mutex mutex;
|
||||
std::vector<PrintBase::SlicingStatus> statuses;
|
||||
print.set_status_callback([&mutex, &statuses](const PrintBase::SlicingStatus &status) {
|
||||
if (status.message_type != PrintStateBase::SlicingNeedSupportOn)
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
statuses.push_back(status);
|
||||
});
|
||||
print.process();
|
||||
return statuses;
|
||||
}
|
||||
|
||||
TEST_CASE("An overhang sliced with support off reports that support is needed", "[SupportMaterial]")
|
||||
{
|
||||
// The 40mm cap reaches ~22mm past its 8mm stem, beyond the 6mm cantilever limit of
|
||||
// PrintObject::is_support_necessary().
|
||||
const std::vector<PrintBase::SlicingStatus> statuses = support_needed_statuses(false);
|
||||
REQUIRE(! statuses.empty());
|
||||
for (const PrintBase::SlicingStatus &status : statuses) {
|
||||
// The CLI only considers step warnings (warning_step != -1), and --strict only NON_CRITICAL ones.
|
||||
CHECK(status.warning_level == PrintStateBase::WarningLevel::NON_CRITICAL);
|
||||
CHECK(status.warning_step != -1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("The no-check flag skips the support-needed check", "[SupportMaterial]")
|
||||
{
|
||||
CHECK(support_needed_statuses(true).empty());
|
||||
}
|
||||
|
||||
SCENARIO("Support layer Z honors contact distance", "[SupportMaterial]")
|
||||
{
|
||||
// Box h = 20mm, hole bottom at 5mm, hole height 10mm (top edge at 15mm).
|
||||
|
||||
Reference in New Issue
Block a user