From b718b14559d9127c351abd996b61de0c44cba7a4 Mon Sep 17 00:00:00 2001
From: Zubin Duggal <zubin.duggal@gmail.com>
Date: Mon, 8 Jan 2024 15:18:15 +0530
Subject: [PATCH] testsuite: Teach testsuite driver about c++ sources

---
 testsuite/driver/testglobals.py |  3 ++-
 testsuite/driver/testlib.py     | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py
index cb281b9d938c..428b44f0cec0 100644
--- a/testsuite/driver/testglobals.py
+++ b/testsuite/driver/testglobals.py
@@ -399,8 +399,9 @@ class TestOptions:
        # Does this test use a literate (.lhs) file?
        self.literate = False
 
-       # Does this test use a .c, .m or .mm file?
+       # Does this test use a .c, .cpp, .m or .mm file?
        self.c_src      = False
+       self.cxx_src    = False
        self.objc_src   = False
        self.objcpp_src = False
 
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index e6f3dff486ee..62bad2ad1668 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -299,6 +299,13 @@ def req_c( name, opts ):
     # JS backend doesn't support C (yet)
     js_skip(name, opts)
 
+def req_cxx( name, opts ):
+    """
+    Mark a test as requiring C++ source file support
+    """
+    # JS backend doesn't support C (yet)
+    js_skip(name, opts)
+
 def req_cmm( name, opts ):
     """
     Mark a test as requiring Cmm support
@@ -953,6 +960,10 @@ def c_src( name, opts ):
     opts.c_src = True
     req_c (name, opts)
 
+def cxx_src( name, opts ):
+    opts.cxx_src = True
+    req_cxx (name, opts)
+
 def objc_src( name, opts ):
     opts.objc_src = True
 
@@ -1948,6 +1959,7 @@ async def simple_build(name: Union[TestName, str],
 
     # Required by GHC 7.3+, harmless for earlier versions:
     if (getTestOpts().c_src or
+        getTestOpts().cxx_src or
         getTestOpts().objc_src or
         getTestOpts().objcpp_src):
         extra_hc_opts += ' -no-hs-main '
@@ -2922,6 +2934,8 @@ def add_hs_lhs_suffix(name: str) -> Path:
         return add_suffix(name, 'c')
     elif getTestOpts().cmm_src:
         return add_suffix(name, 'cmm')
+    elif getTestOpts().cxx_src:
+        return add_suffix(name, 'cpp')
     elif getTestOpts().objc_src:
         return add_suffix(name, 'm')
     elif getTestOpts().objcpp_src:
-- 
GitLab