diff options
-rw-r--r-- | var/spack/repos/builtin/packages/swig/package.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/swig/package.py b/var/spack/repos/builtin/packages/swig/package.py index ce47d71c80..4cf58e8bea 100644 --- a/var/spack/repos/builtin/packages/swig/package.py +++ b/var/spack/repos/builtin/packages/swig/package.py @@ -70,3 +70,45 @@ class Swig(AutotoolsPackage, SourceforgePackage): @when(_version) def autoreconf(self, spec, prefix): which('sh')('./autogen.sh') + + @property + def _installed_exe(self): + return join_path(self.prefix, 'bin', 'swig') + + def _test_version(self): + version = str(self.version) + if version.endswith('-fortran'): + version = version.replace('-', r'\+') + elif version in ('fortran', 'master'): + version = r'.*' + + self.run_test(self._installed_exe, + '-version', + expected=[r'SWIG Version {0}'.format(version)], + purpose="test: version") + + def _test_swiglib(self): + # Get SWIG's alleged path to library files + swig = Executable(self._installed_exe) + swiglib = swig('-swiglib', output=str).strip() + + # Check that the lib dir exists + if not os.path.isdir(swiglib): + msg = "SWIG library does not exist at '{0}'".format(swiglib) + self.test_failures.append([None, msg]) + + # Check for existence of other critical SWIG library files + swigfile = join_path(swiglib, 'swig.swg') + if not os.path.exists(swigfile): + msg = "SWIG runtime does not exist at '{0}'".format(swigfile) + self.test_failures.append([None, msg]) + if 'fortran' in str(self.version): + swigfile = join_path(swiglib, 'fortran', 'fortran.swg') + if not os.path.exists(swigfile): + msg = "SWIG+Fortran runtime does not exist at '{0}'".format( + swigfile) + self.test_failures.append([None, msg]) + + def test(self): + self._test_version() + self._test_swiglib() |