summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2019-09-23 10:18:50 -0700
committerGitHub <noreply@github.com>2019-09-23 10:18:50 -0700
commit08e77e1b41738abda7613247c7fcf64734c70039 (patch)
treeaf1d50a26181c102da18d5427689c91a14d06cb4 /lib
parent27d4e9a1d1e869bf6567deef56bda4fb70e46e5e (diff)
downloadspack-08e77e1b41738abda7613247c7fcf64734c70039.tar.gz
spack-08e77e1b41738abda7613247c7fcf64734c70039.tar.bz2
spack-08e77e1b41738abda7613247c7fcf64734c70039.tar.xz
spack-08e77e1b41738abda7613247c7fcf64734c70039.zip
tests: more template creation tests (#12882)
Addresses #12804 This PR adds the creation of the remaining (16) templates to ensure we can create them with expected content. The goal is to facilitate catching during testing.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/cmd/create.py58
1 files changed, 50 insertions, 8 deletions
diff --git a/lib/spack/spack/test/cmd/create.py b/lib/spack/spack/test/cmd/create.py
index 030140c74e..27d2b252bb 100644
--- a/lib/spack/spack/test/cmd/create.py
+++ b/lib/spack/spack/test/cmd/create.py
@@ -24,23 +24,65 @@ def parser():
return prs
-@pytest.mark.parametrize('args,name_index,expected', [
- (['test-package'], 0, [r'TestPackage(Package)', r'def install(self']),
- (['-n', 'test-named-package', 'file://example.tar.gz'], 1,
+@pytest.mark.parametrize('args,name,expected', [
+ # Basic package cases
+ (['test-package'], 'test-package',
+ [r'TestPackage(Package)', r'def install(self']),
+ (['-n', 'test-named-package', 'file://example.tar.gz'],
+ 'test-named-package',
[r'TestNamedPackage(Package)', r'def install(self']),
- (['file://example.tar.gz'], -1,
+ (['file://example.tar.gz'], 'example',
[r'Example(Package)', r'def install(self']),
- (['-t', 'bundle', 'test-bundle'], 2, [r'TestBundle(BundlePackage)'])
+
+ # Template-specific cases
+ (['-t', 'autoreconf', 'test-autoreconf'], 'test-autoreconf',
+ [r'TestAutoreconf(AutotoolsPackage)', r"depends_on('autoconf",
+ r'def autoreconf(self', r'def configure_args(self']),
+ (['-t', 'autotools', 'test-autotools'], 'test-autotools',
+ [r'TestAutotools(AutotoolsPackage)', r'def configure_args(self']),
+ (['-t', 'bazel', 'test-bazel'], 'test-bazel',
+ [r'TestBazel(Package)', r"depends_on('bazel", r'bazel()']),
+ (['-t', 'bundle', 'test-bundle'], 'test-bundle',
+ [r'TestBundle(BundlePackage)']),
+ (['-t', 'cmake', 'test-cmake'], 'test-cmake',
+ [r'TestCmake(CMakePackage)', r'def cmake_args(self']),
+ (['-t', 'intel', 'test-intel'], 'test-intel',
+ [r'TestIntel(IntelPackage)', r'setup_environment']),
+ (['-t', 'makefile', 'test-makefile'], 'test-makefile',
+ [r'TestMakefile(MakefilePackage)', r'def edit(self', r'makefile']),
+ (['-t', 'meson', 'test-meson'], 'test-meson',
+ [r'TestMeson(MesonPackage)', r'def meson_args(self']),
+ (['-t', 'octave', 'test-octave'], 'octave-test-octave',
+ [r'OctaveTestOctave(OctavePackage)', r"extends('octave",
+ r"depends_on('octave"]),
+ (['-t', 'perlbuild', 'test-perlbuild'], 'perl-test-perlbuild',
+ [r'PerlTestPerlbuild(PerlPackage)', r"depends_on('perl-module-build",
+ r'def configure_args(self']),
+ (['-t', 'perlmake', 'test-perlmake'], 'perl-test-perlmake',
+ [r'PerlTestPerlmake(PerlPackage)', r"depends_on('perl-",
+ r'def configure_args(self']),
+ (['-t', 'python', 'test-python'], 'py-test-python',
+ [r'PyTestPython(PythonPackage)', r"depends_on('py-",
+ r'def build_args(self']),
+ (['-t', 'qmake', 'test-qmake'], 'test-qmake',
+ [r'TestQmake(QMakePackage)', r'def qmake_args(self']),
+ (['-t', 'r', 'test-r'], 'r-test-r',
+ [r'RTestR(RPackage)', r"depends_on('r-", r'def configure_args(self']),
+ (['-t', 'scons', 'test-scons'], 'test-scons',
+ [r'TestScons(SConsPackage)', r'def build_args(self']),
+ (['-t', 'sip', 'test-sip'], 'py-test-sip',
+ [r'PyTestSip(SIPPackage)', r'def configure_args(self']),
+ (['-t', 'waf', 'test-waf'], 'test-waf',
+ [r'TestWaf(WafPackage)', r'configure_args()'])
])
-def test_create_template(parser, mock_test_repo, args, name_index, expected):
+def test_create_template(parser, mock_test_repo, args, name, expected):
"""Test template creation."""
repo, repodir = mock_test_repo
constr_args = parser.parse_args(['--skip-editor'] + args)
spack.cmd.create.create(parser, constr_args)
- pkg_name = args[name_index] if name_index > -1 else 'example'
- filename = repo.filename_for_package_name(pkg_name)
+ filename = repo.filename_for_package_name(name)
assert os.path.exists(filename)
with open(filename, 'r') as package_file: