spack/var/spack/repos/builtin/packages/c/package.py
AcriusWinter 63e680e4f9
c: new test API (#45469)
* c: new test API
* gcc:  provides('c')
* c: bugfix and simplification of the new stand-alone test method

---------

Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
2024-08-12 15:58:09 -06:00

31 lines
997 B
Python

# Copyright 2013-2024 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 os
from spack.package import *
class C(Package):
"""Virtual package for C compilers."""
homepage = "http://open-std.org/JTC1/SC22/WG14/www/standards"
virtual = True
def test_c(self):
"""build and run C examples"""
cc = which(os.environ["CC"])
expected = ["Hello world", "YES!"]
test_source = self.test_suite.current_test_data_dir
for test in os.listdir(test_source):
exe_name = f"{test}.exe"
with test_part(self, f"test_c_{test}", f"build and run {exe_name}"):
filepath = join_path(test_source, test)
cc("-o", exe_name, filepath)
exe = which(exe_name)
out = exe(output=str.split, error=str.split)
check_outputs(expected, out)