add test infrastructure, closing #11

BodgeMaster-unfinished
BodgeMaster 2022-06-28 18:28:44 +02:00
parent 274f18e693
commit e09fb6a61f
4 changed files with 31 additions and 0 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

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

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