Skip to content

Commit

Permalink
refactor: tests/functional_tests/tools
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyTubongbanua committed Jan 3, 2025
1 parent a901c76 commit 64ef707
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 22 deletions.
49 changes: 49 additions & 0 deletions tests/functional_tests/tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# ##########
# This script CMake configures and builds the project for functional tests assuming virtual environment is already setup.
# ##########

FULL_PATH_TO_SCRIPT="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIRECTORY="$(dirname "$FULL_PATH_TO_SCRIPT")"
cd "$SCRIPT_DIRECTORY"

# 1. Go to the root of the project
cd ../../..

# 2. Variables

# 2.1 Default values
ATSIGN_FIRST="@alice🛠"
ATSIGN_SECOND="@bob🛠"
ATDIRECTORY_HOST="vip.ve.atsign.zone"
ATDIRECTORY_PORT=64

# 2.2 Parse command line arguments
while getopts f:s:h:p: flag
do
case "${flag}" in
f) ATSIGN_FIRST=${OPTARG};;
s) ATSIGN_SECOND=${OPTARG};;
h) ATDIRECTORY_HOST=${OPTARG};;
p) ATDIRECTORY_PORT=${OPTARG};;
esac
done

# 2.3 Print variables
echo "ATSIGN_FIRST (-f): $ATSIGN_FIRST"
echo "ATSIGN_SECOND (-s): $ATSIGN_SECOND"
echo "ATDIRECTORY_HOST (-h): $ATDIRECTORY_HOST"
echo "ATDIRECTORY_PORT (-p): $ATDIRECTORY_PORT"

# 3. CMake configure
cmake -S . -B build \
-DATSDK_BUILD_TESTS="func" \
-DCMAKE_BUILD_TYPE=Debug \
-DFIRST_ATSIGN="\"$ATSIGN_FIRST\"" \
-DSECOND_ATSIGN="\"$ATSIGN_SECOND\"" \
-DATDIRECTORY_HOST="\"$ATDIRECTORY_HOST\"" \
-DATDIRECTORY_PORT=$ATDIRECTORY_PORT

# 4. CMake build (this step will build atsdk and link the atsdk to the functional
cmake --build build
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/bin/bash
set -eu
FULL_PATH_TO_SCRIPT="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIRECTORY="$(dirname "$FULL_PATH_TO_SCRIPT")"
cd "$SCRIPT_DIRECTORY"
cd ..

"../../tools/install.sh"

cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --target $1

./build/$1
rm -rf build
20 changes: 20 additions & 0 deletions tests/functional_tests/tools/ctest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
FULL_PATH_TO_SCRIPT="$(realpath "${BASH_SOURCE[0]}")"
SCRIPT_DIRECTORY="$(dirname "$FULL_PATH_TO_SCRIPT")"
cd "$SCRIPT_DIRECTORY"

# 1. Go to root of the project

cd ../../..

# 2. Check if build directory exists

if [ ! -d "build" ]; then
echo "Build directory does not exist. Run build.sh first."
exit 1
fi

# 3. Run ctest

ctest --test-dir build/tests/functional_tests --output-on-failure -VV --timeout 90

13 changes: 0 additions & 13 deletions tests/functional_tests/tools/run_ctest.sh

This file was deleted.

0 comments on commit 64ef707

Please # to comment.