diff options
author | Christiaan Baaij <christiaan.baaij@gmail.com> | 2018-11-22 11:50:51 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-11-22 13:14:01 -0500 |
commit | 599eaada382d04722219bfc319bde94591be3fb1 (patch) | |
tree | 462b6ad7a5df2be04a77df8b5404822ec4cf4b86 /testsuite/tests/ghci/should_run | |
parent | f088c2d42aaa38b32482ea8c4324786123835e62 (diff) | |
download | haskell-599eaada382d04722219bfc319bde94591be3fb1.tar.gz |
Load plugins in interactive session
Reviewers: bgamari, tdammers
Reviewed By: tdammers
Subscribers: monoidal, rwbarton, carter
GHC Trac Issues: #15633
Differential Revision: https://phabricator.haskell.org/D5348
Diffstat (limited to 'testsuite/tests/ghci/should_run')
12 files changed, 93 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/should_run/T15633a.script b/testsuite/tests/ghci/should_run/T15633a.script new file mode 100644 index 0000000000..dabd06c685 --- /dev/null +++ b/testsuite/tests/ghci/should_run/T15633a.script @@ -0,0 +1 @@ +:t True diff --git a/testsuite/tests/ghci/should_run/T15633a.stderr b/testsuite/tests/ghci/should_run/T15633a.stderr new file mode 100644 index 0000000000..986efb1071 --- /dev/null +++ b/testsuite/tests/ghci/should_run/T15633a.stderr @@ -0,0 +1 @@ +TcPluginGHCi diff --git a/testsuite/tests/ghci/should_run/T15633a.stdout b/testsuite/tests/ghci/should_run/T15633a.stdout new file mode 100644 index 0000000000..7ca26c4c97 --- /dev/null +++ b/testsuite/tests/ghci/should_run/T15633a.stdout @@ -0,0 +1 @@ +True :: Bool diff --git a/testsuite/tests/ghci/should_run/T15633b.script b/testsuite/tests/ghci/should_run/T15633b.script new file mode 100644 index 0000000000..361fac84bd --- /dev/null +++ b/testsuite/tests/ghci/should_run/T15633b.script @@ -0,0 +1,2 @@ +:set -fplugin TcPluginGHCi +:t True diff --git a/testsuite/tests/ghci/should_run/T15633b.stderr b/testsuite/tests/ghci/should_run/T15633b.stderr new file mode 100644 index 0000000000..986efb1071 --- /dev/null +++ b/testsuite/tests/ghci/should_run/T15633b.stderr @@ -0,0 +1 @@ +TcPluginGHCi diff --git a/testsuite/tests/ghci/should_run/T15633b.stdout b/testsuite/tests/ghci/should_run/T15633b.stdout new file mode 100644 index 0000000000..7ca26c4c97 --- /dev/null +++ b/testsuite/tests/ghci/should_run/T15633b.stdout @@ -0,0 +1 @@ +True :: Bool diff --git a/testsuite/tests/ghci/should_run/all.T b/testsuite/tests/ghci/should_run/all.T index 3dfea76525..aa6aab3622 100644 --- a/testsuite/tests/ghci/should_run/all.T +++ b/testsuite/tests/ghci/should_run/all.T @@ -37,3 +37,21 @@ test('T14963b', just_ghci, ghci_script, ['T14963b.script']) test('T14963c', [extra_hc_opts("-fdefer-type-errors")], ghci_script, ['T14963c.script']) test('T15007', just_ghci, ghci_script, ['T15007.script']) test('T15806', just_ghci, ghci_script, ['T15806.script']) + +test('T15633a', + [extra_files(['tc-plugin-ghci/']), + when(opsys('mingw32'), multi_cpu_race), + only_ways(['ghci']), + pre_cmd('$MAKE -s --no-print-directory -C tc-plugin-ghci package.plugins01 TOP={top}'), + extra_hc_opts("-package-db tc-plugin-ghci/pkg.plugins01/local.package.conf -fplugin TcPluginGHCi") + ], + ghci_script, ['T15633a.script']) + +test('T15633b', + [extra_files(['tc-plugin-ghci/']), + when(opsys('mingw32'), multi_cpu_race), + only_ways(['ghci']), + pre_cmd('$MAKE -s --no-print-directory -C tc-plugin-ghci package.plugins01 TOP={top}'), + extra_hc_opts("-package-db tc-plugin-ghci/pkg.plugins01/local.package.conf") + ], + ghci_script, ['T15633b.script']) diff --git a/testsuite/tests/ghci/should_run/tc-plugin-ghci/LICENSE b/testsuite/tests/ghci/should_run/tc-plugin-ghci/LICENSE new file mode 100644 index 0000000000..6297f71b3f --- /dev/null +++ b/testsuite/tests/ghci/should_run/tc-plugin-ghci/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/ghci/should_run/tc-plugin-ghci/Makefile b/testsuite/tests/ghci/should_run/tc-plugin-ghci/Makefile new file mode 100644 index 0000000000..9ee7737339 --- /dev/null +++ b/testsuite/tests/ghci/should_run/tc-plugin-ghci/Makefile @@ -0,0 +1,23 @@ +TOP=../../.. +RUN=-DRUN1 +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 + + # The bogus extra-lib-dirs ensures the package is registered with multiple + # dynamic-library-directories which tests that the fix for #15475 works + pkg.$*/setup configure --distdir pkg.$*/dist -v0 $(CABAL_PLUGIN_BUILD) --ghc-option="$(RUN)" --prefix="$(HERE)/pkg.$*/install" --with-compiler="$(TEST_HC)" --with-hc-pkg="$(GHC_PKG)" --extra-lib-dirs="$(HERE)" --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/ghci/should_run/tc-plugin-ghci/Setup.hs b/testsuite/tests/ghci/should_run/tc-plugin-ghci/Setup.hs new file mode 100644 index 0000000000..e8ef27dbba --- /dev/null +++ b/testsuite/tests/ghci/should_run/tc-plugin-ghci/Setup.hs @@ -0,0 +1,3 @@ +import Distribution.Simple + +main = defaultMain diff --git a/testsuite/tests/ghci/should_run/tc-plugin-ghci/TcPluginGHCi.hs b/testsuite/tests/ghci/should_run/tc-plugin-ghci/TcPluginGHCi.hs new file mode 100644 index 0000000000..c8a3bb6d34 --- /dev/null +++ b/testsuite/tests/ghci/should_run/tc-plugin-ghci/TcPluginGHCi.hs @@ -0,0 +1,15 @@ +module TcPluginGHCi where + +import TcRnMonad ( TcPlugin(..), TcPluginResult(..) ) +import Plugins ( defaultPlugin, Plugin(..), CommandLineOption ) +import Debug.Trace + +plugin :: Plugin +plugin = defaultPlugin { tcPlugin = Just . thePlugin } + +thePlugin :: [CommandLineOption] -> TcPlugin +thePlugin opts = TcPlugin + { tcPluginInit = trace "TcPluginGHCi" (return ()) + , tcPluginSolve = \_ _ _ _ -> return $ TcPluginOk [] [] + , tcPluginStop = \_ -> return () + } diff --git a/testsuite/tests/ghci/should_run/tc-plugin-ghci/tc-plugin-ghci.cabal b/testsuite/tests/ghci/should_run/tc-plugin-ghci/tc-plugin-ghci.cabal new file mode 100644 index 0000000000..fdcbef9329 --- /dev/null +++ b/testsuite/tests/ghci/should_run/tc-plugin-ghci/tc-plugin-ghci.cabal @@ -0,0 +1,17 @@ +Name: tc-plugin-ghci +Version: 0.1 +Synopsis: Testing type-checker plugins in ghci +Cabal-Version: >= 1.2 +Build-Type: Simple +License: BSD3 +License-File: LICENSE +Author: Matthew Pickering +Homepage: http://blog.omega-prime.co.uk + +Library + Extensions: CPP + Build-Depends: + base, + ghc >= 6.11 + Exposed-Modules: + TcPluginGHCi |