From c92826f54d6a700fa4600a0fe8cdef2163372f92 Mon Sep 17 00:00:00 2001 From: Cory Cross Date: Mon, 3 Nov 2025 10:48:30 -0800 Subject: [PATCH] Allow building tests separately from Orca with build_linux.sh --- build_linux.sh | 20 ++++++++------------ doc/developer-reference/How-to-test.md | 26 +++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/build_linux.sh b/build_linux.sh index 1f35b464f6..9a9a9160ba 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -27,7 +27,6 @@ function usage() { echo " -L: use ld.lld as linker (if available)" echo "For a first use, you want to './${SCRIPT_NAME} -u'" echo " and then './${SCRIPT_NAME} -dsi'" - echo "To build with tests: './${SCRIPT_NAME} -st' or './${SCRIPT_NAME} -dst'" } SLIC3R_PRECOMPILED_HEADERS="ON" @@ -102,11 +101,6 @@ if [ ${OPTIND} -eq 1 ] ; then exit 1 fi -if [[ -n "${BUILD_TESTS}" ]] && [[ -z "${BUILD_ORCA}" ]] ; then - echo "-t flag requires -s flag in the same invocation" - exit 1 -fi - function check_available_memory_and_disk() { FREE_MEM_GB=$(free --gibi --total | grep 'Mem' | rev | cut --delimiter=" " --fields=1 | rev) MIN_MEM_GB=10 @@ -221,7 +215,7 @@ if [[ -n "${BUILD_DEPS}" ]] ; then print_and_run cmake --build deps/$BUILD_DIR fi -if [[ -n "${BUILD_ORCA}" ]] ; then +if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then echo "Configuring OrcaSlicer..." if [[ -n "${CLEAN_BUILD}" ]] ; then print_and_run rm -fr $BUILD_DIR @@ -243,11 +237,13 @@ if [[ -n "${BUILD_ORCA}" ]] ; then "${COLORED_OUTPUT}" \ "${BUILD_ARGS[@]}" echo "done" - echo "Building OrcaSlicer ..." - print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer - echo "Building OrcaSlicer_profile_validator .." - print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator - ./scripts/run_gettext.sh + if [[ -n "${BUILD_ORCA}" ]]; then + echo "Building OrcaSlicer ..." + print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer + echo "Building OrcaSlicer_profile_validator .." + print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator + ./scripts/run_gettext.sh + fi if [[ -n "${BUILD_TESTS}" ]] ; then echo "Building tests ..." print_and_run cmake --build ${BUILD_DIR} --config "${BUILD_CONFIG}" --target tests/all diff --git a/doc/developer-reference/How-to-test.md b/doc/developer-reference/How-to-test.md index 2929384b1f..5268e02304 100644 --- a/doc/developer-reference/How-to-test.md +++ b/doc/developer-reference/How-to-test.md @@ -10,18 +10,38 @@ Can be built when you are building Orca Slicer binary by including the `-t` flag build_linux.sh -st ``` -Test binaries will then appear under `build/tests`. As of this writing, not all tests will be built. +(or `-ster` or `-stb` etc). + +When running `build_linux.sh` with `-t`, make sure you always include the `-e` or `-b` flag if you built the binary with them, otherwise you'll rebuild all of OrcaSlicer again before the tests are ready. + +Test binaries will then appear under `build/tests` or `build-dbginfo/tests` or `build-dbg/tests`. As of this writing, not all tests will be built. + +For rebuilding after changes, you can look into `build_linux.sh` for the cmake command which triggers the build, but it should be something like: + +``` +# Obviously only use the appropriate one +BUILD_CONFIG=Release +BUILD_CONFIG=RelWithDebInfo +cd $BUILD_DIR # build or build-dbginfo probably + +cmake --build . --config $BUILD_CONFIG --target tests/all +# or +cmake --build . --config $BUILD_CONFIG --target libslic3r_tests +# etc +``` ## Run Unit Tests ### Run All ``` -ctest --test-dir build/tests +cd $BUILD_DIR # build or build-dbginfo probably +ctest --test-dir tests ``` ### Run a Specific Set ``` -ctest --test-dir build/tests/slic3rutils +cd $BUILD_DIR # build or build-dbginfo probably +ctest --test-dir tests/slic3rutils ```