From 262ab401884a8b46992872b8c010fa844cb14271 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 5 Jul 2016 11:33:29 -0500 Subject: Update build_system_guess test with new class name --- lib/spack/spack/test/__init__.py | 2 +- lib/spack/spack/test/build_system_guess.py | 89 ++++++++++++++++++++++++++++++ lib/spack/spack/test/configure_guess.py | 83 ---------------------------- 3 files changed, 90 insertions(+), 84 deletions(-) create mode 100644 lib/spack/spack/test/build_system_guess.py delete mode 100644 lib/spack/spack/test/configure_guess.py (limited to 'lib') diff --git a/lib/spack/spack/test/__init__.py b/lib/spack/spack/test/__init__.py index fb91f24721..19bc1d89d3 100644 --- a/lib/spack/spack/test/__init__.py +++ b/lib/spack/spack/test/__init__.py @@ -38,7 +38,7 @@ test_names = ['architecture', 'versions', 'url_parse', 'url_substitution', 'pack 'directory_layout', 'pattern', 'python_version', 'git_fetch', 'svn_fetch', 'hg_fetch', 'mirror', 'modules', 'url_extrapolate', 'cc', 'link_tree', 'spec_yaml', 'optional_deps', - 'make_executable', 'configure_guess', 'lock', 'database', + 'make_executable', 'build_system_guess', 'lock', 'database', 'namespace_trie', 'yaml', 'sbang', 'environment', 'cmd.find', 'cmd.uninstall', 'cmd.test_install', 'cmd.test_compiler_cmd'] diff --git a/lib/spack/spack/test/build_system_guess.py b/lib/spack/spack/test/build_system_guess.py new file mode 100644 index 0000000000..80b867a528 --- /dev/null +++ b/lib/spack/spack/test/build_system_guess.py @@ -0,0 +1,89 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# 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 terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +import os +import shutil +import tempfile +import unittest + +from llnl.util.filesystem import * +from spack.cmd.create import BuildSystemGuesser +from spack.stage import Stage +from spack.test.mock_packages_test import * +from spack.util.executable import which + + +class InstallTest(unittest.TestCase): + """Tests the build system guesser in spack create""" + + def setUp(self): + self.tar = which('tar') + self.tmpdir = tempfile.mkdtemp() + self.orig_dir = os.getcwd() + os.chdir(self.tmpdir) + self.stage = None + + + def tearDown(self): + shutil.rmtree(self.tmpdir, ignore_errors=True) + os.chdir(self.orig_dir) + + + def check_archive(self, filename, system): + mkdirp('archive') + touch(join_path('archive', filename)) + self.tar('czf', 'archive.tar.gz', 'archive') + + url = 'file://' + join_path(os.getcwd(), 'archive.tar.gz') + print url + with Stage(url) as stage: + stage.fetch() + + guesser = BuildSystemGuesser() + guesser(stage, url) + self.assertEqual(system, guesser.build_system) + + + def test_autotools(self): + self.check_archive('configure', 'autotools') + + + def test_cmake(self): + self.check_archive('CMakeLists.txt', 'cmake') + + + def test_scons(self): + self.check_archive('SConstruct', 'scons') + + + def test_python(self): + self.check_archive('setup.py', 'python') + + + def test_R(self): + self.check_archive('NAMESPACE', 'R') + + + def test_unknown(self): + self.check_archive('foobar', 'unknown') diff --git a/lib/spack/spack/test/configure_guess.py b/lib/spack/spack/test/configure_guess.py deleted file mode 100644 index bad3673e7a..0000000000 --- a/lib/spack/spack/test/configure_guess.py +++ /dev/null @@ -1,83 +0,0 @@ -############################################################################## -# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. -# Produced at the Lawrence Livermore National Laboratory. -# -# This file is part of Spack. -# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. -# LLNL-CODE-647188 -# -# For details, see https://github.com/llnl/spack -# Please also see the LICENSE file for our notice and the LGPL. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License (as -# published by the Free Software Foundation) version 2.1, February 1999. -# -# 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 terms and -# conditions of the GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -############################################################################## -import os -import shutil -import tempfile -import unittest - -from llnl.util.filesystem import * -from spack.cmd.create import ConfigureGuesser -from spack.stage import Stage -from spack.test.mock_packages_test import * -from spack.util.executable import which - - -class InstallTest(unittest.TestCase): - """Tests the configure guesser in spack create""" - - def setUp(self): - self.tar = which('tar') - self.tmpdir = tempfile.mkdtemp() - self.orig_dir = os.getcwd() - os.chdir(self.tmpdir) - self.stage = None - - - def tearDown(self): - shutil.rmtree(self.tmpdir, ignore_errors=True) - os.chdir(self.orig_dir) - - - def check_archive(self, filename, system): - mkdirp('archive') - touch(join_path('archive', filename)) - self.tar('czf', 'archive.tar.gz', 'archive') - - url = 'file://' + join_path(os.getcwd(), 'archive.tar.gz') - print url - with Stage(url) as stage: - stage.fetch() - - guesser = ConfigureGuesser() - guesser(stage) - self.assertEqual(system, guesser.build_system) - - - def test_python(self): - self.check_archive('setup.py', 'python') - - - def test_autotools(self): - self.check_archive('configure', 'autotools') - - - def test_cmake(self): - self.check_archive('CMakeLists.txt', 'cmake') - - - def test_unknown(self): - self.check_archive('foobar', 'unknown') - - -- cgit v1.2.3-60-g2f50