diff --git a/doc/How to build - Linux et al.md b/doc/How to build - Linux et al.md index 15d2037e11..39d0b8005d 100644 --- a/doc/How to build - Linux et al.md +++ b/doc/How to build - Linux et al.md @@ -73,8 +73,27 @@ And that's it. It is now possible to run the freshly built PrusaSlicer binary: cd src ./prusa-slicer +#### 4. Running Unit Tests +For the most complete unit testing, use the Debug build option `-DCMAKE_BUILD_TYPE=Debug` when running cmake. +Without the Debug build, internal assert statements are not tested. +To run the unit tests: + + cd build + make test + +To run a specific unit test: + + cd build/tests/ + +The unit tests can be found by + + `ls */*_tests` + +Any of these unit tests can be run directly e.g. + + `./fff_print/fff_print_tests` ## Useful CMake flags when building dependencies diff --git a/doc/How to build - Mac OS.md b/doc/How to build - Mac OS.md index 82fbfd6686..3e62593127 100644 --- a/doc/How to build - Mac OS.md +++ b/doc/How to build - Mac OS.md @@ -63,6 +63,28 @@ Alternatively, if you would like to use XCode GUI, modify the `cmake` command to and then open the `PrusaSlicer.xcodeproj` file. This should open up XCode where you can perform build using the GUI or perform other tasks. +### Running Unit Tests + +For the most complete unit testing, use the Debug build option `-DCMAKE_BUILD_TYPE=Debug` when running cmake. +Without the Debug build, internal assert statements are not tested. + +To run all the unit tests: + + cd build + make test + +To run a specific unit test: + + cd build/tests/ + +The unit tests can be found by + + `ls */*_tests` + +Any of these unit tests can be run directly e.g. + + `./fff_print/fff_print_tests` + ### Note on Mac OS X SDKs By default PrusaSlicer builds against whichever SDK is the default on the current system. diff --git a/doc/How to build - Windows.md b/doc/How to build - Windows.md index f62cb6ae08..4d135257fc 100644 --- a/doc/How to build - Windows.md +++ b/doc/How to build - Windows.md @@ -58,8 +58,28 @@ Debug->Start Debugging or press F5 PrusaSlicer should start. You're up and running! +### Running Unit Tests + +For the most complete unit testing, use the Debug build option `-DCMAKE_BUILD_TYPE=Debug` when running cmake. +Without the Debug build, internal assert statements are not tested. + +To run the unit tests: + + cd build + make test +To run a specific unit test: + + cd build\tests + +The unit tests can be found by + + `dir *\*_tests` + +Any of these unit tests can be run directly e.g. + + `.\fff_print\fff_print_tests` ## 2.B Run the automatic build script diff --git a/tests/fff_print/test_gcode.cpp b/tests/fff_print/test_gcode.cpp index 65564ae516..30d3e29d29 100644 --- a/tests/fff_print/test_gcode.cpp +++ b/tests/fff_print/test_gcode.cpp @@ -119,12 +119,12 @@ std::optional parse_axis(const std::string& line, const std::string& axi * - no travel moves go outside skirt * - temperatures are set correctly */ -TEST_CASE("Extrusion, travels, temeperatures", "[GCode]") { +TEST_CASE("Extrusion, travels, temperatures", "[GCode]") { DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config(); config.set_deserialize_strict({ { "gcode_comments", 1 }, { "complete_objects", 1 }, - { "extrusion_axis", 'A' }, + { "extrusion_axis", "A" }, { "start_gcode", "" }, // prevent any default extra Z move { "layer_height", 0.4 }, { "first_layer_height", 0.4 }, @@ -174,6 +174,11 @@ TEST_CASE("Extrusion, travels, temeperatures", "[GCode]") { } }); + // Remove last travel_moves returning to origin + if (travel_moves.back().x() == 0 && travel_moves.back().y() == 0) { + travel_moves.pop_back(); + } + const unsigned layer_count = 20 / 0.4; INFO("Complete_objects generates the correct number of Z moves."); CHECK(z_moves.size() == layer_count * 2); @@ -192,20 +197,30 @@ TEST_CASE("Extrusion, travels, temeperatures", "[GCode]") { TEST_CASE("Used filament", "[GCode]") { - DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config(); - config.set_deserialize_strict({ - { "retract_length", "1000000" }, + DynamicPrintConfig config1 = Slic3r::DynamicPrintConfig::full_print_config(); + config1.set_deserialize_strict({ + { "retract_length", "0" }, { "use_relative_e_distances", 1 }, { "layer_gcode", "G92 E0\n" }, }); - GCodeReader parser; - Print print; - Model model; - Test::init_print({TestMesh::cube_20x20x20}, print, model, config); - Test::gcode(print); + Print print1; + Model model1; + Test::init_print({TestMesh::cube_20x20x20}, print1, model1, config1); + Test::gcode(print1); + + DynamicPrintConfig config2 = Slic3r::DynamicPrintConfig::full_print_config(); + config2.set_deserialize_strict({ + { "retract_length", "999" }, + { "use_relative_e_distances", 1 }, + { "layer_gcode", "G92 E0\n" }, + }); + Print print2; + Model model2; + Test::init_print({TestMesh::cube_20x20x20}, print2, model2, config2); + Test::gcode(print2); INFO("Final retraction is not considered in total used filament"); - CHECK(print.print_statistics().total_used_filament > 0); + CHECK(print1.print_statistics().total_used_filament == print2.print_statistics().total_used_filament); } void check_m73s(Print& print){ diff --git a/tests/fff_print/test_retraction.cpp b/tests/fff_print/test_retraction.cpp index b8cf441da8..5efbfcc000 100644 --- a/tests/fff_print/test_retraction.cpp +++ b/tests/fff_print/test_retraction.cpp @@ -135,11 +135,6 @@ void test_slicing(std::initializer_list meshes, DynamicPrintConfig& co check_gcode(meshes, config, duplicate); } - SECTION("Negative restart extra length") { - config.set_deserialize_strict({{ "retract_restart_extra", "-1" }}); - check_gcode(meshes, config, duplicate); - } - SECTION("Retract_lift") { config.set_deserialize_strict({{ "retract_lift", "1,2" }}); check_gcode(meshes, config, duplicate);