From 8c2dbc161572b59498a9d7abe444e65973069ef7 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 15 Jan 2019 11:48:59 -0500 Subject: testsuite: Add test for #16104 --- testsuite/tests/plugins/Makefile | 4 ++++ testsuite/tests/plugins/T16104-plugin/LICENSE | 10 ++++++++++ testsuite/tests/plugins/T16104-plugin/Makefile | 18 ++++++++++++++++++ testsuite/tests/plugins/T16104-plugin/Setup.hs | 3 +++ .../tests/plugins/T16104-plugin/T16104-plugin.cabal | 11 +++++++++++ .../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 | 4 ++++ 9 files changed, 75 insertions(+) create mode 100644 testsuite/tests/plugins/T16104-plugin/LICENSE create mode 100644 testsuite/tests/plugins/T16104-plugin/Makefile create mode 100644 testsuite/tests/plugins/T16104-plugin/Setup.hs create mode 100644 testsuite/tests/plugins/T16104-plugin/T16104-plugin.cabal create mode 100644 testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs create mode 100644 testsuite/tests/plugins/T16104.hs create mode 100644 testsuite/tests/plugins/T16104.stdout 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 f366d4988b..05283e6105 100644 --- a/testsuite/tests/plugins/all.T +++ b/testsuite/tests/plugins/all.T @@ -141,3 +141,7 @@ test('plugin-recomp-change-prof', when(not config.have_profiling,skip) ], run_command, ['$MAKE -s --no-print-directory plugin-recomp-change-prof']) + +test('T16104', + pre_cmd('$MAKE -s --no-print-directory -C T16104-plugin package.T16104-plugin TOP={top}'), + run_command, ['$MAKE -s --no-print-directory T16104']) -- cgit v1.2.1