From c30a2df3b8c9ca411f6c8f621b021d9a4bd9a062 Mon Sep 17 00:00:00 2001 From: Marcel Stimberg Date: Fri, 28 Jul 2023 10:43:07 +0200 Subject: [PATCH] Add mechanism to skip Brian tests --- scripts/run_brian_tests.py | 6 +++++- scripts/run_brian_tests_32bit.py | 6 +++++- scripts/run_brian_tests_CPU.py | 6 +++++- scripts/run_brian_tests_CPU_32bit.py | 6 +++++- scripts/skip_tests.txt | 5 +++++ scripts/test_utils.py | 11 +++++++++++ 6 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 scripts/skip_tests.txt create mode 100644 scripts/test_utils.py diff --git a/scripts/run_brian_tests.py b/scripts/run_brian_tests.py index 41b85bc3..4d50e47a 100644 --- a/scripts/run_brian_tests.py +++ b/scripts/run_brian_tests.py @@ -3,9 +3,13 @@ import brian2genn import brian2 +import test_utils +skip_args = test_utils.get_skip_args() + if __name__ == '__main__': success = brian2.test([], test_codegen_independent=False, test_standalone='genn', - fail_for_not_implemented=False) + fail_for_not_implemented=False, + additional_args=skip_args) if not success: sys.exit(1) \ No newline at end of file diff --git a/scripts/run_brian_tests_32bit.py b/scripts/run_brian_tests_32bit.py index 9701d710..e5ff903b 100644 --- a/scripts/run_brian_tests_32bit.py +++ b/scripts/run_brian_tests_32bit.py @@ -5,10 +5,14 @@ import numpy as np +import test_utils +skip_args = test_utils.get_skip_args() + if __name__ == '__main__': success = brian2.test([], test_codegen_independent=False, test_standalone='genn', fail_for_not_implemented=False, - float_dtype=np.float32) + float_dtype=np.float32, + additional_args=skip_args) if not success: sys.exit(1) diff --git a/scripts/run_brian_tests_CPU.py b/scripts/run_brian_tests_CPU.py index 30c46880..ac1afe86 100644 --- a/scripts/run_brian_tests_CPU.py +++ b/scripts/run_brian_tests_CPU.py @@ -3,11 +3,15 @@ import brian2genn import brian2 +import test_utils +skip_args = test_utils.get_skip_args() + if __name__ == '__main__': success = brian2.test([], test_codegen_independent=False, test_standalone='genn', build_options={'use_GPU': False}, fail_for_not_implemented=False, - reset_preferences=False) + reset_preferences=False, + additional_args=skip_args + ['--collect-only']) if not success: sys.exit(1) diff --git a/scripts/run_brian_tests_CPU_32bit.py b/scripts/run_brian_tests_CPU_32bit.py index fefd0ff4..20c4eb5c 100644 --- a/scripts/run_brian_tests_CPU_32bit.py +++ b/scripts/run_brian_tests_CPU_32bit.py @@ -5,12 +5,16 @@ import brian2genn import brian2 +import test_utils +skip_args = test_utils.get_skip_args() + if __name__ == '__main__': success = brian2.test([], test_codegen_independent=False, test_standalone='genn', build_options={'use_GPU': False}, fail_for_not_implemented=False, float_dtype=np.float32, - reset_preferences=False) + reset_preferences=False, + additional_args=skip_args) if not success: sys.exit(1) diff --git a/scripts/skip_tests.txt b/scripts/skip_tests.txt new file mode 100644 index 00000000..703df813 --- /dev/null +++ b/scripts/skip_tests.txt @@ -0,0 +1,5 @@ +# A list of test name prefixes to skip (usually because they are marked as "standalone-compatible", but make assumptions +# that are only valid for C++ standalone). +# Test names have to use pytest's syntax, i.e. "test_name.py::test_function". Note that these are *prefixes*, so all +# tests with names starting with the given prefix will be skipped. +test_network.py::test_profile \ No newline at end of file diff --git a/scripts/test_utils.py b/scripts/test_utils.py new file mode 100644 index 00000000..3c9e34b3 --- /dev/null +++ b/scripts/test_utils.py @@ -0,0 +1,11 @@ +""" +Utility functions for testing. +""" +from pathlib import Path +def get_skip_args(): + fname = Path(__file__).parent / 'skip_tests.txt' + if not fname.exists(): + return [] + with open(fname) as f: + lines = f.readlines() + return ["--deselect="+line.strip() for line in lines if line.strip() and not line.startswith('#')]