Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added system test for testing compiler.
  • Loading branch information
BryanRumsey committed Apr 27, 2023
commit f3c0f6ef794bea0bd35f1e8d65dc53a54b47c1aa
30 changes: 30 additions & 0 deletions .github/workflows/run_system_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run SpatialPy System Tests

on:
push:
branches: [staging, develop]

jobs:
run-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]

steps:
- name: Initialize environment
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install coverage

- name: Run tests
run: coverage run --source=spatialpy test/run_system_tests.py
Empty file added test/__init__.py
Empty file.
46 changes: 46 additions & 0 deletions test/run_system_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
# SpatialPy is a Python 3 package for simulation of
# spatial deterministic/stochastic reaction-diffusion-advection problems
# Copyright (C) 2019 - 2023 SpatialPy developers.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
# published by the Free Software Foundation.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU GENERAL PUBLIC LICENSE Version 3 for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import unittest
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('-m', '--mode', default='develop', choices=['develop', 'release'],
help='Run system tests in develop mode or release mode.')

if __name__ == '__main__':
args = parser.parse_args()
if args.mode == 'develop':
print('Running system tests in develop mode. Appending repository directory to system path.')
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from system_tests import test_compiler

modules = [
test_compiler
]

for module in modules:
suite = unittest.TestLoader().loadTestsFromModule(module)
runner = unittest.TextTestRunner(failfast=args.mode == 'develop')

print(f"Executing: {module}")
result = runner.run(suite)
print('=' * 70)
if not result.wasSuccessful():
sys.exit(not result.wasSuccessful())
Empty file added test/system_tests/__init__.py
Empty file.
40 changes: 40 additions & 0 deletions test/system_tests/test_compiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# SpatialPy is a Python 3 package for simulation of
# spatial deterministic/stochastic reaction-diffusion-advection problems
# Copyright (C) 2019 - 2023 SpatialPy developers.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as
# published by the Free Software Foundation.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU GENERAL PUBLIC LICENSE Version 3 for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
''' Tests from the compiler. '''
import os
import sys
print(os.getcwd())
sys.path.insert(1, os.path.abspath(os.getcwd()))
import unittest

from test.models.birth_death import create_birth_death

class TestCompiler(unittest.TestCase):
'''
################################################################################################
System test for compiler.
################################################################################################
'''
def setUp(self):
self.model = create_birth_death()

def test_constructor(self):
""" Test the compiler. """
_ = self.model.run()

if __name__ == '__main__':
unittest.main()