Source code for spack.test.build_system_guess

# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import sys

import pytest

import spack.cmd.create
import spack.stage
import spack.util.executable

pytestmark = pytest.mark.skipif(sys.platform == "win32",
                                reason="does not run on windows")

[docs]@pytest.fixture( scope='function', params=[ ('configure', 'autotools'), ('CMakeLists.txt', 'cmake'), ('', 'qmake'), ('pom.xml', 'maven'), ('SConstruct', 'scons'), ('waf', 'waf'), ('argbah.rockspec', 'lua'), ('', 'python'), ('NAMESPACE', 'r'), ('WORKSPACE', 'bazel'), ('Makefile.PL', 'perlmake'), ('Build.PL', 'perlbuild'), ('foo.gemspec', 'ruby'), ('Rakefile', 'ruby'), ('setup.rb', 'ruby'), ('GNUmakefile', 'makefile'), ('makefile', 'makefile'), ('Makefile', 'makefile'), ('', 'meson'), ('', 'sip'), ('foobar', 'generic') ] ) def url_and_build_system(request, tmpdir): """Sets up the resources to be pulled by the stage with the appropriate file name and returns their url along with the correct build-system guess """ tar = spack.util.executable.which('tar') orig_dir = tmpdir.chdir() filename, system = request.param tmpdir.ensure('archive', filename) tar('czf', 'archive.tar.gz', 'archive') url = 'file://' + str(tmpdir.join('archive.tar.gz')) yield url, system orig_dir.chdir()
[docs]def test_build_systems(url_and_build_system): url, build_system = url_and_build_system with spack.stage.Stage(url) as stage: stage.fetch() guesser = spack.cmd.create.BuildSystemGuesser() guesser(stage, url) assert build_system == guesser.build_system