Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Tests: sculptforge_tests --shard K/N, registered as four parallel ctest entries with their own temporary folders; each test prints its time; timed UI measurements run alone under ctest -j
islandmed4b5650fd1ef8
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 3046f86f..09c59eab 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -498,7 +498,18 @@ if(SCULPTFORGE_BUILD_TESTS)if(MSVC)target_compile_options(sculptforge_tests PRIVATE /utf-8)endif()- add_test(NAME sculptforge_tests COMMAND sculptforge_tests)+ # The suite as SCULPTFORGE_TEST_SHARDS processes (sculptforge_tests_0of4 ...; `ctest -j` runs them at once, CI does),+ # each with its own temporary folder so tests in different shards never share a scratch file.+ set(SCULPTFORGE_TEST_SHARDS 4 CACHE STRING "Number of ctest entries the sculptforge_tests suite is split into")+ math(EXPR last_shard "${SCULPTFORGE_TEST_SHARDS} - 1")+ foreach(k RANGE ${last_shard})+ set(shard_tmp ${CMAKE_CURRENT_BINARY_DIR}/test-tmp/shard${k})+ file(MAKE_DIRECTORY ${shard_tmp})+ add_test(NAME sculptforge_tests_${k}of${SCULPTFORGE_TEST_SHARDS}+ COMMAND sculptforge_tests --shard ${k}/${SCULPTFORGE_TEST_SHARDS})+ set_tests_properties(sculptforge_tests_${k}of${SCULPTFORGE_TEST_SHARDS} PROPERTIES+ ENVIRONMENT "TMPDIR=${shard_tmp};TMP=${shard_tmp};TEMP=${shard_tmp}")+ endforeach()# A stand-in for Brush, COLMAP and ffmpeg (tests/tools/fake_splat_tools.cpp): splat training is tested without a GPU.add_executable(sf_fake_splat_tools tests/tools/fake_splat_tools.cpp)target_include_directories(sf_fake_splat_tools PRIVATE third_party/stb)@@ -617,6 +628,13 @@ if(SCULPTFORGE_BUILD_TESTS)add_test(NAME ui_stroke_resize COMMAND sculptforge --run "new_sphere" --measure-stroke 1.5)set_tests_properties(ui_stroke_resize PROPERTIES LABELS ui TIMEOUT 60 DISABLED TRUE # predictive strokes: not yet identical in every runENVIRONMENT "SF_NO_UPDATE_CHECK=1;SF_MEASURE_RESIZE=1;SF_MEASURE_VERIFY=1;SF_PREDICTIVE_STROKE=1")+ # Timed measurements run alone when ctest runs tests in parallel (CI: ctest -j): other tests' load must not+ # change what they measure.+ foreach(t ui_idle_redraw ui_calibrate_json ui_stroke_path ui_hardware_profile)+ if(TEST ${t})+ set_tests_properties(${t} PROPERTIES RUN_SERIAL TRUE)+ endif()+ endforeach()# The guide's keyboard table must match the app's default shortcuts (tools/guide/update_shortcuts.py).if(Python3_Interpreter_FOUND)sculptforge_runner(SCULPTFORGE_APP_RUNNER sculptforge)diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 5a8b35cd..84c4d8f2 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -31,6 +31,10 @@ trailing underscore for private members. A `.clang-format` is provided.See [README.md#building](README.md#building). On Linux, `packaging/linux/install-build-deps.sh` installs thebuild dependencies. `ctest` runs the unit tests; `cpack` in the build folder makes the platform's packages.+`ctest -j 4` runs them four at a time: the `sculptforge_tests` suite is registered as four shards+(`sculptforge_tests_0of4` ...), each with its own temporary folder. Run the binary itself for a quick check:+`./build/sculptforge_tests qremesh` runs the tests whose names contain "qremesh", `--shard 1/4` one shard, and+each test prints how long it took.Releases are built by `.github/workflows/release.yml` when a `v*` tag is pushed.### UI tests@@ -50,7 +54,8 @@ take under a second. They use a throwaway settings folder and never touch your othe script and saves `FAIL-line-N.png`, and clicking a missing item lists similarly named items. Clicksscroll panels as needed, and clicking an item a person couldn't reach (off screen) fails. CI runs the UItests on Linux under Xvfb and on Windows with Mesa's software OpenGL, and uploads the screenshots as an-artifact.+artifact. CI compiles through ccache (see the comment at the top of `.github/workflows/ci.yml`); release builds+don't.### Windows, from Linuxdiff --git a/tests/TestHarness.h b/tests/TestHarness.hindex 1813fbbb..2f3498d8 100644--- a/tests/TestHarness.h+++ b/tests/TestHarness.h@@ -8,6 +8,7 @@#include "core/Document.h"+#include <cstddef>#include <cstdio>#include <filesystem>#include <functional>@@ -37,6 +38,12 @@ inline Document makeDoc(Mesh m) {return d;}+// `sculptforge_tests --shard K/N` (tests/test_main.cpp) runs the tests whose registration index is K modulo N: every+// test is in exactly one of the N shards.+inline bool inShard(std::size_t index, int shard, int shards) {+ return shards <= 1 || index % static_cast<std::size_t>(shards) == static_cast<std::size_t>(shard);+}+inline std::string tempPath(const char* name) { return (std::filesystem::temp_directory_path() / name).string(); }} // namespace sf::testdiff --git a/tests/test_harness.cpp b/tests/test_harness.cppnew file mode 100644index 00000000..fa7b0484--- /dev/null+++ b/tests/test_harness.cpp@@ -0,0 +1,29 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The test runner itself: CI runs sculptforge_tests as several shards at once (--shard K/N), which must+// together run every test exactly once.+#include "TestHarness.h"++#include <vector>++TEST(test_shards_cover_every_test_once) {+ using sf::test::inShard;+ const std::size_t count = sf::test::registry().size();+ CHECK(count > 100); // the whole suite is registered+ for (int shards = 1; shards <= 9; ++shards) {+ std::vector<int> runs(count + 17, 0); // a few more than registered: the rule must not depend on the count+ for (int k = 0; k < shards; ++k)+ for (std::size_t i = 0; i < runs.size(); ++i)+ if (inShard(i, k, shards)) ++runs[i];+ bool once = true;+ for (int r : runs) once = once && r == 1;+ CHECK(once);+ }+ // Shards stay balanced: with 4 shards none gets more than a quarter (rounded up) of the tests.+ for (int k = 0; k < 4; ++k) {+ std::size_t n = 0;+ for (std::size_t i = 0; i < count; ++i) n += inShard(i, k, 4) ? 1 : 0;+ CHECK(n <= (count + 3) / 4);+ }+}diff --git a/tests/test_main.cpp b/tests/test_main.cppindex d9e34139..f6e122b0 100644--- a/tests/test_main.cpp+++ b/tests/test_main.cpp@@ -2,31 +2,54 @@// SPDX-License-Identifier: GPL-3.0-or-later//// Runs every TEST registered by the tests/test_*.cpp files (with arguments: only the tests whose names contain-// one of them, e.g. `sculptforge_tests qremesh_guide`).+// one of them, e.g. `sculptforge_tests qremesh_guide`). `--shard K/N` runs only shard K (0-based) of N, so the+// suite can run as N processes at once (CMake registers sculptforge_tests_0of4 ... for ctest -j); every test is+// in exactly one shard (sf::test::inShard).#include "TestHarness.h"+#include <chrono>#include <cstdio>#include <cstring>#include <exception>+#include <vector>int main(int argc, char** argv) {using namespace sf::test;- for (const auto& t : registry()) {- bool wanted = argc < 2;- for (int i = 1; i < argc && !wanted; ++i) wanted = std::strstr(t.name, argv[i]) != nullptr;+ int shard = 0, shards = 1;+ std::vector<const char*> filters;+ for (int i = 1; i < argc; ++i) {+ if (std::strcmp(argv[i], "--shard") == 0 && i + 1 < argc) {+ if (std::sscanf(argv[++i], "%d/%d", &shard, &shards) != 2 || shards < 1 || shard < 0 || shard >= shards) {+ std::printf("--shard wants K/N with 0 <= K < N, got %s\n", argv[i]);+ return 2;+ }+ } else {+ filters.push_back(argv[i]);+ }+ }+ int ran = 0;+ for (std::size_t index = 0; index < registry().size(); ++index) {+ const auto& t = registry()[index];+ if (!inShard(index, shard, shards)) continue;+ bool wanted = filters.empty();+ for (const char* f : filters) wanted = wanted || std::strstr(t.name, f) != nullptr;if (!wanted) continue;+ ++ran;std::printf("[ RUN] %s\n", t.name);std::fflush(stdout); // so a crash still shows which test was runningint before = g_failures;+ const auto start = std::chrono::steady_clock::now();try {t.fn();} catch (const std::exception& e) {++g_failures;std::printf(" EXCEPTION: %s\n", e.what());}- std::printf("%s %s\n", g_failures == before ? "[ OK ]" : "[FAIL]", t.name);+ const long long ms =+ std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();+ std::printf("%s %s (%lld ms)\n", g_failures == before ? "[ OK ]" : "[FAIL]", t.name, ms);std::fflush(stdout);}- std::printf("\n%d checks, %d failures\n", g_checks, g_failures);+ std::printf("\n%d tests, %d checks, %d failures\n", ran, g_checks, g_failures);return g_failures == 0 ? 0 : 1;}