Skip to content

Commit

Permalink
kurt/shift-mode-tests #77
Browse files Browse the repository at this point in the history
kurt/shift-mode-tests #77
  • Loading branch information
livingkurt authored Jul 16, 2024
2 parents e875c7d + f73ac27 commit 74facb0
Show file tree
Hide file tree
Showing 10 changed files with 22,951 additions and 1,268 deletions.
8 changes: 7 additions & 1 deletion HeliosCLI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SUFFIXES:

# List all make targets which are not filenames
.PHONY: all tests clean
.PHONY: all tests clean clean_storage

# compiler tool definitions
CC=g++
Expand Down Expand Up @@ -105,6 +105,12 @@ FORCE:
clean:
@$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS)

clean_storage:
@echo "Cleaning Helios storage file..."
@$(RM) Helios.storage
@$(RM) ../tests/Helios.storage
@echo "Helios storage file cleaned."

# Now include our target dependency files
# the hyphen means ignore non-existent files
-include $(DFILES)
15 changes: 9 additions & 6 deletions tests/record_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ if [ "$NUMFILES" == "" ]; then
NUMFILES=1
fi

INPUT="$(grep "Input=" $FILE | cut -d= -f2)"
BRIEF="$(grep "Brief=" $FILE | cut -d= -f2)"
ARGS="$(grep "Args=" $FILE | cut -d= -f2)"
TESTNUM="$(echo $FILE | cut -d/ -f2 | cut -d_ -f1 | cut -d/ -f2)"
INPUT="$(grep "Input=" $FILE | cut -d= -f2 | tr -d '\n' | tr -d '\r')"
BRIEF="$(grep "Brief=" $FILE | cut -d= -f2 | tr -d '\n' | tr -d '\r')"
ARGS="$(grep "Args=" $FILE | cut -d= -f2 | tr -d '\n' | tr -d '\r')"
TESTNUM="$(echo $FILE | cut -d/ -f3 | cut -d_ -f1 | cut -d/ -f2)"
TESTNUM=$((10#$TESTNUM))

if [ "$QUIET" -eq 0 ]; then
if [ "$QUIET" -eq 0 ]; then
echo -e -n "\e[31mRecording test ($TESTCOUNT/$NUMFILES) \e[33m[\e[97m$BRIEF\e[33m] \e[33m[\e[97m$ARGS\e[33m]...\e[0m"
fi
TEMP_FILE="tmp/${FILE}.out"
Expand All @@ -40,13 +40,16 @@ echo "Brief=${BRIEF}" >> "$TEMP_FILE"
echo "Args=${ARGS}" >> "$TEMP_FILE"
echo "--------------------------------------------------------------------------------" >> "$TEMP_FILE"

# ensure there is no existing storage file
rm -f Helios.storage

# strip any \r in case this was run on windows
$HELIOS $ARGS --no-timestep --hex <<< $INPUT >> $TEMP_FILE

sed -i 's/\r//g' $TEMP_FILE
# Replace the original file with the modified temp file
mv $TEMP_FILE $FILE
if [ "$QUIET" -eq 0 ]; then
if [ "$QUIET" -eq 0 ]; then
echo -e "\e[96mOK\e[0m"
else
echo -n "."
Expand Down
4 changes: 1 addition & 3 deletions tests/recordtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ function record_tests() {

NUMFILES=${#FILES[@]}
echo -e "\e[33m== [\e[31mRECORDING \e[97m$NUMFILES INTEGRATION TESTS\e[33m] ==\e[0m"



TESTCOUNT=0

for FILE in "${FILES[@]}"; do
# Call the record_test.sh using its relative path
"$SCRIPT_DIR"/record_test.sh "$FILE" $VALIDATE $TESTCOUNT "$NUMFILES" $QUIET &
"$SCRIPT_DIR"/record_test.sh "$FILE" $VALIDATE $TESTCOUNT "$NUMFILES" $QUIET
TESTCOUNT=$((TESTCOUNT + 1))
done

Expand Down
10 changes: 7 additions & 3 deletions tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function run_tests() {
TESTCOUNT=0

for FILE in $FILES; do
INPUT="$(grep "Input=" $FILE | cut -d= -f2)"
BRIEF="$(grep "Brief=" $FILE | cut -d= -f2)"
ARGS="$(grep "Args=" $FILE | cut -d= -f2)"
INPUT="$(grep "Input=" $FILE | cut -d= -f2 | tr -d '\n' | tr -d '\r')"
BRIEF="$(grep "Brief=" $FILE | cut -d= -f2 | tr -d '\n' | tr -d '\r')"
ARGS="$(grep "Args=" $FILE | cut -d= -f2 | tr -d '\n' | tr -d '\r')"
TESTNUM="$(echo $FILE | cut -d/ -f2 | cut -d_ -f1 | cut -d/ -f2)"
TESTNUM=$((10#$TESTNUM))
TESTCOUNT=$((TESTCOUNT + 1))
Expand Down Expand Up @@ -104,7 +104,11 @@ function run_tests() {
echo "Test: $TESTNUM"
echo "-----------------------------"
fi
# ensure there is no leftover storage file
rm -f Helios.storage
# now run the test
$VALGRIND $HELIOS $ARGS --no-timestep --hex <<< $INPUT &> $OUTPUT
# and diff the result
$DIFF --brief $EXPECTED $OUTPUT &> $DIFFOUT
RESULT=$?
if [ $VERBOSE -eq 1 ]; then
Expand Down
Loading

0 comments on commit 74facb0

Please sign in to comment.