summaryrefslogtreecommitdiff
path: root/testsuite/tests/plugins
diff options
context:
space:
mode:
authorKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
committerKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
commit84c2ad99582391005b5e873198b15e9e9eb4f78d (patch)
treecaa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /testsuite/tests/plugins
parent8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff)
parente68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff)
downloadhaskell-84c2ad99582391005b5e873198b15e9e9eb4f78d.tar.gz
update to current master againwip/T13904
Diffstat (limited to 'testsuite/tests/plugins')
-rw-r--r--testsuite/tests/plugins/Makefile76
-rw-r--r--testsuite/tests/plugins/MetaRemoveHelper.hs6
-rw-r--r--testsuite/tests/plugins/PluginFilteredExport.hs8
-rw-r--r--testsuite/tests/plugins/QuasiQuotation.hs11
-rw-r--r--testsuite/tests/plugins/T11244.stderr9
-rw-r--r--testsuite/tests/plugins/T12567a.stderr5
-rw-r--r--testsuite/tests/plugins/T14335.hs1
-rw-r--r--testsuite/tests/plugins/T14335.stderr1
-rw-r--r--testsuite/tests/plugins/all.T114
-rw-r--r--testsuite/tests/plugins/plugin-recomp-change-prof.stderr12
-rw-r--r--testsuite/tests/plugins/plugin-recomp-change.stderr6
-rw-r--r--testsuite/tests/plugins/plugin-recomp-flags.stderr6
-rw-r--r--testsuite/tests/plugins/plugin-recomp-flags.stdout4
-rw-r--r--testsuite/tests/plugins/plugin-recomp-impure.stderr6
-rw-r--r--testsuite/tests/plugins/plugin-recomp-impure.stdout4
-rw-r--r--testsuite/tests/plugins/plugin-recomp-pure.stderr3
-rw-r--r--testsuite/tests/plugins/plugin-recomp-pure.stdout2
-rw-r--r--testsuite/tests/plugins/plugin-recomp-test.hs8
-rw-r--r--testsuite/tests/plugins/plugin-recomp/Common.hs22
-rw-r--r--testsuite/tests/plugins/plugin-recomp/FingerprintPlugin.hs10
-rw-r--r--testsuite/tests/plugins/plugin-recomp/ImpurePlugin.hs10
-rw-r--r--testsuite/tests/plugins/plugin-recomp/LICENSE10
-rw-r--r--testsuite/tests/plugins/plugin-recomp/Makefile23
-rw-r--r--testsuite/tests/plugins/plugin-recomp/PurePlugin.hs10
-rw-r--r--testsuite/tests/plugins/plugin-recomp/Setup.hs3
-rw-r--r--testsuite/tests/plugins/plugin-recomp/plugin-recomp.cabal20
-rw-r--r--testsuite/tests/plugins/plugins03.stderr2
-rw-r--r--testsuite/tests/plugins/plugins04.stderr2
-rw-r--r--testsuite/tests/plugins/plugins08.hs18
-rw-r--r--testsuite/tests/plugins/plugins08.stderr4
-rw-r--r--testsuite/tests/plugins/plugins08.stdout3
-rw-r--r--testsuite/tests/plugins/plugins09.hs1
-rw-r--r--testsuite/tests/plugins/plugins09.stdout9
-rw-r--r--testsuite/tests/plugins/plugins10.hs9
-rw-r--r--testsuite/tests/plugins/plugins10.stdout18
-rw-r--r--testsuite/tests/plugins/plugins11.hs2
-rw-r--r--testsuite/tests/plugins/plugins11.stdout9
-rw-r--r--testsuite/tests/plugins/plugins12.hs9
-rw-r--r--testsuite/tests/plugins/plugins13.hs5
-rw-r--r--testsuite/tests/plugins/plugins14.hs11
-rw-r--r--testsuite/tests/plugins/plugins15.hs12
-rw-r--r--testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs7
-rw-r--r--testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs69
-rw-r--r--testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs52
-rw-r--r--testsuite/tests/plugins/simple-plugin/simple-plugin.cabal4
45 files changed, 616 insertions, 20 deletions
diff --git a/testsuite/tests/plugins/Makefile b/testsuite/tests/plugins/Makefile
index efe17efeb8..8a6af5b118 100644
--- a/testsuite/tests/plugins/Makefile
+++ b/testsuite/tests/plugins/Makefile
@@ -16,6 +16,39 @@ plugins07:
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 -O plugins07.hs -package-db rule-defining-plugin/pkg.plugins07/local.package.conf -hide-all-packages -package base -plugin-package rule-defining-plugin -fplugin=RuleDefiningPlugin
./plugins07
+.PHONY: plugins08
+plugins08:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins08.hs -package-db simple-plugin/pkg.plugins08/local.package.conf
+ ./plugins08
+
+.PHONY: plugins09
+plugins09:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins09.hs -package-db simple-plugin/pkg.plugins09/local.package.conf -fplugin Simple.SourcePlugin -fplugin-opt Simple.SourcePlugin:a -fplugin-opt Simple.SourcePlugin:b -plugin-package simple-plugin
+
+.PHONY: plugins10
+plugins10:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins10.hs QuasiQuotation.hs -package-db simple-plugin/pkg.plugins10/local.package.conf -fplugin Simple.SourcePlugin -plugin-package simple-plugin
+
+.PHONY: plugins11
+plugins11:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins11.hs -package-db simple-plugin/pkg.plugins11/local.package.conf -plugin-package simple-plugin
+
+.PHONY: plugins12
+plugins12:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins12.hs -package-db simple-plugin/pkg.plugins12/local.package.conf -plugin-package simple-plugin
+
+.PHONY: plugins13
+plugins13:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins13.hs PluginFilteredExport.hs -package-db simple-plugin/pkg.plugins13/local.package.conf -plugin-package simple-plugin
+
+.PHONY: plugins14
+plugins14:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins14.hs -package-db simple-plugin/pkg.plugins14/local.package.conf -plugin-package simple-plugin
+
+.PHONY: plugins15
+plugins15:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make -v0 plugins15.hs MetaRemoveHelper.hs -package-db simple-plugin/pkg.plugins15/local.package.conf -plugin-package simple-plugin
+
# -package (should work for backwards compatibility)
.PHONY: T10420
T10420:
@@ -45,5 +78,46 @@ T11244:
.PHONY: T12567a
T12567a:
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567a.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 1>&2
- "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567a.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 2>&1 | grep "T12567a.hs, T12567a.o" 1>&2
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567a.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 1>&2
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567b.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 1>&2
+
+.PHONY: T14335
+T14335:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -fexternal-interpreter --make -v0 plugins01.hs -package-db simple-plugin/pkg.plugins01/local.package.conf -fplugin Simple.Plugin -fplugin-opt Simple.Plugin:Irrelevant_Option -hide-all-plugin-packages -plugin-package simple-plugin
+ ./plugins01
+
+# Shouldn't recompile the module
+.PHONY: plugin-recomp-pure
+plugin-recomp-pure:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin PurePlugin
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin PurePlugin
+
+# Should recompile the module
+.PHONY: plugin-recomp-impure
+plugin-recomp-impure:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin ImpurePlugin
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin ImpurePlugin
+
+# Should not recompile the module the first time but should the second time
+.PHONY: plugin-recomp-flags
+plugin-recomp-flags:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin FingerprintPlugin -fplugin-opt FingerprintPlugin:0
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin FingerprintPlugin -fplugin-opt FingerprintPlugin:0
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin FingerprintPlugin -fplugin-opt FingerprintPlugin:1
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin FingerprintPlugin -fplugin-opt FingerprintPlugin:1
+
+# Should recompile the module because the plugin changed
+.PHONY: plugin-recomp-change
+plugin-recomp-change:
+ "$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -v0 plugin-recomp-test.hs -package-db plugin-recomp/pkg.plugins01/local.package.conf -fplugin PurePlugin
+ "$(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
+
+# Should recompile the module because the plugin changed, test for 15492
+.PHONY: plugin-recomp-change-prof
+plugin-recomp-change-prof:
+ "$(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
+ "$(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
diff --git a/testsuite/tests/plugins/MetaRemoveHelper.hs b/testsuite/tests/plugins/MetaRemoveHelper.hs
new file mode 100644
index 0000000000..06a67995f7
--- /dev/null
+++ b/testsuite/tests/plugins/MetaRemoveHelper.hs
@@ -0,0 +1,6 @@
+module MetaRemoveHelper where
+
+import Language.Haskell.TH
+
+clear :: Q [Dec] -> Q [Dec]
+clear _ = return []
diff --git a/testsuite/tests/plugins/PluginFilteredExport.hs b/testsuite/tests/plugins/PluginFilteredExport.hs
new file mode 100644
index 0000000000..6dd62d33ff
--- /dev/null
+++ b/testsuite/tests/plugins/PluginFilteredExport.hs
@@ -0,0 +1,8 @@
+{-# OPTIONS_GHC -fplugin Simple.RemovePlugin #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:map #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:typecheck #-}
+-- testing that the plugin can alter the parsed representation
+module PluginFilteredExport where
+
+map :: ()
+map = ()
diff --git a/testsuite/tests/plugins/QuasiQuotation.hs b/testsuite/tests/plugins/QuasiQuotation.hs
new file mode 100644
index 0000000000..b8fe5d6b26
--- /dev/null
+++ b/testsuite/tests/plugins/QuasiQuotation.hs
@@ -0,0 +1,11 @@
+module QuasiQuotation where
+
+import Language.Haskell.TH
+import Language.Haskell.TH.Quote
+
+stringify :: QuasiQuoter
+stringify = QuasiQuoter { quoteExp = return . LitE . StringL
+ , quotePat = return . LitP . StringL
+ , quoteType = return . LitT . StrTyLit
+ , quoteDec = const (return [])
+ }
diff --git a/testsuite/tests/plugins/T11244.stderr b/testsuite/tests/plugins/T11244.stderr
index f489103f28..72f01060db 100644
--- a/testsuite/tests/plugins/T11244.stderr
+++ b/testsuite/tests/plugins/T11244.stderr
@@ -1,4 +1,5 @@
-<command line>: Could not find module ‘RuleDefiningPlugin’
-Perhaps you meant
- RuleDefiningPlugin (from rule-defining-plugin-0.1)
-Use -v to see a list of the files searched for.
+<command line>: Could not load module ‘RuleDefiningPlugin’
+It is a member of the hidden package ‘rule-defining-plugin-0.1’.
+You can run ‘:set -package rule-defining-plugin’ to expose it.
+(Note: this unloads all the modules in the current scope.)
+Use -v (or `:set -v` in ghci) to see a list of the files searched for.
diff --git a/testsuite/tests/plugins/T12567a.stderr b/testsuite/tests/plugins/T12567a.stderr
index aee35e3528..efc75384e6 100644
--- a/testsuite/tests/plugins/T12567a.stderr
+++ b/testsuite/tests/plugins/T12567a.stderr
@@ -2,9 +2,4 @@
Simple Plugin Passes Queried
Got options:
Simple Plugin Pass Run
-[1 of 1] Compiling T12567a ( T12567a.hs, T12567a.o ) [Simple.Plugin changed]
-[1 of 2] Compiling T12567a ( T12567a.hs, T12567a.o ) [Simple.Plugin changed]
-Simple Plugin Passes Queried
-Got options:
-Simple Plugin Pass Run
[2 of 2] Compiling T12567b ( T12567b.hs, T12567b.o )
diff --git a/testsuite/tests/plugins/T14335.hs b/testsuite/tests/plugins/T14335.hs
new file mode 100644
index 0000000000..49a0085247
--- /dev/null
+++ b/testsuite/tests/plugins/T14335.hs
@@ -0,0 +1 @@
+module T14335 where
diff --git a/testsuite/tests/plugins/T14335.stderr b/testsuite/tests/plugins/T14335.stderr
new file mode 100644
index 0000000000..1f051a79b4
--- /dev/null
+++ b/testsuite/tests/plugins/T14335.stderr
@@ -0,0 +1 @@
+<command line>: Plugins require -fno-external-interpreter
diff --git a/testsuite/tests/plugins/all.T b/testsuite/tests/plugins/all.T
index 9e17eb42c8..339b9bab76 100644
--- a/testsuite/tests/plugins/all.T
+++ b/testsuite/tests/plugins/all.T
@@ -1,55 +1,118 @@
setTestOpts(req_interp)
+# The implementation of ghc-pkg doesn't seem to be multi-concurrent process safe
+# on windows. These tests which mutate the package db need to be run
+# sequentially until this is fixed. This likely means that #13194 isn't fully
+# solved. See also #15313.
+
test('plugins01',
- [extra_files(['simple-plugin/']),
+ [extra_files(['simple-plugin/']), when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins01 TOP={top}')],
run_command, ['$MAKE -s --no-print-directory plugins01'])
test('plugins02',
- [extra_files(['simple-plugin/']),
+ [extra_files(['simple-plugin/']), when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins02 TOP={top}')],
compile_fail,
['-package-db simple-plugin/pkg.plugins02/local.package.conf -fplugin Simple.BadlyTypedPlugin -package simple-plugin ' + config.plugin_way_flags])
test('plugins03',
- [extra_files(['simple-plugin/']),
+ [extra_files(['simple-plugin/']), when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins03 TOP={top}')],
compile_fail,
['-package-db simple-plugin/pkg.plugins03/local.package.conf -fplugin Simple.NonExistentPlugin -package simple-plugin'])
-test('plugins04', [extra_files(['HomePackagePlugin.hs'])], multimod_compile_fail,
+test('plugins04', [extra_files(['HomePackagePlugin.hs']),
+ when(opsys('mingw32'), multi_cpu_race)],
+ multimod_compile_fail,
['plugins04', '-package ghc -fplugin HomePackagePlugin'])
test('plugins05', [extra_files(['HomePackagePlugin.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
only_ways([config.ghc_plugin_way])],
multimod_compile_and_run, ['plugins05', '-package ghc'])
test('plugins06',
[extra_files(['LinkerTicklingPlugin.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
unless(have_dynamic(), skip), only_ways([config.ghc_plugin_way])],
multimod_compile_and_run, ['plugins06', '-package ghc'])
test('plugins07',
[extra_files(['rule-defining-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C rule-defining-plugin package.plugins07 TOP={top}')],
run_command, ['$MAKE -s --no-print-directory plugins07'])
+test('plugins08',
+ [extra_files(['simple-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins08 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins08'])
+
+test('plugins09',
+ [extra_files(['simple-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins09 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins09'])
+
+test('plugins10',
+ [expect_broken(15216),
+ extra_files(['simple-plugin/', 'QuasiQuotation.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins10 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins10'])
+
+test('plugins11',
+ [extra_files(['simple-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins11 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins11'])
+
+test('plugins12',
+ [extra_files(['simple-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins12 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins12'])
+
+test('plugins13',
+ [extra_files(['simple-plugin/', 'PluginFilteredExport.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins13 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins13'])
+
+test('plugins14',
+ [extra_files(['simple-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins14 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins14'])
+
+test('plugins15',
+ [extra_files(['simple-plugin/', 'MetaRemoveHelper.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins15 TOP={top}')],
+ run_command, ['$MAKE -s --no-print-directory plugins15'])
+
test('T10420',
[extra_files(['rule-defining-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C rule-defining-plugin package.T10420 TOP={top}')],
run_command, ['$MAKE -s --no-print-directory T10420'])
test('T10294',
[extra_files(['annotation-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C annotation-plugin package.T10294 TOP={top}')],
run_command, ['$MAKE -s --no-print-directory T10294'])
test('T10294a',
[extra_files(['annotation-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C annotation-plugin package.T10294a TOP={top}')],
run_command, ['$MAKE -s --no-print-directory T10294a'])
test('frontend01', [extra_files(['FrontendPlugin.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
unless(have_dynamic(), expect_broken(10301))], run_command,
['$MAKE -s --no-print-directory frontend01'])
@@ -60,5 +123,48 @@ test('T11244',
test('T12567a',
[extra_files(['T12567b.hs', 'simple-plugin/']),
+ when(opsys('mingw32'), multi_cpu_race),
pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.T12567a TOP={top}')],
run_command, ['$MAKE -s --no-print-directory T12567a'])
+
+test('T14335',
+ [extra_files(['simple-plugin/', 'plugins01.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins01 TOP={top}')],
+ compile_fail,
+ ['-package-db simple-plugin/pkg.plugins01/local.package.conf -fplugin Simple.Plugin \
+ -fexternal-interpreter -package simple-plugin ' + config.plugin_way_flags])
+
+test('plugin-recomp-pure',
+ [extra_files(['plugin-recomp/', 'plugin-recomp-test.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C plugin-recomp package.plugins01 TOP={top}')
+ ],
+ run_command, ['$MAKE -s --no-print-directory plugin-recomp-pure'])
+
+test('plugin-recomp-impure',
+ [extra_files(['plugin-recomp/', 'plugin-recomp-test.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C plugin-recomp package.plugins01 TOP={top}')
+ ],
+ run_command, ['$MAKE -s --no-print-directory plugin-recomp-impure'])
+
+test('plugin-recomp-flags',
+ [extra_files(['plugin-recomp/', 'plugin-recomp-test.hs']),
+ when(opsys('mingw32'), multi_cpu_race),
+ pre_cmd('$MAKE -s --no-print-directory -C plugin-recomp package.plugins01 TOP={top}')
+ ],
+ run_command, ['$MAKE -s --no-print-directory plugin-recomp-flags'])
+
+test('plugin-recomp-change',
+ [extra_files(['plugin-recomp/', 'plugin-recomp-test.hs']),
+ pre_cmd('$MAKE -s --no-print-directory -C plugin-recomp package.plugins01 TOP={top}')
+ ],
+ run_command, ['$MAKE -s --no-print-directory plugin-recomp-change'])
+
+test('plugin-recomp-change-prof',
+ [extra_files(['plugin-recomp/', 'plugin-recomp-test.hs']),
+ pre_cmd('$MAKE -s --no-print-directory -C plugin-recomp package.plugins01 TOP={top}'),
+ when(not config.have_profiling,skip)
+ ],
+ run_command, ['$MAKE -s --no-print-directory plugin-recomp-change-prof'])
diff --git a/testsuite/tests/plugins/plugin-recomp-change-prof.stderr b/testsuite/tests/plugins/plugin-recomp-change-prof.stderr
new file mode 100644
index 0000000000..b8018055db
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-change-prof.stderr
@@ -0,0 +1,12 @@
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run 2
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run 2
diff --git a/testsuite/tests/plugins/plugin-recomp-change.stderr b/testsuite/tests/plugins/plugin-recomp-change.stderr
new file mode 100644
index 0000000000..91747c8b7d
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-change.stderr
@@ -0,0 +1,6 @@
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run 2
diff --git a/testsuite/tests/plugins/plugin-recomp-flags.stderr b/testsuite/tests/plugins/plugin-recomp-flags.stderr
new file mode 100644
index 0000000000..a7f0da692a
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-flags.stderr
@@ -0,0 +1,6 @@
+Simple Plugin Passes Queried
+Got options: 0
+Simple Plugin Pass Run
+Simple Plugin Passes Queried
+Got options: 1
+Simple Plugin Pass Run
diff --git a/testsuite/tests/plugins/plugin-recomp-flags.stdout b/testsuite/tests/plugins/plugin-recomp-flags.stdout
new file mode 100644
index 0000000000..342fa3e0f8
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-flags.stdout
@@ -0,0 +1,4 @@
+[1 of 1] Compiling Main ( plugin-recomp-test.hs, plugin-recomp-test.o )
+Linking plugin-recomp-test ...
+[1 of 1] Compiling Main ( plugin-recomp-test.hs, plugin-recomp-test.o ) [Plugin fingerprint changed]
+Linking plugin-recomp-test ...
diff --git a/testsuite/tests/plugins/plugin-recomp-impure.stderr b/testsuite/tests/plugins/plugin-recomp-impure.stderr
new file mode 100644
index 0000000000..a1edc3bda5
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-impure.stderr
@@ -0,0 +1,6 @@
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
diff --git a/testsuite/tests/plugins/plugin-recomp-impure.stdout b/testsuite/tests/plugins/plugin-recomp-impure.stdout
new file mode 100644
index 0000000000..d282cfea8f
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-impure.stdout
@@ -0,0 +1,4 @@
+[1 of 1] Compiling Main ( plugin-recomp-test.hs, plugin-recomp-test.o )
+Linking plugin-recomp-test ...
+[1 of 1] Compiling Main ( plugin-recomp-test.hs, plugin-recomp-test.o ) [Plugin forced recompilation]
+Linking plugin-recomp-test ...
diff --git a/testsuite/tests/plugins/plugin-recomp-pure.stderr b/testsuite/tests/plugins/plugin-recomp-pure.stderr
new file mode 100644
index 0000000000..84e15cfa91
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-pure.stderr
@@ -0,0 +1,3 @@
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
diff --git a/testsuite/tests/plugins/plugin-recomp-pure.stdout b/testsuite/tests/plugins/plugin-recomp-pure.stdout
new file mode 100644
index 0000000000..a6828318a0
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-pure.stdout
@@ -0,0 +1,2 @@
+[1 of 1] Compiling Main ( plugin-recomp-test.hs, plugin-recomp-test.o )
+Linking plugin-recomp-test ...
diff --git a/testsuite/tests/plugins/plugin-recomp-test.hs b/testsuite/tests/plugins/plugin-recomp-test.hs
new file mode 100644
index 0000000000..2cc84a9eac
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp-test.hs
@@ -0,0 +1,8 @@
+-- Intended to test that the plugins have basic functionality --
+-- * Can modify the program
+-- * Get to see command line options
+module Main where
+
+main = do
+ putStrLn "Program Started"
+ putStrLn "Program Ended"
diff --git a/testsuite/tests/plugins/plugin-recomp/Common.hs b/testsuite/tests/plugins/plugin-recomp/Common.hs
new file mode 100644
index 0000000000..ce4f8240c8
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/Common.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE CPP #-}
+module Common where
+
+import GhcPlugins
+
+install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo]
+install options todos = do
+ putMsgS $ "Simple Plugin Passes Queried"
+ putMsgS $ "Got options: " ++ unwords options
+
+ -- Create some actual passes to continue the test.
+ return $ CoreDoPluginPass "Main pass" mainPass
+ : todos
+
+mainPass :: ModGuts -> CoreM ModGuts
+mainPass guts = do
+#if defined(RUN2)
+ putMsgS "Simple Plugin Pass Run 2"
+#else
+ putMsgS "Simple Plugin Pass Run"
+#endif
+ return guts
diff --git a/testsuite/tests/plugins/plugin-recomp/FingerprintPlugin.hs b/testsuite/tests/plugins/plugin-recomp/FingerprintPlugin.hs
new file mode 100644
index 0000000000..584962470a
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/FingerprintPlugin.hs
@@ -0,0 +1,10 @@
+module FingerprintPlugin where
+
+import GhcPlugins
+import Common
+
+plugin :: Plugin
+plugin = defaultPlugin {
+ installCoreToDos = install,
+ pluginRecompile = flagRecompile
+ }
diff --git a/testsuite/tests/plugins/plugin-recomp/ImpurePlugin.hs b/testsuite/tests/plugins/plugin-recomp/ImpurePlugin.hs
new file mode 100644
index 0000000000..0ccb626a15
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/ImpurePlugin.hs
@@ -0,0 +1,10 @@
+module ImpurePlugin where
+
+import GhcPlugins
+import Common
+
+plugin :: Plugin
+plugin = defaultPlugin {
+ installCoreToDos = install,
+ pluginRecompile = impurePlugin
+ }
diff --git a/testsuite/tests/plugins/plugin-recomp/LICENSE b/testsuite/tests/plugins/plugin-recomp/LICENSE
new file mode 100644
index 0000000000..6297f71b3f
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/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/plugin-recomp/Makefile b/testsuite/tests/plugins/plugin-recomp/Makefile
new file mode 100644
index 0000000000..9ee7737339
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/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/plugins/plugin-recomp/PurePlugin.hs b/testsuite/tests/plugins/plugin-recomp/PurePlugin.hs
new file mode 100644
index 0000000000..c106aa3400
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/PurePlugin.hs
@@ -0,0 +1,10 @@
+module PurePlugin where
+
+import GhcPlugins
+import Common
+
+plugin :: Plugin
+plugin = defaultPlugin {
+ installCoreToDos = install,
+ pluginRecompile = purePlugin
+ }
diff --git a/testsuite/tests/plugins/plugin-recomp/Setup.hs b/testsuite/tests/plugins/plugin-recomp/Setup.hs
new file mode 100644
index 0000000000..e8ef27dbba
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+
+main = defaultMain
diff --git a/testsuite/tests/plugins/plugin-recomp/plugin-recomp.cabal b/testsuite/tests/plugins/plugin-recomp/plugin-recomp.cabal
new file mode 100644
index 0000000000..dabaf72e03
--- /dev/null
+++ b/testsuite/tests/plugins/plugin-recomp/plugin-recomp.cabal
@@ -0,0 +1,20 @@
+Name: plugin-recompilation
+Version: 0.1
+Synopsis: Testing plugin recompilation
+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:
+ PurePlugin
+ ImpurePlugin
+ FingerprintPlugin
+ Common
diff --git a/testsuite/tests/plugins/plugins03.stderr b/testsuite/tests/plugins/plugins03.stderr
index c02965ad1f..a923550592 100644
--- a/testsuite/tests/plugins/plugins03.stderr
+++ b/testsuite/tests/plugins/plugins03.stderr
@@ -1,2 +1,2 @@
<command line>: Could not find module ‘Simple.NonExistentPlugin’
-Use -v to see a list of the files searched for.
+Use -v (or `:set -v` in ghci) to see a list of the files searched for.
diff --git a/testsuite/tests/plugins/plugins04.stderr b/testsuite/tests/plugins/plugins04.stderr
index f0acc67d22..46c0f9ce55 100644
--- a/testsuite/tests/plugins/plugins04.stderr
+++ b/testsuite/tests/plugins/plugins04.stderr
@@ -1,2 +1,2 @@
Module imports form a cycle:
- module ‘HomePackagePlugin’ (./HomePackagePlugin.hs) imports itself
+ module ‘HomePackagePlugin’ (./HomePackagePlugin.hs) imports itself \ No newline at end of file
diff --git a/testsuite/tests/plugins/plugins08.hs b/testsuite/tests/plugins/plugins08.hs
new file mode 100644
index 0000000000..403d81f076
--- /dev/null
+++ b/testsuite/tests/plugins/plugins08.hs
@@ -0,0 +1,18 @@
+-- Tests a plugin added with TH.addCorePlugin
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import Simple.DataStructures
+import Language.Haskell.TH.Syntax
+
+do addCorePlugin "Simple.Plugin"
+ return []
+
+{-# ANN theMessage (ReplaceWith "Right") #-}
+{-# NOINLINE theMessage #-}
+theMessage = "Wrong"
+
+main = do
+ putStrLn "Program Started"
+ putStrLn theMessage
+ putStrLn "Program Ended"
diff --git a/testsuite/tests/plugins/plugins08.stderr b/testsuite/tests/plugins/plugins08.stderr
new file mode 100644
index 0000000000..72667a052f
--- /dev/null
+++ b/testsuite/tests/plugins/plugins08.stderr
@@ -0,0 +1,4 @@
+Simple Plugin Passes Queried
+Got options:
+Simple Plugin Pass Run
+Performing Replacement
diff --git a/testsuite/tests/plugins/plugins08.stdout b/testsuite/tests/plugins/plugins08.stdout
new file mode 100644
index 0000000000..5633757f84
--- /dev/null
+++ b/testsuite/tests/plugins/plugins08.stdout
@@ -0,0 +1,3 @@
+Program Started
+Right
+Program Ended
diff --git a/testsuite/tests/plugins/plugins09.hs b/testsuite/tests/plugins/plugins09.hs
new file mode 100644
index 0000000000..d843c00b78
--- /dev/null
+++ b/testsuite/tests/plugins/plugins09.hs
@@ -0,0 +1 @@
+module A where
diff --git a/testsuite/tests/plugins/plugins09.stdout b/testsuite/tests/plugins/plugins09.stdout
new file mode 100644
index 0000000000..885850e598
--- /dev/null
+++ b/testsuite/tests/plugins/plugins09.stdout
@@ -0,0 +1,9 @@
+parsePlugin(a,b)
+interfacePlugin: Prelude
+interfacePlugin: GHC.Float
+interfacePlugin: GHC.Base
+typeCheckPlugin (rn)
+interfacePlugin: GHC.Types
+typeCheckPlugin (tc)
+interfacePlugin: GHC.Integer.Type
+interfacePlugin: GHC.Natural
diff --git a/testsuite/tests/plugins/plugins10.hs b/testsuite/tests/plugins/plugins10.hs
new file mode 100644
index 0000000000..d4564a2c29
--- /dev/null
+++ b/testsuite/tests/plugins/plugins10.hs
@@ -0,0 +1,9 @@
+{-# OPTIONS_GHC -fplugin-opt Simple.SourcePlugin:a #-}
+{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
+module B where
+
+import QuasiQuotation
+
+$(return [])
+
+x = [stringify|x|]
diff --git a/testsuite/tests/plugins/plugins10.stdout b/testsuite/tests/plugins/plugins10.stdout
new file mode 100644
index 0000000000..737789cc56
--- /dev/null
+++ b/testsuite/tests/plugins/plugins10.stdout
@@ -0,0 +1,18 @@
+parsePlugin()
+interfacePlugin: Prelude
+interfacePlugin: Language.Haskell.TH
+interfacePlugin: Language.Haskell.TH.Quote
+interfacePlugin: GHC.Float
+interfacePlugin: GHC.Base
+interfacePlugin: Language.Haskell.TH.Syntax
+interfacePlugin: GHC.Types
+typeCheckPlugin (rn)
+typeCheckPlugin (tc)
+interfacePlugin: GHC.Integer.Type
+parsePlugin(a)
+interfacePlugin: Language.Haskell.TH.Lib.Internal
+metaPlugin: return []
+metaPlugin: quoteExp stringify "x"
+interfacePlugin: GHC.CString
+typeCheckPlugin (rn)
+typeCheckPlugin (tc) \ No newline at end of file
diff --git a/testsuite/tests/plugins/plugins11.hs b/testsuite/tests/plugins/plugins11.hs
new file mode 100644
index 0000000000..f714472a07
--- /dev/null
+++ b/testsuite/tests/plugins/plugins11.hs
@@ -0,0 +1,2 @@
+{-# OPTIONS_GHC -fplugin Simple.SourcePlugin #-}
+module A where
diff --git a/testsuite/tests/plugins/plugins11.stdout b/testsuite/tests/plugins/plugins11.stdout
new file mode 100644
index 0000000000..8e0dca4335
--- /dev/null
+++ b/testsuite/tests/plugins/plugins11.stdout
@@ -0,0 +1,9 @@
+parsePlugin()
+interfacePlugin: Prelude
+interfacePlugin: GHC.Float
+interfacePlugin: GHC.Base
+typeCheckPlugin (rn)
+interfacePlugin: GHC.Types
+typeCheckPlugin (tc)
+interfacePlugin: GHC.Integer.Type
+interfacePlugin: GHC.Natural
diff --git a/testsuite/tests/plugins/plugins12.hs b/testsuite/tests/plugins/plugins12.hs
new file mode 100644
index 0000000000..96d35db179
--- /dev/null
+++ b/testsuite/tests/plugins/plugins12.hs
@@ -0,0 +1,9 @@
+{-# OPTIONS_GHC -fplugin Simple.RemovePlugin #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:map #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:parse #-}
+-- testing that the plugin can alter the parsed representation
+module A where
+
+map x = ()
+
+x = map show [1,2,3]
diff --git a/testsuite/tests/plugins/plugins13.hs b/testsuite/tests/plugins/plugins13.hs
new file mode 100644
index 0000000000..273aba2df9
--- /dev/null
+++ b/testsuite/tests/plugins/plugins13.hs
@@ -0,0 +1,5 @@
+module A where
+
+import PluginFilteredExport
+
+x = map show [1,2,3]
diff --git a/testsuite/tests/plugins/plugins14.hs b/testsuite/tests/plugins/plugins14.hs
new file mode 100644
index 0000000000..6f4c2f5780
--- /dev/null
+++ b/testsuite/tests/plugins/plugins14.hs
@@ -0,0 +1,11 @@
+{-# OPTIONS_GHC -fplugin Simple.RemovePlugin #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:map #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:interface #-}
+module A where
+-- test if a definition can be removed from loaded interface
+
+map :: ()
+map = ()
+
+x :: ()
+x = map
diff --git a/testsuite/tests/plugins/plugins15.hs b/testsuite/tests/plugins/plugins15.hs
new file mode 100644
index 0000000000..be760192ae
--- /dev/null
+++ b/testsuite/tests/plugins/plugins15.hs
@@ -0,0 +1,12 @@
+{-# OPTIONS_GHC -fplugin Simple.RemovePlugin #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:clear #-}
+{-# OPTIONS_GHC -fplugin-opt Simple.RemovePlugin:meta #-}
+{-# LANGUAGE TemplateHaskell #-}
+-- testing that the plugin can alter the evaluated splice
+module A where
+
+import MetaRemoveHelper
+
+$(clear [d| a = () |])
+
+x = a
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs
index e8c2435849..94cb74b151 100644
--- a/testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs
+++ b/testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs
@@ -16,14 +16,15 @@ import qualified Language.Haskell.TH as TH
plugin :: Plugin
plugin = defaultPlugin {
- installCoreToDos = install
+ installCoreToDos = install,
+ pluginRecompile = purePlugin
}
install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo]
install options todos = do
putMsgS $ "Simple Plugin Passes Queried"
putMsgS $ "Got options: " ++ unwords options
-
+
-- Create some actual passes to continue the test.
return $ CoreDoPluginPass "Main pass" mainPass
: todos
@@ -36,7 +37,7 @@ findNameBind target (NonRec b e) = findNameBndr target b
findNameBind target (Rec bes) = mconcat (map (findNameBndr target . fst) bes)
findNameBndr :: String -> CoreBndr -> First Name
-findNameBndr target b
+findNameBndr target b
= if getOccString (varName b) == target
then First (Just (varName b))
else First Nothing
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs
new file mode 100644
index 0000000000..2d14eeaf85
--- /dev/null
+++ b/testsuite/tests/plugins/simple-plugin/Simple/RemovePlugin.hs
@@ -0,0 +1,69 @@
+{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
+module Simple.RemovePlugin where
+
+import Control.Monad.IO.Class
+import Data.List (intercalate)
+import Plugins
+import Bag
+import HscTypes
+import TcRnTypes
+import HsExtension
+import HsExpr
+import Outputable
+import SrcLoc
+import HsSyn
+import HsBinds
+import OccName
+import RdrName
+import Name
+import Avail
+
+plugin :: Plugin
+plugin = defaultPlugin { parsedResultAction = parsedPlugin
+ , typeCheckResultAction = typecheckPlugin
+ , spliceRunAction = metaPlugin'
+ , interfaceLoadAction = interfaceLoadPlugin'
+ }
+
+parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule
+ -> Hsc HsParsedModule
+parsedPlugin [name, "parse"] _ pm
+ = return $ pm { hpm_module = removeParsedBinding name (hpm_module pm) }
+parsedPlugin _ _ pm = return pm
+
+removeParsedBinding :: String -> Located (HsModule GhcPs)
+ -> Located (HsModule GhcPs)
+removeParsedBinding name (L l m)
+ = (L l (m { hsmodDecls = filter (notNamedAs name) (hsmodDecls m) } ))
+ where notNamedAs name (L _ (ValD _ (FunBind { fun_id = L _ fid })))
+ = occNameString (rdrNameOcc fid) /= name
+ notNamedAs _ _ = True
+
+typecheckPlugin :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
+typecheckPlugin [name, "typecheck"] _ tc
+ = return $ tc { tcg_exports = filter (availNotNamedAs name) (tcg_exports tc)
+ , tcg_binds = filterBag (notNamedAs name) (tcg_binds tc)
+ }
+ where notNamedAs name (L _ FunBind { fun_id = L _ fid })
+ = occNameString (getOccName fid) /= name
+ notNamedAs name (L _ AbsBinds { abs_binds = bnds })
+ = all (notNamedAs name) bnds
+ notNamedAs _ (L _ b) = True
+typecheckPlugin _ _ tc = return tc
+
+metaPlugin' :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc)
+metaPlugin' [name, "meta"] (L _ (HsApp noExt (L l (HsVar _ (L _ id))) e))
+ | occNameString (getOccName id) == name
+ = return e
+metaPlugin' _ meta = return meta
+
+interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface
+interfaceLoadPlugin' [name, "interface"] iface
+ = return $ iface { mi_exports = filter (availNotNamedAs name)
+ (mi_exports iface)
+ }
+interfaceLoadPlugin' _ iface = return iface
+
+availNotNamedAs :: String -> AvailInfo -> Bool
+availNotNamedAs name avail
+ = occNameString (getOccName (availName avail)) /= name
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
new file mode 100644
index 0000000000..b9bdaeb37a
--- /dev/null
+++ b/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
@@ -0,0 +1,52 @@
+module Simple.SourcePlugin where
+
+import Control.Monad.IO.Class
+import Data.List (intercalate)
+import Data.Maybe (isJust)
+import Plugins
+import HscTypes
+import TcRnTypes
+import HsExtension
+import Avail
+import HsExpr
+import Outputable
+import HsImpExp
+import HsDecls
+import HsDoc
+
+plugin :: Plugin
+plugin = defaultPlugin { parsedResultAction = parsedPlugin
+ , typeCheckResultAction = typecheckPlugin
+ , spliceRunAction = metaPlugin'
+ , interfaceLoadAction = interfaceLoadPlugin'
+ , renamedResultAction = renamedAction
+ }
+
+parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule
+ -> Hsc HsParsedModule
+parsedPlugin opts _ pm
+ = do liftIO $ putStrLn $ "parsePlugin(" ++ intercalate "," opts ++ ")"
+ return pm
+
+renamedAction :: [CommandLineOption]
+ -> TcGblEnv -> HsGroup GhcRn
+ -> TcM (TcGblEnv, HsGroup GhcRn)
+renamedAction _ env grp
+ = do liftIO $ putStrLn "typeCheckPlugin (rn)"
+ return (env, grp)
+
+typecheckPlugin :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
+typecheckPlugin _ _ tc
+ = do liftIO $ putStrLn "typeCheckPlugin (tc)"
+ return tc
+
+metaPlugin' :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc)
+metaPlugin' _ meta
+ = do liftIO $ putStrLn $ "metaPlugin: " ++ (showSDocUnsafe $ ppr meta)
+ return meta
+
+interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface
+interfaceLoadPlugin' _ iface
+ = do liftIO $ putStrLn $ "interfacePlugin: "
+ ++ (showSDocUnsafe $ ppr $ mi_module iface)
+ return iface
diff --git a/testsuite/tests/plugins/simple-plugin/simple-plugin.cabal b/testsuite/tests/plugins/simple-plugin/simple-plugin.cabal
index 011ed67e23..0a3c49e988 100644
--- a/testsuite/tests/plugins/simple-plugin/simple-plugin.cabal
+++ b/testsuite/tests/plugins/simple-plugin/simple-plugin.cabal
@@ -17,4 +17,6 @@ Library
Exposed-Modules:
Simple.Plugin
Simple.BadlyTypedPlugin
- Simple.DataStructures \ No newline at end of file
+ Simple.DataStructures
+ Simple.SourcePlugin
+ Simple.RemovePlugin