forked from stacs-cp/AutoIG
-
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.
test: added tests to ensure that Conjure still works in the altered e…
…nvironment
- Loading branch information
Showing
18 changed files
with
271 additions
and
1 deletion.
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
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# Runs all scripts put in ./tests and makes sure that the run at some point contains a provided line: | ||
|
||
# Lines being checked for | ||
lines=( | ||
"# Best configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):" | ||
"# Best configurations as commandlines (first number is the configuration ID; same order as above):" | ||
) | ||
|
||
testsPassed=0 | ||
testsRun=0 | ||
|
||
start=$(date +%s) | ||
|
||
# Loop through each script in the tests directory | ||
for file in 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 |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
# Runs all scripts put in ./tests and makes sure that the run at some point contains a provided line: | ||
|
||
# Lines being checked for | ||
lines=( | ||
"Copying solution to: model-test.solution" | ||
) | ||
|
||
testsPassed=0 | ||
testsRun=0 | ||
|
||
start=$(date +%s) | ||
|
||
# Loop through each script in the tests directory | ||
for file in conjure_solve-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 for Conjure: %d/%d! :D\e[0m\n" "$testsPassed" "$testsRun" | ||
exit 0 | ||
else | ||
printf "\e[31mSome cases failing for Conjure, only %d/%d passed.\e[0m\n" "$testsPassed" "$testsRun" | ||
exit 1 | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
# Runs all scripts put in ./tests and makes sure that the run at some point contains a provided line: | ||
|
||
# Lines being checked for | ||
lines=( | ||
"# Best configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):" | ||
"# Best configurations as commandlines (first number is the configuration ID; same order as above):" | ||
) | ||
|
||
testsPassed=0 | ||
testsRun=0 | ||
|
||
start=$(date +%s) | ||
|
||
# Loop through each script in the tests directory | ||
for file in pr_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 | ||
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 | ||
|
||
# Record end time and calculate elapsed time | ||
end=$(date +%s) | ||
elapsedTime=$((end - start)) | ||
|
||
# Display time elapsed | ||
echo "Time elapsed: $elapsedTime seconds" |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
DATA_DIR=../essence_testing_data | ||
conjure solve model.essence test.param --solver=chuffed |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
DATA_DIR=../essence_testing_data | ||
conjure solve $DATA_DIR/model.essence $DATA_DIR/test.param --solver=or-tools |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language Essence 1.3 | ||
|
||
letting y be 6 |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
given x: int(1..10) | ||
find y: int(1..10) | ||
such that | ||
y > x |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
letting x be 5 |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# avoids having an error if directory already exists | ||
mkdir -p "$AUTOIG/experiments/macc-graded" | ||
cd "$AUTOIG/experiments/macc-graded" | ||
python3 "$AUTOIG/scripts/setup.py" --generatorModel "$AUTOIG/data/models/macc/generator.essence" --problemModel "$AUTOIG/data/models/macc/problem.mzn" --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver chuffed --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 3 | ||
|
||
bash "$AUTOIG/experiments/macc-graded/run.sh" |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
echo "reached the test.sh script" | ||
|
||
exit 0 # exit successful |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Description | ||
|
||
This is a directory which contains scripts to test various AutoIG runs using regex to test output | ||
|
||
To run this, put the commands to navigate to the AutoIG experiment directory, setup the project, and run it. See the general README for further instructions on running. | ||
|
||
The script will automatically scan the standard output, then output weather the output of each file contained the desired lines specified within the script. The lines need to exist independently in the output, not be sequential. | ||
|
||
After all tests are run, the script also outputs the number of passed tests / the number of failed tests, as well as time taken to run all of them. | ||
|
||
This is one of the same test script which will eventuall be integrated into the automated CI pipeline in GitHub, but can also be used manually. | ||
|
||
An example contents of a test may look like: | ||
|
||
## Within tests/macc-graded: | ||
|
||
`cd "AutoIG/experiments/macc-graded"` | ||
|
||
`python3 "\$AUTOIG/scripts/setup.py --generatorModel \$AUTOIG/data/models/macc/generator-small.essence --problemModel \$AUTOIG/data/models/macc/problem.mzn --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver chuffed --solverFlags=\"-f\" --maxEvaluations 180 --genSolverTimeLimit 5"` | ||
|
||
`bash "run.sh"` | ||
|
||
`cd "../.."` |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# avoids having an error if directory already exists | ||
echo "the variable is: " | ||
ls | ||
echo $AUTOIG | ||
mkdir -p "$AUTOIG/experiments/macc-graded-small-gen" | ||
cd "$AUTOIG/experiments/macc-graded-small-gen" | ||
python3 "$AUTOIG/scripts/setup.py" --generatorModel "$AUTOIG/data/models/macc/generator-small.essence" --problemModel "$AUTOIG/data/models/macc/problem.mzn" --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver chuffed --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 3 | ||
|
||
bash "$AUTOIG/experiments/macc-graded-small-gen/run.sh" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# avoids having an error if directory already exists | ||
echo "the variable is: " | ||
ls | ||
echo $AUTOIG | ||
mkdir -p "$AUTOIG/experiments/macc-graded-small-gen" | ||
cd "$AUTOIG/experiments/macc-graded-small-gen" | ||
python3 "$AUTOIG/scripts/setup.py" --generatorModel "$AUTOIG/data/models/macc/generator-small.essence" --problemModel "$AUTOIG/data/models/macc/problem.mzn" --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver cpsat --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 3 | ||
|
||
bash "$AUTOIG/experiments/macc-graded-small-gen/run.sh" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# avoids having an error if directory already exists | ||
echo "the variable is: " | ||
ls | ||
echo $AUTOIG | ||
mkdir -p "$AUTOIG/experiments/macc-graded-small-gen" | ||
cd "$AUTOIG/experiments/macc-graded-small-gen" | ||
python3 "$AUTOIG/scripts/setup.py" --generatorModel "$AUTOIG/data/models/macc/generator-small.essence" --problemModel "$AUTOIG/data/models/macc/problem.mzn" --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver gecode --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 3 | ||
|
||
bash "$AUTOIG/experiments/macc-graded-small-gen/run.sh" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# avoids having an error if directory already exists | ||
echo "the variable is: " | ||
ls | ||
echo $AUTOIG | ||
mkdir -p "$AUTOIG/experiments/macc-graded-small-gen" | ||
cd "$AUTOIG/experiments/macc-graded-small-gen" | ||
python3 "$AUTOIG/scripts/setup.py" --generatorModel "$AUTOIG/data/models/macc/generator-small.essence" --problemModel "$AUTOIG/data/models/macc/problem.mzn" --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver picat --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 3 | ||
|
||
bash "$AUTOIG/experiments/macc-graded-small-gen/run.sh" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# avoids having an error if directory already exists | ||
echo "the variable is: " | ||
ls | ||
echo $AUTOIG | ||
mkdir -p "$AUTOIG/experiments/macc-graded-small-gen" | ||
cd "$AUTOIG/experiments/macc-graded-small-gen" | ||
python3 "$AUTOIG/scripts/setup.py" --generatorModel "$AUTOIG/data/models/macc/generator-small.essence" --problemModel "$AUTOIG/data/models/macc/problem.mzn" --instanceSetting graded --minSolverTime 0 --maxSolverTime 5 --solver yuck --solverFlags="-f" --maxEvaluations 180 --genSolverTimeLimit 3 | ||
|
||
bash "$AUTOIG/experiments/macc-graded-small-gen/run.sh" |