Skip to content

Commit

Permalink
[spack] Add test support
Browse files Browse the repository at this point in the history
  • Loading branch information
muffgaga committed Nov 26, 2021
1 parent 5f8afe0 commit 848de21
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *
import glob


class Genn(PythonPackage):
Expand All @@ -16,23 +17,30 @@ class Genn(PythonPackage):
version('4.6.0', sha256='5e5ca94fd3a56b5b963a4911ea1b2130df6fa7dcdde3b025bd8cb85d4c2d3236')

conflicts('%gcc@:4.9.3')
depends_on('gmake', type='build')
depends_on('gmake', type='build')
depends_on('googletest', type=('build', 'run', 'test'))
depends_on('lcov', type=('build', 'run', 'test'))

variant('cuda', default=True, description='Enable CUDA support')
depends_on('cuda', when='+cuda')

variant('python', default=True, description='Enable PyGeNN')
extends('python', when='+python')
depends_on('[email protected]:', when='+python')
depends_on('[email protected]:', when='+python')
depends_on('py-six', when='+python')
depends_on('py-deprecated', when='+python')
depends_on('py-psutil', when='+python')
depends_on('[email protected]:', when='+python')
depends_on('swig', when='+python')
depends_on('[email protected]:', when='+python', type=('build', 'run', 'test'))
depends_on('[email protected]:', when='+python', type=('build', 'run', 'test'))
depends_on('py-six', when='+python', type=('build', 'run', 'test'))
depends_on('py-deprecated', when='+python', type=('build', 'run', 'test'))
depends_on('py-psutil', when='+python', type=('build', 'run', 'test'))
depends_on('[email protected]:', when='+python', type=('build', 'run', 'test'))
depends_on('swig', when='+python', type=('build', 'run', 'test'))

patch('include_path.patch')

def patch(self):
files = glob.glob("tests/**/Makefile", recursive=True)
filter_file('\$\(GTEST_DIR\)/src/gtest-all\.cc \$\(GTEST_DIR\)/src/gtest_main\.cc',
'-L$(GTEST_DIR) -lgtest', *files)

def build(self, spec, prefix):
make('PREFIX={}'.format(prefix), 'install')
if '+python' in self.spec:
Expand All @@ -44,6 +52,8 @@ def install(self, spec, prefix):
install_tree('include', prefix.include)
mkdirp(prefix.src.genn)
install_tree('src/genn', prefix.src.genn)
install_tree('tests', prefix.tests)
install('version.txt', prefix)
if '+python' in self.spec:
super(Genn, self).install(spec, prefix)

Expand All @@ -53,3 +63,17 @@ def setup_run_environment(self, env):
env.append_path('CUDA_PATH', self.spec['cuda'].prefix)
if '+python' in self.spec:
super(Genn, self).setup_run_environment(env)

def test(self):
env['GTEST_DIR'] = self.spec['googletest'].prefix
# workaround for https://github.com/spack/spack/issues/20553
env['PATH'] = '{}:{}'.format(self.spec['lcov'].prefix.bin, env['PATH'])
# overriding automatic python testing
with working_dir(self.prefix.tests):
# FIXME:
# * expects a non-zero return code for errors
# * also too slow for a simple install test?
# ⇒ provide another simple install test?
self.run_test('run_tests.sh')
if '+python' in self.spec:
super(Genn, self).test(self)

0 comments on commit 848de21

Please sign in to comment.