diff options
author | AcriusWinter <152348900+AcriusWinter@users.noreply.github.com> | 2024-08-08 22:23:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 23:23:05 -0600 |
commit | 899ac7888761746b735089473873a68c45c7cfb4 (patch) | |
tree | 1854af363776d6b12bce1a6b68c20ce473c7bc75 | |
parent | 7bec524dd5b8055eab7bd06ac820c1df47bf6ddf (diff) | |
download | spack-899ac7888761746b735089473873a68c45c7cfb4.tar.gz spack-899ac7888761746b735089473873a68c45c7cfb4.tar.bz2 spack-899ac7888761746b735089473873a68c45c7cfb4.tar.xz spack-899ac7888761746b735089473873a68c45c7cfb4.zip |
cxx: new test API (#45462)
* cxx: new test API
* gcc: provide cxx
* default providers: cxx provided by gcc
* cxx: cleanup stand-alone test
- test_c -> test_cxx
- simplify compilation and execution
- corrected output checks
---------
Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
-rw-r--r-- | etc/spack/defaults/packages.yaml | 1 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/cxx/package.py | 45 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/gcc/package.py | 2 |
3 files changed, 25 insertions, 23 deletions
diff --git a/etc/spack/defaults/packages.yaml b/etc/spack/defaults/packages.yaml index 25a707e4dd..38bc2014d5 100644 --- a/etc/spack/defaults/packages.yaml +++ b/etc/spack/defaults/packages.yaml @@ -20,6 +20,7 @@ packages: awk: [gawk] armci: [armcimpi] blas: [openblas, amdblis] + cxx: [gcc] D: [ldc] daal: [intel-oneapi-daal] elf: [elfutils] diff --git a/var/spack/repos/builtin/packages/cxx/package.py b/var/spack/repos/builtin/packages/cxx/package.py index c34e8af7bb..bedd235fd8 100644 --- a/var/spack/repos/builtin/packages/cxx/package.py +++ b/var/spack/repos/builtin/packages/cxx/package.py @@ -14,28 +14,27 @@ class Cxx(Package): homepage = "https://isocpp.org/std/the-standard" virtual = True - def test(self): - test_source = self.test_suite.current_test_data_dir + def test_cxx(self): + """Compile and run 'Hello World'""" + cxx = which(os.environ["CXX"]) + expected = ["Hello world", "YES!"] + test_source = self.test_suite.current_test_data_dir for test in os.listdir(test_source): - filepath = os.path.join(test_source, test) - exe_name = "%s.exe" % test - - cxx_exe = os.environ["CXX"] - - # standard options - # Hack to get compiler attributes - # TODO: remove this when compilers are dependencies - c_name = clang if self.spec.satisfies("llvm+clang") else self.name - c_spec = spack.spec.CompilerSpec(c_name, self.spec.version) - c_cls = spack.compilers.class_for_compiler_name(c_name) - compiler = c_cls(c_spec, None, None, ["fakecc", "fakecxx"]) - - cxx_opts = [compiler.cxx11_flag] if "c++11" in test else [] - - cxx_opts += ["-o", exe_name, filepath] - compiled = self.run_test(cxx_exe, options=cxx_opts, installed=True) - - if compiled: - expected = ["Hello world", "YES!"] - self.run_test(exe_name, expected=expected) + exe_name = f"{test}.exe" + filepath = test_source.join(test) + with test_part(self, f"test_cxx_{test}", f"build and run {exe_name}"): + # standard options + # Hack to get compiler attributes + # TODO: remove this when compilers are dependencies + c_name = clang if self.spec.satisfies("llvm+clang") else self.name + c_spec = spack.spec.CompilerSpec(c_name, self.spec.version) + c_cls = spack.compilers.class_for_compiler_name(c_name) + compiler = c_cls(c_spec, None, None, ["fakecc", "fakecxx"]) + cxx_opts = [compiler.cxx11_flag] if "c++11" in test else [] + cxx_opts += ["-o", exe_name, filepath] + + cxx(*cxx_opts) + exe = which(exe_name) + out = exe(output=str.split, error=str.split) + check_outputs(expected, out) diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py index 81e325feda..0a91eb83d8 100644 --- a/var/spack/repos/builtin/packages/gcc/package.py +++ b/var/spack/repos/builtin/packages/gcc/package.py @@ -34,6 +34,8 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage): license("GPL-2.0-or-later AND LGPL-2.1-or-later") + provides("cxx") + version("master", branch="master") version("14.2.0", sha256="a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9") |