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>
This commit is contained in:
AcriusWinter 2024-08-12 14:58:09 -07:00 committed by GitHub
parent 27557a133b
commit 63e680e4f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 12 deletions

View File

@ -20,6 +20,7 @@ packages:
awk: [gawk]
armci: [armcimpi]
blas: [openblas, amdblis]
c: [gcc]
cxx: [gcc]
D: [ldc]
daal: [intel-oneapi-daal]

View File

@ -14,17 +14,17 @@ class C(Package):
homepage = "http://open-std.org/JTC1/SC22/WG14/www/standards"
virtual = True
def test(self):
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):
filepath = test_source.join(test)
exe_name = "%s.exe" % test
cc_exe = os.environ["CC"]
cc_opts = ["-o", exe_name, filepath]
compiled = self.run_test(cc_exe, options=cc_opts, installed=True)
if compiled:
expected = ["Hello world", "YES!"]
self.run_test(exe_name, expected=expected)
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)

View File

@ -34,6 +34,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage):
license("GPL-2.0-or-later AND LGPL-2.1-or-later")
provides("c")
provides("cxx")
provides("fortran")