Skip to content

Commit

Permalink
test: updated tests scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vincepick committed Dec 19, 2024
1 parent ab9d0f6 commit e48103b
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 7 deletions.
Binary file modified scripts/testScripts/.DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion scripts/testScripts/check_pr.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# Tests for Graded Instance Generation

# Runs all scripts put in ./tests and makes sure that the run at some point contains provided lines.

# This script runs more intensive tests, intended for PRs to main.
Expand All @@ -16,7 +18,7 @@ testsRun=0
start=$(date +%s)

# Loop through each script in the tests directory
for file in pr_tests/*; do
for file in pr_graded_tests/*; do
((testsRun++))
# Check if file
if [[ -f "$file" ]]; then
Expand Down
58 changes: 58 additions & 0 deletions scripts/testScripts/check_pr_discrim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# Tests for Discriminating Instance Generation

# Runs all scripts put in ./tests and makes sure that the run at some point contains provided lines

# This script runs less intensive tests, intended for push requests rather than a PR

# Lines being checked for
lines=(
"too difficult instances for the favoured solver"
)

testsPassed=0
testsRun=0

start=$(date +%s)

# Loop through each script in the tests directory
for file in pr_discrim_tests/*; do
((testsRun++))
# Check if file
if [[ -f "$file" ]]; then

# Run contents of file
output=$(bash "$file")
all_lines_found=true

# Check for each line in the array
for line in "${lines[@]}"; do
if [[ "$output" != *"$line"* ]]; then
all_lines_found=false
echo "Test $testsRun: $file failed, line not found: $line"
fi
done

# If all lines are found, count as passed
if $all_lines_found; then
echo "Test $testsRun: $file passed, all lines found in output"
((testsPassed++))
fi
fi
# Record end time and calculate elapsed time
end=$(date +%s)
elapsedTime=$((end - start))

# Display time elapsed
echo "Time elapsed: $elapsedTime seconds"
done

# Final results
if [[ "$testsRun" -eq "$testsPassed" ]]; then
printf "\e[32mAll tests passed: %d/%d! :D\e[0m\n" "$testsPassed" "$testsRun"
exit 0
else
printf "\e[31mSome cases failing, only %d/%d passed.\e[0m\n" "$testsPassed" "$testsRun"
exit 1
fi
4 changes: 3 additions & 1 deletion scripts/testScripts/check_push.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# Tests for graded instance generation

# Runs all scripts put in ./tests and makes sure that the run at some point contains provided lines

# This script runs less intensive tests, intended for push requests rather than a PR
Expand All @@ -16,7 +18,7 @@ testsRun=0
start=$(date +%s)

# Loop through each script in the tests directory
for file in tests/*; do
for file in push_graded_tests/*; do
((testsRun++))
# Check if file
if [[ -f "$file" ]]; then
Expand Down
60 changes: 60 additions & 0 deletions scripts/testScripts/check_push_discrim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Tests for discriminating instance generation

# Runs all scripts put in ./tests and makes sure that the run at some point contains provided lines

# This script runs less intensive tests, intended for push requests rather than a PR

# Lines being checked for
lines=(
"instances where the base solver wins"
"too easy instances for the base solver"
"Info of discriminating instances is saved to"
)

testsPassed=0
testsRun=0

start=$(date +%s)

# Loop through each script in the tests directory
for file in push_discrim_tests/*; do
((testsRun++))
# Check if file
if [[ -f "$file" ]]; then

# Run contents of file
output=$(bash "$file")
all_lines_found=true

# Check for each line in the array
for line in "${lines[@]}"; do
if [[ "$output" != *"$line"* ]]; then
all_lines_found=false
echo "Test $testsRun: $file failed, line not found: $line"
fi
done

# If all lines are found, count as passed
if $all_lines_found; then
echo "Test $testsRun: $file passed, all lines found in output"
((testsPassed++))
fi
fi
# Record end time and calculate elapsed time
end=$(date +%s)
elapsedTime=$((end - start))

# Display time elapsed
echo "Time elapsed: $elapsedTime seconds"
done

# Final results
if [[ "$testsRun" -eq "$testsPassed" ]]; then
printf "\e[32mAll tests passed: %d/%d! :D\e[0m\n" "$testsPassed" "$testsRun"
exit 0
else
printf "\e[31mSome cases failing, only %d/%d passed.\e[0m\n" "$testsPassed" "$testsRun"
exit 1
fi
5 changes: 0 additions & 5 deletions scripts/testScripts/test.sh

This file was deleted.

0 comments on commit e48103b

Please sign in to comment.