added -s option to test to skip time consuming tests. also updated readme accordingly

This commit is contained in:
PatchOfScotland
2023-03-16 13:25:44 +01:00
parent a7f910ecff
commit 9547df7612
3 changed files with 43 additions and 4 deletions

View File

@ -12,7 +12,12 @@ The most import definitions are the BasePattern, and BaseRecipe, which define th
The way to run a MEOW system is to create and MeowRunner instance, found in **core/runner.py**. This will take 1 or more Monitors, 1 or more Handlers, and 1 or more Conductors. In turn, these will listen for events, respond to events, and execute any analysis identified. Examples of how this can be run can be found in **tests/testRunner.py** The way to run a MEOW system is to create and MeowRunner instance, found in **core/runner.py**. This will take 1 or more Monitors, 1 or more Handlers, and 1 or more Conductors. In turn, these will listen for events, respond to events, and execute any analysis identified. Examples of how this can be run can be found in **tests/testRunner.py**
## Testing ## Testing
Pytest unittests are provided within the 'tests directory, as well as a script **test_all.sh** for calling all test scripts from a single command. Individual test scripts can be started using: Pytest unittests are provided within the 'tests directory, as well as a script **test_all.sh** for calling all test scripts from a single command. This can be
run as:
test_all.sh -s
This will skip the more time consuming tests if you just need quick feedback. Without the -s argument then all tests will be run. Individual test scripts can be started using:
pytest test_runner.py::MeowTests -W ignore::DeprecationWarning pytest test_runner.py::MeowTests -W ignore::DeprecationWarning

View File

@ -7,15 +7,31 @@ starting_working_dir=$(pwd)
script_name=$(basename "$0") script_name=$(basename "$0")
script_dir=$(dirname "$(realpath "$0")") script_dir=$(dirname "$(realpath "$0")")
skip_long_tests=0
for arg in "$@"
do
echo "Given arg: $arg";
if [[ $arg == -s ]]
then
echo "skippy the kangaroo"
skip_long_tests=1
fi
done
cd $script_dir cd $script_dir
# Gather all other test files and run pytest # Gather all other test files and run pytest
search_dir=. search_dir=.
for entry in "$search_dir"/* for entry in "$search_dir"/*
do do
if [[ $entry == ./test* ]] && [[ -f $entry ]] && [[ $entry != ./$script_name ]] && [[ $entry != ./shared.py ]]; if [[ $entry == ./test* ]] \
&& [[ -f $entry ]] \
&& [[ $entry != ./$script_name ]] \
&& [[ $entry != ./shared.py ]];
then then
pytest $entry "-W ignore::DeprecationWarning" SKIP_LONG=$skip_long_tests pytest $entry "-W ignore::DeprecationWarning"
# SKIP_LONG=$skip_long_tests pytest $entry
fi fi
done done

View File

@ -3,10 +3,11 @@ import io
import importlib import importlib
import os import os
import unittest import unittest
from random import shuffle from random import shuffle
from shutil import copy from shutil import copy
from time import sleep from time import sleep
from warnings import warn
from meow_base.core.base_conductor import BaseConductor from meow_base.core.base_conductor import BaseConductor
from meow_base.core.base_handler import BaseHandler from meow_base.core.base_handler import BaseHandler
@ -116,6 +117,7 @@ recipe_generator = JupyterNotebookRecipe(
requirements={recipe_generator_key: recipe_generator_req} requirements={recipe_generator_key: recipe_generator_req}
) )
class MeowTests(unittest.TestCase): class MeowTests(unittest.TestCase):
def setUp(self)->None: def setUp(self)->None:
super().setUp() super().setUp()
@ -970,6 +972,10 @@ class MeowTests(unittest.TestCase):
# Test some actual scientific analysis, but in a simple progression # Test some actual scientific analysis, but in a simple progression
def testScientificAnalysisAllGood(self)->None: def testScientificAnalysisAllGood(self)->None:
if os.environ["SKIP_LONG"]:
warn("Skipping testScientificAnalysisAllGood")
return
patterns = { patterns = {
'pattern_check': pattern_check, 'pattern_check': pattern_check,
'pattern_segment': pattern_segment, 'pattern_segment': pattern_segment,
@ -1090,6 +1096,10 @@ class MeowTests(unittest.TestCase):
# Test some actual scientific analysis, in a predicatable loop # Test some actual scientific analysis, in a predicatable loop
def testScientificAnalysisPredictableLoop(self)->None: def testScientificAnalysisPredictableLoop(self)->None:
if os.environ["SKIP_LONG"]:
warn("Skipping testScientificAnalysisPredictableLoop")
return
patterns = { patterns = {
'pattern_check': pattern_check, 'pattern_check': pattern_check,
'pattern_segment': pattern_segment, 'pattern_segment': pattern_segment,
@ -1225,6 +1235,10 @@ class MeowTests(unittest.TestCase):
# Test some actual scientific analysis, in an unpredicatable loop # Test some actual scientific analysis, in an unpredicatable loop
def testScientificAnalysisRandomLoop(self)->None: def testScientificAnalysisRandomLoop(self)->None:
if os.environ["SKIP_LONG"]:
warn("Skipping testScientificAnalysisRandomLoop")
return
pattern_regenerate_random = FileEventPattern( pattern_regenerate_random = FileEventPattern(
"pattern_regenerate_random", "pattern_regenerate_random",
os.path.join("foam_ct_data_discarded", "*"), os.path.join("foam_ct_data_discarded", "*"),
@ -1373,6 +1387,10 @@ class MeowTests(unittest.TestCase):
# Test some actual scientific analysis, in an unpredicatable loop # Test some actual scientific analysis, in an unpredicatable loop
def testScientificAnalysisMassiveRandomLoop(self)->None: def testScientificAnalysisMassiveRandomLoop(self)->None:
if os.environ["SKIP_LONG"]:
warn("Skipping testScientificAnalysisMassiveRandomLoop")
return
pattern_regenerate_random = FileEventPattern( pattern_regenerate_random = FileEventPattern(
"pattern_regenerate_random", "pattern_regenerate_random",
os.path.join("foam_ct_data_discarded", "*"), os.path.join("foam_ct_data_discarded", "*"),