Compare commits

...

2 Commits

Author SHA1 Message Date
BodgeMaster e09fb6a61f add test infrastructure, closing #11 2022-06-28 18:28:44 +02:00
BodgeMaster 274f18e693 Environment: fix LD_LIBRARY_PATH not being set correctly if it has a preexisting value 2022-06-28 18:07:05 +02:00
4 changed files with 32 additions and 1 deletions

View File

@ -9,3 +9,5 @@ mrproper:
bash ./scripts/clean_dependencies.sh
setup:
bash ./scripts/setup_project.sh
test:
bash ./scripts/test.sh

25
scripts/test.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
if [ -z "$CXX" ]; then
CXX="c++"
fi
if [ -z "$CXXFLAGS" ]; then
CXXFLAGS="-std=c++20 -Wall"
fi
CXX_WITH_FLAGS="$CXX $CXXFLAGS"
echo -n "Using LD_LIBRARY_PATH "
if [ -z "$LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH=./bin/lib
else
export LD_LIBRARY_PATH=./bin/lib:"$LD_LIBRARY_PATH"
fi
echo "$LD_LIBRARY_PATH"
mkdir -pv bin/test
echo "Building and running tests one by one..."
set -v
"CXX_WITH_FLAGS" -Lbin/lib -l:nbt.so -o bin/test/nbt_helpers src/test/nbt_helpers.cpp

View File

@ -20,6 +20,7 @@ PROJECT_BASE_DIR="$( cd -- "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 ; pw
alias clean="pushd \"$PROJECT_BASE_DIR\" >/dev/null 2>&1; scripts/clean.sh; popd >/dev/null 2>&1"
alias clean_dependencies="pushd \"$PROJECT_BASE_DIR\" >/dev/null 2>&1; scripts/clean_dependencies.sh; popd >/dev/null 2>&1"
alias setup_project="pushd \"$PROJECT_BASE_DIR\" >/dev/null 2>&1; scripts/setup_project.sh; popd >/dev/null 2>&1"
alias run_tests="pushd \"$PROJECT_BASE_DIR\" >/dev/null 2>&1; scripts/test.sh; popd >/dev/null 2>&1"
function build {
pushd "$PROJECT_BASE_DIR" >/dev/null 2>&1
@ -31,7 +32,7 @@ function build {
if [ -z "$LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH="$PROJECT_BASE_DIR"/bin/lib
else
export LD_LIBRARY_PATH="$PROJECT_BASE_DIR"/bin/lib:"LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$PROJECT_BASE_DIR"/bin/lib:"$LD_LIBRARY_PATH"
fi
unset PROJECT_BASE_DIR

3
src/test/nbt_helpers.cpp Normal file
View File

@ -0,0 +1,3 @@
int main(){
return 0;
}