summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-11-19 12:39:45 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-14 20:53:51 -0500
commit5686f47ba1866094a1546473ae2f0c523fb20d9e (patch)
tree97c2ba629c19186cccbf1cedfc295dcd00406fcf /testsuite
parent71ecb55b0b3ada2c9841dbc9f4a36fed52eb652e (diff)
downloadhaskell-5686f47ba1866094a1546473ae2f0c523fb20d9e.tar.gz
ghc-bin: Add --merge-objs mode
This adds a new mode, `--merge-objs`, which can be used to produce merged GHCi library objects. As future work we will rip out the object-merging logic in Hadrian and Cabal and instead use this mode. Closes #20712.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/driver/MergeObjsMode/A.hs5
-rw-r--r--testsuite/tests/driver/MergeObjsMode/B.hs4
-rw-r--r--testsuite/tests/driver/MergeObjsMode/Main.hs7
-rw-r--r--testsuite/tests/driver/MergeObjsMode/Makefile12
-rw-r--r--testsuite/tests/driver/MergeObjsMode/MergeObjsMode.stdout1
-rw-r--r--testsuite/tests/driver/MergeObjsMode/all.T4
-rw-r--r--testsuite/tests/driver/MergeObjsMode/app/Main.hs6
7 files changed, 39 insertions, 0 deletions
diff --git a/testsuite/tests/driver/MergeObjsMode/A.hs b/testsuite/tests/driver/MergeObjsMode/A.hs
new file mode 100644
index 0000000000..af7ebc8eb9
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/A.hs
@@ -0,0 +1,5 @@
+module A where
+
+a :: Int
+a = 42
+
diff --git a/testsuite/tests/driver/MergeObjsMode/B.hs b/testsuite/tests/driver/MergeObjsMode/B.hs
new file mode 100644
index 0000000000..0cb45d3f54
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/B.hs
@@ -0,0 +1,4 @@
+module B where
+
+b :: String
+b = "hello world"
diff --git a/testsuite/tests/driver/MergeObjsMode/Main.hs b/testsuite/tests/driver/MergeObjsMode/Main.hs
new file mode 100644
index 0000000000..4785441214
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/Main.hs
@@ -0,0 +1,7 @@
+module Main where
+
+import A
+import B
+
+main :: IO ()
+main = print (a,b)
diff --git a/testsuite/tests/driver/MergeObjsMode/Makefile b/testsuite/tests/driver/MergeObjsMode/Makefile
new file mode 100644
index 0000000000..c36e0626a6
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/Makefile
@@ -0,0 +1,12 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+MergeObjsMode :
+ "$(TEST_HC)" $(TEST_HC_OPTS) -c A.hs
+ "$(TEST_HC)" $(TEST_HC_OPTS) -c B.hs
+ "$(TEST_HC)" $(TEST_HC_OPTS) -c Main.hs
+ "$(TEST_HC)" $(TEST_HC_OPTS) -merge-objs -o HSlib.o A.o B.o
+ "$(TEST_HC)" $(TEST_HC_OPTS) -o Main Main.o HSlib.o
+ ./Main
+
diff --git a/testsuite/tests/driver/MergeObjsMode/MergeObjsMode.stdout b/testsuite/tests/driver/MergeObjsMode/MergeObjsMode.stdout
new file mode 100644
index 0000000000..79c8eebc6e
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/MergeObjsMode.stdout
@@ -0,0 +1 @@
+(42,"hello world")
diff --git a/testsuite/tests/driver/MergeObjsMode/all.T b/testsuite/tests/driver/MergeObjsMode/all.T
new file mode 100644
index 0000000000..ebcf4546c6
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/all.T
@@ -0,0 +1,4 @@
+test('MergeObjsMode',
+ extra_files(['A.hs', 'B.hs', 'Main.hs']),
+ makefile_test,
+ [])
diff --git a/testsuite/tests/driver/MergeObjsMode/app/Main.hs b/testsuite/tests/driver/MergeObjsMode/app/Main.hs
new file mode 100644
index 0000000000..c1ce71b0e6
--- /dev/null
+++ b/testsuite/tests/driver/MergeObjsMode/app/Main.hs
@@ -0,0 +1,6 @@
+module Main where
+
+import A
+import B
+
+