Allow building tests separately from Orca with build_linux.sh

This commit is contained in:
Cory Cross
2025-11-03 10:48:30 -08:00
parent b48dd917fd
commit c92826f54d
2 changed files with 31 additions and 15 deletions

View File

@@ -27,7 +27,6 @@ function usage() {
echo " -L: use ld.lld as linker (if available)" echo " -L: use ld.lld as linker (if available)"
echo "For a first use, you want to './${SCRIPT_NAME} -u'" echo "For a first use, you want to './${SCRIPT_NAME} -u'"
echo " and then './${SCRIPT_NAME} -dsi'" echo " and then './${SCRIPT_NAME} -dsi'"
echo "To build with tests: './${SCRIPT_NAME} -st' or './${SCRIPT_NAME} -dst'"
} }
SLIC3R_PRECOMPILED_HEADERS="ON" SLIC3R_PRECOMPILED_HEADERS="ON"
@@ -102,11 +101,6 @@ if [ ${OPTIND} -eq 1 ] ; then
exit 1 exit 1
fi 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() { function check_available_memory_and_disk() {
FREE_MEM_GB=$(free --gibi --total | grep 'Mem' | rev | cut --delimiter=" " --fields=1 | rev) FREE_MEM_GB=$(free --gibi --total | grep 'Mem' | rev | cut --delimiter=" " --fields=1 | rev)
MIN_MEM_GB=10 MIN_MEM_GB=10
@@ -221,7 +215,7 @@ if [[ -n "${BUILD_DEPS}" ]] ; then
print_and_run cmake --build deps/$BUILD_DIR print_and_run cmake --build deps/$BUILD_DIR
fi fi
if [[ -n "${BUILD_ORCA}" ]] ; then if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then
echo "Configuring OrcaSlicer..." echo "Configuring OrcaSlicer..."
if [[ -n "${CLEAN_BUILD}" ]] ; then if [[ -n "${CLEAN_BUILD}" ]] ; then
print_and_run rm -fr $BUILD_DIR print_and_run rm -fr $BUILD_DIR
@@ -243,11 +237,13 @@ if [[ -n "${BUILD_ORCA}" ]] ; then
"${COLORED_OUTPUT}" \ "${COLORED_OUTPUT}" \
"${BUILD_ARGS[@]}" "${BUILD_ARGS[@]}"
echo "done" echo "done"
if [[ -n "${BUILD_ORCA}" ]]; then
echo "Building OrcaSlicer ..." echo "Building OrcaSlicer ..."
print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer
echo "Building OrcaSlicer_profile_validator .." echo "Building OrcaSlicer_profile_validator .."
print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator
./scripts/run_gettext.sh ./scripts/run_gettext.sh
fi
if [[ -n "${BUILD_TESTS}" ]] ; then if [[ -n "${BUILD_TESTS}" ]] ; then
echo "Building tests ..." echo "Building tests ..."
print_and_run cmake --build ${BUILD_DIR} --config "${BUILD_CONFIG}" --target tests/all print_and_run cmake --build ${BUILD_DIR} --config "${BUILD_CONFIG}" --target tests/all

View File

@@ -10,18 +10,38 @@ Can be built when you are building Orca Slicer binary by including the `-t` flag
build_linux.sh -st 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 Unit Tests
### Run All ### Run All
``` ```
ctest --test-dir build/tests cd $BUILD_DIR # build or build-dbginfo probably
ctest --test-dir tests
``` ```
### Run a Specific Set ### Run a Specific Set
``` ```
ctest --test-dir build/tests/slic3rutils cd $BUILD_DIR # build or build-dbginfo probably
ctest --test-dir tests/slic3rutils
``` ```