From 3c21b696abc9acf375307eb91ccc678965487843 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Mon, 7 Oct 2024 21:32:28 +0000
Subject: [PATCH] testsuite: implement & use req_plugins predicate

This commit implements req_plugins predicate to indicate that the test
requires plugin functionality. Currently this means cross GHC is
disabled since internal-interpreter doesn't work in cross GHC yet.
---
 testsuite/driver/testlib.py                    | 14 ++++++++++++++
 testsuite/tests/plugins/all.T                  |  2 +-
 testsuite/tests/simplCore/should_compile/all.T |  2 +-
 testsuite/tests/tcplugins/all.T                |  5 ++++-
 testsuite/tests/typecheck/should_compile/all.T |  5 ++---
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index dbdd1f3e30a..788b0dd1d7f 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -334,6 +334,20 @@ def req_th( name, opts ):
     if ghc_dynamic():
         return _omit_ways(name, opts, ['profasm', 'profthreaded'])
 
+def req_plugins( name, opts ):
+    """
+    Mark a test as requiring GHC plugins. In additional to having
+    interpreter support, currently we don't run the test for cross
+    GHCs, since plugin support for cross GHC (!7377) is unfinished
+    work (#14335) and completely untested in CI, and we don't enable
+    the internal-interpreter flag for the ghc library for cross GHC
+    anyway.
+    """
+    req_interp(name, opts)
+
+    if config.cross:
+        opts.skip = True
+
 def req_ghc_smp( name, opts ):
     """
     Mark a test as requiring GHC to be linked with an RTS that supports smp.
diff --git a/testsuite/tests/plugins/all.T b/testsuite/tests/plugins/all.T
index a78e377629e..a7bad499350 100644
--- a/testsuite/tests/plugins/all.T
+++ b/testsuite/tests/plugins/all.T
@@ -1,5 +1,5 @@
 setTestOpts([
-    req_interp,
+    req_plugins,
     # Plugins aren't supported with the JS backend so we get unexpected passes
     # for tests that expected to fail... Just skipping them for now until #14335
     # is fixed
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index 9eb66c4f5ea..a7db56ddf9b 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -156,7 +156,7 @@ test('T7702',
       # allocation done by the plugin... but a regression allocates > 90mb
       collect_compiler_stats('peak_megabytes_allocated',70),
       when(opsys('mingw32'), [multi_cpu_race]),
-      req_interp
+      req_plugins
      ],
      compile,
      ['-v0 -package-db T7702plugin/pkg.T7702/local.package.conf -fplugin T7702Plugin -package T7702plugin ' + config.plugin_way_flags])
diff --git a/testsuite/tests/tcplugins/all.T b/testsuite/tests/tcplugins/all.T
index cf496e41987..9ccb224ef93 100644
--- a/testsuite/tests/tcplugins/all.T
+++ b/testsuite/tests/tcplugins/all.T
@@ -1,4 +1,7 @@
-setTestOpts(js_broken(22261))
+setTestOpts([
+  req_plugins,
+  js_broken(22261)
+])
 
 # See NullaryPlugin.hs for a description of this plugin.
 test('TcPlugin_Nullary'
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 5057c4d7e4d..4a4bafc97e3 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -500,7 +500,7 @@ test('T10592', normal, compile, [''])
 test('T11305', normal, compile, [''])
 test('T11254', normal, compile, [''])
 test('T11379', normal, compile, [''])
-test('T11462', [js_broken(22261), req_th], multi_compile,
+test('T11462', [js_broken(22261), req_th, req_plugins], multi_compile,
      [None, [('T11462_Plugin.hs', '-package ghc'), ('T11462.hs', '')],
       '-dynamic' if have_dynamic() else ''])
 test('T11480', normal, compile, [''])
@@ -568,7 +568,7 @@ test('T11723', normal, compile, [''])
 test('T12987', normal, compile, [''])
 test('T11736', normal, compile, [''])
 test('T13248', expect_broken(13248), compile, [''])
-test('T11525', [js_broken(22261), req_th], multi_compile,
+test('T11525', [js_broken(22261), req_th, req_plugins], multi_compile,
      [None, [('T11525_Plugin.hs', '-package ghc'), ('T11525.hs', '')],
       '-dynamic' if have_dynamic() else ''])
 test('T12923_1', normal, compile, [''])
@@ -934,4 +934,3 @@ test('T25125', normal, compile, [''])
 test('T24845a', normal, compile, [''])
 test('T23501a', normal, compile, [''])
 test('T23501b', normal, compile, [''])
-
-- 
GitLab