diff --git a/Makefile b/Makefile index 476ed40..b75801a 100644 --- a/Makefile +++ b/Makefile @@ -9,3 +9,5 @@ mrproper: bash ./scripts/clean_dependencies.sh setup: bash ./scripts/setup_project.sh +test: + bash ./scripts/test.sh diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..423d694 --- /dev/null +++ b/scripts/test.sh @@ -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 diff --git a/setupenv.bashrc b/setupenv.bashrc index 949b9cf..00fccad 100644 --- a/setupenv.bashrc +++ b/setupenv.bashrc @@ -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 diff --git a/src/test/nbt_helpers.cpp b/src/test/nbt_helpers.cpp new file mode 100644 index 0000000..c30d8f1 --- /dev/null +++ b/src/test/nbt_helpers.cpp @@ -0,0 +1,3 @@ +int main(){ + return 0; +}