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 "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

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
```
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
```