From 6fe4d83694bb5de8cae6da3a3b694a400290a8a6 Mon Sep 17 00:00:00 2001 From: Pedro Mendes Date: Fri, 18 Oct 2024 15:47:17 -0400 Subject: [PATCH] test for task warnings --- tests/0509_Tasks/README.md | 14 +++++++ tests/0509_Tasks/run.sh | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tests/0509_Tasks/README.md create mode 100755 tests/0509_Tasks/run.sh diff --git a/tests/0509_Tasks/README.md b/tests/0509_Tasks/README.md new file mode 100644 index 0000000..09e9a68 --- /dev/null +++ b/tests/0509_Tasks/README.md @@ -0,0 +1,14 @@ +# 0509_Tasks + +tests errors/warnings related with setting up tasks + +## tests + +- 1D 2D, network, grid, transport, synaptic +- appropriate warning when model has scan over parameter sets +- appropriate warning when model has parameter scan +- appropriate warning when model cross section +- appropriate warning for model with a parameter estimation +- appropriate warning for model with a sensitivity analysis +- appropriate warning for model with optimization +- appropriate warning for model with active time course sensitivities diff --git a/tests/0509_Tasks/run.sh b/tests/0509_Tasks/run.sh new file mode 100755 index 0000000..253552e --- /dev/null +++ b/tests/0509_Tasks/run.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# work out our folder name +test=${PWD##*/} # to assign to a variable +test=${test:-/} # to correct for the case where PWD=/ + +fail=0 + +# test model that has scan over parameter sets +sbmodelr -t M1 ../sources/multimodel.cps 2 2 > output 2>&1 + +# check that the correct warning is issued +if ! grep -q " Warning: a scan of parameter sets exists in the original model but was not included in the new model." output; then + printf 'FAIL %s\n' "${test}" + let "fail = 1" +fi + +# check that the other warning is also issued +if ! grep -q " Warning: in Parameter scan task the scanned or sampled items were converted to those of the first unit only." output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 2" +fi + +# test model with a cross section +sbmodelr -t Y ../sources/crossect.cps 2 2 > output 2>&1 + +# check that the correct warning is issued for cross section +if ! grep -q " Warning: the cross section task was updated to use \[X_1,1\] as variable." output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 4" +fi + +# check that the correct warning is issued for parameter scan +if ! grep -q " Warning: in Parameter scan task the scanned or sampled items were converted to those of the first unit only." output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 8" +fi + +# test model with a sensitivity analysis +sbmodelr -t B ../sources/sens.cps 2 > output 2>&1 + +# check that the correct warning is issued +if ! grep -q " Warning: sensitivies task is now using items of unit " output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 16" +fi + +# test model with optimization +sbmodelr -t X ../sources/opt.cps 2 > output 2>&1 + +# check that the correct warning is issued +if ! grep -q " Warning: in Optimization task the objective function and the search parameters were converted to those of the first unit only." output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 32" +fi + +# test model with parameter estimation +sbmodelr -t E1 ../sources/pe_tcs.cps 2 > output 2>&1 + +# check that the correct warning is issued +if ! grep -q " Warning: Parameter Estimation task settings were not copied to the new model." output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 64" +fi + +# check that the correct warning is issued for time course sensitivities +if ! grep -q " Warning: Time Course Sensitivities task settings were not copied to the new model." output; then + printf 'FAIL %s\n' "${test}" + let "fail = $fail + 128" +fi + +if [ "$fail" = 0 ] ; then + printf 'PASS %s\n' "${test}" + rm output *.cps > /dev/null 2>&1 +fi + +exit $fail