[commit: ghc] wip/T16104: testsuite: Add test for #16104 (d79810b)

git at git.haskell.org git at git.haskell.org
Sun Mar 31 15:09:26 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T16104
Link       : http://ghc.haskell.org/trac/ghc/changeset/d79810b6f1e4bf684a0b3c2a2be6f3b4b4753f82/ghc

>---------------------------------------------------------------

commit d79810b6f1e4bf684a0b3c2a2be6f3b4b4753f82
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Tue Jan 15 11:48:59 2019 -0500

    testsuite: Add test for #16104


>---------------------------------------------------------------

d79810b6f1e4bf684a0b3c2a2be6f3b4b4753f82
 testsuite/tests/plugins/Makefile                     |  4 ++++
 .../tc-plugin-ghci => plugins/T16104-plugin}/LICENSE |  0
 .../{rule-defining-plugin => T16104-plugin}/Makefile |  0
 .../T16104-plugin}/Setup.hs                          |  0
 .../T16104-plugin.cabal}                             |  8 ++------
 .../tests/plugins/T16104-plugin/T16104_Plugin.hs     | 20 ++++++++++++++++++++
 testsuite/tests/plugins/T16104.hs                    |  4 ++++
 testsuite/tests/plugins/T16104.stdout                |  1 +
 testsuite/tests/plugins/all.T                        |  6 ++++++
 9 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/testsuite/tests/plugins/Makefile b/testsuite/tests/plugins/Makefile
index 8a6af5b..d913ca5 100644
--- a/testsuite/tests/plugins/Makefile
+++ b/testsuite/tests/plugins/Makefile
@@ -121,3 +121,7 @@ plugin-recomp-change-prof:
 	"$(MAKE)" -s --no-print-directory -C plugin-recomp package.plugins01 TOP=$(TOP) RUN=-DRUN2
 	"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -v0 plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin PurePlugin
 	"$(TEST_HC)" $(TEST_HC_OPTS) -prof -osuf p_o -hisuf p_hi -v0 plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin PurePlugin
+
+.PHONY: T16104
+T16104:
+	"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -v0 T16104.hs -package-db T16104-plugin/pkg.T16104-plugin/local.package.conf
diff --git a/testsuite/tests/ghci/should_run/tc-plugin-ghci/LICENSE b/testsuite/tests/plugins/T16104-plugin/LICENSE
similarity index 100%
copy from testsuite/tests/ghci/should_run/tc-plugin-ghci/LICENSE
copy to testsuite/tests/plugins/T16104-plugin/LICENSE
diff --git a/testsuite/tests/plugins/rule-defining-plugin/Makefile b/testsuite/tests/plugins/T16104-plugin/Makefile
similarity index 100%
copy from testsuite/tests/plugins/rule-defining-plugin/Makefile
copy to testsuite/tests/plugins/T16104-plugin/Makefile
diff --git a/testsuite/tests/ghci/should_run/tc-plugin-ghci/Setup.hs b/testsuite/tests/plugins/T16104-plugin/Setup.hs
similarity index 100%
copy from testsuite/tests/ghci/should_run/tc-plugin-ghci/Setup.hs
copy to testsuite/tests/plugins/T16104-plugin/Setup.hs
diff --git a/testsuite/tests/plugins/rule-defining-plugin/rule-defining-plugin.cabal b/testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal
similarity index 51%
copy from testsuite/tests/plugins/rule-defining-plugin/rule-defining-plugin.cabal
copy to testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal
index b354f6b..5288e8f 100644
--- a/testsuite/tests/plugins/rule-defining-plugin/rule-defining-plugin.cabal
+++ b/testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal
@@ -1,15 +1,11 @@
-Name:           rule-defining-plugin
+Name:           T16104-plugin
 Version:        0.1
 Synopsis:       For testing
 Cabal-Version:  >= 1.2
 Build-Type:     Simple
 License:        BSD3
 License-File:   LICENSE
-Author:         Edward Z. Yang
-Homepage:       http://ezyang.com
 
 Library
     Build-Depends: base, ghc
-    ghc-options: -O
-    Exposed-Modules:
-        RuleDefiningPlugin
+    Exposed-Modules: T16104_Plugin
diff --git a/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs b/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs
new file mode 100644
index 0000000..79cd0fe
--- /dev/null
+++ b/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module T16104_Plugin (plugin) where
+
+import GhcPlugins
+import Data.Bits
+
+plugin :: Plugin
+plugin = defaultPlugin {installCoreToDos = install}
+  where install _ todos = return (test : todos)
+
+        test = CoreDoPluginPass "Test" check
+
+        check :: ModGuts -> CoreM ModGuts
+        check m = do mbN <- thNameToGhcName 'complement
+                     case mbN of
+                       Just _  -> liftIO $ putStrLn "Found complement!"
+                       Nothing -> error "Failed to locate complement"
+
+                     return m
diff --git a/testsuite/tests/plugins/T16104.hs b/testsuite/tests/plugins/T16104.hs
new file mode 100644
index 0000000..bfef697
--- /dev/null
+++ b/testsuite/tests/plugins/T16104.hs
@@ -0,0 +1,4 @@
+{-# OPTIONS_GHC -fplugin T16104_Plugin #-}
+
+main :: IO ()
+main = return ()
diff --git a/testsuite/tests/plugins/T16104.stdout b/testsuite/tests/plugins/T16104.stdout
new file mode 100644
index 0000000..a1eb7b6
--- /dev/null
+++ b/testsuite/tests/plugins/T16104.stdout
@@ -0,0 +1 @@
+Found complement!
diff --git a/testsuite/tests/plugins/all.T b/testsuite/tests/plugins/all.T
index da6294e..82e9fcb 100644
--- a/testsuite/tests/plugins/all.T
+++ b/testsuite/tests/plugins/all.T
@@ -208,3 +208,9 @@ test('T15858',
       extra_hc_opts("-package-db plugin-recomp/pkg.plugins01/local.package.conf ")
       ],
      ghci_script, ['T15858.script'])
+
+test('T16104',
+     [extra_files(['T16104-plugin/']),
+      pre_cmd('$MAKE -s --no-print-directory -C T16104-plugin package.T16104-plugin TOP={top}')
+     ],
+     run_command, ['$MAKE -s --no-print-directory T16104'])



More information about the ghc-commits mailing list