summaryrefslogtreecommitdiff
path: root/testsuite/tests/plugins
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-01-15 11:48:59 -0500
committerBen Gamari <ben@smart-cactus.org>2019-01-27 08:32:12 -0500
commit372b5d1b4543334d9b446dc897227b838e40cf4e (patch)
treee514569d3da9c64d701fa6cfd258a24ba6682f45 /testsuite/tests/plugins
parent1dd251b861c98c7b42a117b820afef5020745585 (diff)
downloadhaskell-372b5d1b4543334d9b446dc897227b838e40cf4e.tar.gz
testsuite: Add test for #16104
Diffstat (limited to 'testsuite/tests/plugins')
-rw-r--r--testsuite/tests/plugins/Makefile4
-rw-r--r--testsuite/tests/plugins/T16104-plugin/LICENSE10
-rw-r--r--testsuite/tests/plugins/T16104-plugin/Makefile18
-rw-r--r--testsuite/tests/plugins/T16104-plugin/Setup.hs3
-rw-r--r--testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal11
-rw-r--r--testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs20
-rw-r--r--testsuite/tests/plugins/T16104.hs4
-rw-r--r--testsuite/tests/plugins/T16104.stdout1
-rw-r--r--testsuite/tests/plugins/all.T6
9 files changed, 77 insertions, 0 deletions
diff --git a/testsuite/tests/plugins/Makefile b/testsuite/tests/plugins/Makefile
index 8a6af5b118..d913ca5108 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/plugins/T16104-plugin/LICENSE b/testsuite/tests/plugins/T16104-plugin/LICENSE
new file mode 100644
index 0000000000..6297f71b3f
--- /dev/null
+++ b/testsuite/tests/plugins/T16104-plugin/LICENSE
@@ -0,0 +1,10 @@
+Copyright (c) 2008, Max Bolingbroke
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of Max Bolingbroke nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/testsuite/tests/plugins/T16104-plugin/Makefile b/testsuite/tests/plugins/T16104-plugin/Makefile
new file mode 100644
index 0000000000..5a0289c99b
--- /dev/null
+++ b/testsuite/tests/plugins/T16104-plugin/Makefile
@@ -0,0 +1,18 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+clean.%:
+ rm -rf pkg.$*
+
+HERE := $(abspath .)
+$(eval $(call canonicalise,HERE))
+
+package.%:
+ $(MAKE) -s --no-print-directory clean.$*
+ mkdir pkg.$*
+ "$(TEST_HC)" -outputdir pkg.$* --make -v0 -o pkg.$*/setup Setup.hs
+ "$(GHC_PKG)" init pkg.$*/local.package.conf
+ pkg.$*/setup configure --distdir pkg.$*/dist -v0 $(CABAL_PLUGIN_BUILD) --prefix="$(HERE)/pkg.$*/install" --with-compiler="$(TEST_HC)" --with-hc-pkg="$(GHC_PKG)" --package-db=pkg.$*/local.package.conf $(if $(findstring YES,$(HAVE_PROFILING)), --enable-library-profiling)
+ pkg.$*/setup build --distdir pkg.$*/dist -v0
+ pkg.$*/setup install --distdir pkg.$*/dist -v0
diff --git a/testsuite/tests/plugins/T16104-plugin/Setup.hs b/testsuite/tests/plugins/T16104-plugin/Setup.hs
new file mode 100644
index 0000000000..e8ef27dbba
--- /dev/null
+++ b/testsuite/tests/plugins/T16104-plugin/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+
+main = defaultMain
diff --git a/testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal b/testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal
new file mode 100644
index 0000000000..5288e8fa2c
--- /dev/null
+++ b/testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal
@@ -0,0 +1,11 @@
+Name: T16104-plugin
+Version: 0.1
+Synopsis: For testing
+Cabal-Version: >= 1.2
+Build-Type: Simple
+License: BSD3
+License-File: LICENSE
+
+Library
+ Build-Depends: base, ghc
+ 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 0000000000..79cd0fe16d
--- /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 0000000000..bfef69767d
--- /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 0000000000..a1eb7b6983
--- /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 da6294eae2..82e9fcb150 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'])