forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add unit test to github action (OpenAtomFoundation#1604)
* ci: add unit test in github workflow
- Loading branch information
Showing
3 changed files
with
117 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,73 @@ | ||
#!/bin/bash | ||
rm -rf ./log | ||
rm -rf .db | ||
cp output/pika src/redis-server | ||
cp conf/pika.conf tests/assets/default.conf | ||
|
||
tclsh tests/test_helper.tcl --clients 1 --single unit/$1 | ||
rm src/redis-server | ||
rm -rf ./log | ||
rm -rf ./db | ||
|
||
# clear the log file | ||
function cleanup() { | ||
rm -rf ./log | ||
rm -rf db | ||
rm -rf dbsync/ | ||
rm src/redis-server | ||
} | ||
|
||
# check if tcl is installed | ||
function check_tcl { | ||
if [ -z "$(which tclsh)" ]; then | ||
echo "tclsh is not installed" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# handle different build directories. | ||
function setup_build_dir { | ||
BUILD_DIR="" | ||
if [ -d "./build" ] && [ -d "./output" ]; then | ||
echo "Both build and output directories exist. Please remove one of them." | ||
exit 1 | ||
fi | ||
if [ -d "./build" ]; then | ||
BUILD_DIR="build" | ||
fi | ||
|
||
if [ -d "./output" ]; then | ||
BUILD_DIR="output" | ||
fi | ||
if [ -z "$BUILD_DIR" ]; then | ||
echo "No build directory found. Please build the project first." | ||
exit 1 | ||
fi | ||
echo "BUILD_DIR: $BUILD_DIR" | ||
} | ||
|
||
# setup pika bin and conf | ||
function setup_pika_bin { | ||
PIKA_BIN="./$BUILD_DIR/pika" | ||
if [ ! -f "$PIKA_BIN" ]; then | ||
echo "pika bin not found" | ||
exit 1 | ||
fi | ||
cp $PIKA_BIN src/redis-server | ||
cp conf/pika.conf tests/assets/default.conf | ||
} | ||
|
||
|
||
cleanup | ||
|
||
check_tcl | ||
|
||
setup_build_dir | ||
|
||
setup_pika_bin | ||
|
||
echo "run pika tests $1" | ||
|
||
if [ "$1" == "all" ]; then | ||
tclsh tests/test_helper.tcl --clients 1 | ||
else | ||
tclsh tests/test_helper.tcl --clients 1 --single unit/$1 | ||
fi | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "pika tests failed" | ||
cleanup | ||
exit 1 | ||
fi | ||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters