Add a test for dynCompileExpr
authorIan Lynagh <igloo@earth.li>
Wed, 5 Oct 2011 18:17:20 +0000 (19:17 +0100)
committerIan Lynagh <igloo@earth.li>
Wed, 5 Oct 2011 18:17:20 +0000 (19:17 +0100)
testsuite/tests/ghc-api/dynCompileExpr/Makefile [new file with mode: 0644]
testsuite/tests/ghc-api/dynCompileExpr/all.T [new file with mode: 0644]
testsuite/tests/ghc-api/dynCompileExpr/dynCompileExpr.hs [new file with mode: 0644]
testsuite/tests/ghc-api/dynCompileExpr/dynCompileExpr.stdout [new file with mode: 0644]

diff --git a/testsuite/tests/ghc-api/dynCompileExpr/Makefile b/testsuite/tests/ghc-api/dynCompileExpr/Makefile
new file mode 100644 (file)
index 0000000..8ed1da5
--- /dev/null
@@ -0,0 +1,13 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+clean:
+       rm -f *.o *.hi
+
+dynCompileExpr: clean
+       '$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc dynCompileExpr
+       ./dynCompileExpr "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
+
+.PHONY: clean dynCompileExpr
+
diff --git a/testsuite/tests/ghc-api/dynCompileExpr/all.T b/testsuite/tests/ghc-api/dynCompileExpr/all.T
new file mode 100644 (file)
index 0000000..57962cf
--- /dev/null
@@ -0,0 +1,4 @@
+test('dynCompileExpr',
+     normal,
+     run_command,
+     ['$MAKE -s --no-print-directory dynCompileExpr'])
diff --git a/testsuite/tests/ghc-api/dynCompileExpr/dynCompileExpr.hs b/testsuite/tests/ghc-api/dynCompileExpr/dynCompileExpr.hs
new file mode 100644 (file)
index 0000000..9cdd3f0
--- /dev/null
@@ -0,0 +1,18 @@
+
+module Main where
+
+import GHC
+import MonadUtils
+
+import System.Environment
+
+main :: IO ()
+main = do [libdir] <- getArgs
+          runGhc (Just libdir) doit
+
+doit :: Ghc ()
+doit = do
+  getSessionDynFlags >>= setSessionDynFlags
+  dyn <- dynCompileExpr "()"
+  liftIO $ print dyn
+
diff --git a/testsuite/tests/ghc-api/dynCompileExpr/dynCompileExpr.stdout b/testsuite/tests/ghc-api/dynCompileExpr/dynCompileExpr.stdout
new file mode 100644 (file)
index 0000000..e5f4ec8
--- /dev/null
@@ -0,0 +1 @@
+<<()>>