Skip to content

Commit

Permalink
Add mechanism to skip Brian tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Jul 28, 2023
1 parent 8028d5d commit c30a2df
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion scripts/run_brian_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion scripts/run_brian_tests_32bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion scripts/run_brian_tests_CPU.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion scripts/run_brian_tests_CPU_32bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 5 additions & 0 deletions scripts/skip_tests.txt
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions scripts/test_utils.py
Original file line number Diff line number Diff line change
@@ -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('#')]

0 comments on commit c30a2df

Please sign in to comment.