From d7423f1096b5415928ba1d1d621e066ef4e5b641 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= <omeragacan@gmail.com>
Date: Thu, 27 Jun 2019 11:46:20 +0300
Subject: [PATCH] Testsuite tweaks and refactoring

- Rename requires_th to req_th for consistency with other req functions
  (e.g. req_interp, req_profiling etc.)

- req_th (previously requires_th) now checks for interpreter (via
  req_interp). With this running TH tests are skipped when running the
  test suite with stage=1.

- Test tweaks:
    - T9360a, T9360b: Use req_interp
    - recomp009, T13938, RAE_T32a: Use req_th

- Fix check-makefiles linter: it now looks for Makefiles instead of .T
  files (which are actually Python files)
---
 .gitlab/linters/check-makefiles.py             |  2 +-
 testsuite/driver/testlib.py                    | 18 ++++++++++--------
 testsuite/tests/dependent/should_compile/all.T |  2 +-
 testsuite/tests/dependent/should_fail/all.T    |  2 +-
 testsuite/tests/driver/all.T                   |  6 +++---
 testsuite/tests/driver/recomp009/all.T         |  2 +-
 testsuite/tests/parser/should_compile/all.T    |  2 +-
 testsuite/tests/perf/compiler/all.T            |  2 +-
 testsuite/tests/quotes/all.T                   |  2 +-
 testsuite/tests/roles/should_compile/all.T     |  2 +-
 10 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/.gitlab/linters/check-makefiles.py b/.gitlab/linters/check-makefiles.py
index b647f6c1c5ef..19b7b563682d 100755
--- a/.gitlab/linters/check-makefiles.py
+++ b/.gitlab/linters/check-makefiles.py
@@ -13,7 +13,7 @@ from linter import run_linters, RegexpLinter
 linters = [
     RegexpLinter(r'--interactive',
                  message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`."
-                ).add_path_filter(lambda path: path.suffix == '.T')
+                ).add_path_filter(lambda path: path.name == 'Makefile')
 ]
 
 if __name__ == '__main__':
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 2e87925fdaaa..d220110a6bff 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -184,6 +184,16 @@ def req_interp( name, opts ):
     if not config.have_interp:
         opts.expect = 'fail'
 
+def req_th( name, opts ):
+    """
+    Mark a test as requiring TemplateHaskell. In addition to having interpreter
+    support, currently this means that we don't run the test in the profasm when
+    when GHC is dynamically-linked since we can't load profiled objects in this
+    case.
+    """
+    req_interp(name, opts)
+    return when(ghc_dynamic(), omit_ways(['profasm']))
+
 def req_smp( name, opts ):
     if not config.have_smp:
         opts.expect = 'fail'
@@ -453,14 +463,6 @@ def unless(b: bool, f):
 def doing_ghci() -> bool:
     return 'ghci' in config.run_ways
 
-def requires_th(name, opts):
-    """
-    Mark a test as requiring TemplateHaskell. Currently this means
-    that we don't run the test in the profasm when when GHC is
-    dynamically-linked since we can't load profiled objects in this case.
-    """
-    return when(ghc_dynamic(), omit_ways(['profasm']))
-
 def ghc_dynamic() -> bool:
     return config.ghc_dynamic
 
diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T
index a3fc4aca6e6b..bbc32c8115af 100644
--- a/testsuite/tests/dependent/should_compile/all.T
+++ b/testsuite/tests/dependent/should_compile/all.T
@@ -41,7 +41,7 @@ test('T12742', normal, compile, [''])
 #       (2) Build the program twice: once with -dynamic, and then
 #           with -prof using -osuf to set a different object file suffix.
 test('T13910', [expect_broken_for(16537, ['optasm']), omit_ways(['profasm'])], compile, [''])
-test('T13938', [extra_files(['T13938a.hs'])], makefile_test, ['T13938'])
+test('T13938', [req_th, extra_files(['T13938a.hs'])], makefile_test, ['T13938'])
 test('T14556', normal, compile, [''])
 test('T14720', normal, compile, [''])
 test('T14066a', normal, compile, [''])
diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T
index 1e6ab40b09a1..97580ce1cd52 100644
--- a/testsuite/tests/dependent/should_fail/all.T
+++ b/testsuite/tests/dependent/should_fail/all.T
@@ -1,5 +1,5 @@
 test('DepFail1', normal, compile_fail, [''])
-test('RAE_T32a', normal, compile_fail, [''])
+test('RAE_T32a', req_th, compile_fail, [''])
 test('TypeSkolEscape', normal, compile_fail, ['-fprint-explicit-runtime-reps'])
 test('BadTelescope', normal, compile_fail, [''])
 test('BadTelescope2', normal, compile_fail, [''])
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index a3f33c567f7b..b2187a2517e4 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -227,8 +227,8 @@ test('T365',
      [pre_cmd('touch test_preprocessor.txt'), unless(opsys('mingw32'), skip)],
      compile_fail, [''])
 
-test('T9360a', normal, run_command, ['{compiler} --interactive -e "" -ignore-dot-ghci'])
-test('T9360b', normal, run_command, ['{compiler} -e "" --interactive -ignore-dot-ghci'])
+test('T9360a', req_interp, run_command, ['{compiler} --interactive -e "" -ignore-dot-ghci'])
+test('T9360b', req_interp, run_command, ['{compiler} -e "" --interactive -ignore-dot-ghci'])
 
 test('T10970', normal, compile_and_run, [''])
 test('T4931', normal, compile_and_run, [''])
@@ -273,6 +273,6 @@ test('T14452', [], makefile_test, [])
 test('T15396', normal, compile_and_run, ['-package ghc'])
 test('T16737',
      [extra_files(['T16737include/']),
-      requires_th,
+      req_th,
       expect_broken_for(16541, ['ghci'])],
      compile_and_run, ['-optP=-isystem -optP=T16737include'])
diff --git a/testsuite/tests/driver/recomp009/all.T b/testsuite/tests/driver/recomp009/all.T
index 5e20e09110d3..33c36f7ea3d8 100644
--- a/testsuite/tests/driver/recomp009/all.T
+++ b/testsuite/tests/driver/recomp009/all.T
@@ -1,3 +1,3 @@
 # Test for #481, a recompilation bug with Template Haskell
 
-test('recomp009', [extra_files(['Main.hs', 'Sub1.hs', 'Sub2.hs'])], makefile_test, [])
+test('recomp009', [req_th, extra_files(['Main.hs', 'Sub1.hs', 'Sub2.hs'])], makefile_test, [])
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index ef76f3ac525b..3d44e225106f 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -142,6 +142,6 @@ test('T15457', normal, compile, [''])
 test('T15675', normal, compile, [''])
 test('T15781', normal, compile, [''])
 test('T16339', normal, compile, [''])
-test('T16619', requires_th, multimod_compile, ['T16619', '-v0'])
+test('T16619', req_th, multimod_compile, ['T16619', '-v0'])
 test('T504', normal, compile, [''])
 test('T515', literate, compile, ['-Wall'])
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index 40b5e268f05c..cfc860d0b090 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -404,7 +404,7 @@ test ('WWRec',
       ['-v0 -O'])
 
 test('T16190',
-      [requires_th, collect_stats()],
+      [req_th, collect_stats()],
       multimod_compile,
       ['T16190.hs', '-v0'])
 
diff --git a/testsuite/tests/quotes/all.T b/testsuite/tests/quotes/all.T
index 18c4247ed138..feefc41433c6 100644
--- a/testsuite/tests/quotes/all.T
+++ b/testsuite/tests/quotes/all.T
@@ -15,7 +15,7 @@ test('T8633', normal, compile_and_run, [''])
 test('T8759a', normal, compile, ['-v0'])
 test('T9824', normal, compile, ['-v0'])
 test('T10384', normal, compile_fail, [''])
-test('T16384', requires_th, compile, [''])
+test('T16384', req_th, compile, [''])
 
 test('TH_tf2', normal, compile, ['-v0'])
 test('TH_ppr1', normal, compile_and_run, [''])
diff --git a/testsuite/tests/roles/should_compile/all.T b/testsuite/tests/roles/should_compile/all.T
index 1e8599eaf3fc..b74f704f23f3 100644
--- a/testsuite/tests/roles/should_compile/all.T
+++ b/testsuite/tests/roles/should_compile/all.T
@@ -10,4 +10,4 @@ test('T8958', [normalise_fun(normalise_errmsg), only_ways(['normal'])], compile,
 test('T10263', normal, compile, [''])
 test('T9204b', [], multimod_compile, ['T9204b', '-v0'])
 test('T14101', normal, compile, [''])
-test('T16718', requires_th, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T16718', req_th, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
-- 
GitLab