summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/T13676.hs
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2019-10-08 22:24:07 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-12 06:33:05 -0400
commitf1ce3535d20007dc78aeed096f32fc9dfacf11b3 (patch)
tree1edd6e8092ff6bfcc5c6d43cb7090289f9fbe1e8 /testsuite/tests/rts/T13676.hs
parentc2290596f10ce732be85503d3ef0f0b50b7e925a (diff)
downloadhaskell-f1ce3535d20007dc78aeed096f32fc9dfacf11b3.tar.gz
Escape stats file command (#13676)
Diffstat (limited to 'testsuite/tests/rts/T13676.hs')
-rw-r--r--testsuite/tests/rts/T13676.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/rts/T13676.hs b/testsuite/tests/rts/T13676.hs
new file mode 100644
index 0000000000..8fdeaed16d
--- /dev/null
+++ b/testsuite/tests/rts/T13676.hs
@@ -0,0 +1,43 @@
+-- T13676 test driver.
+-- Tests that the command dumped by the RTS into the stats file is properly escaped.
+
+module T13676_Driver (GhcPath(GhcPath), test_t13676) where
+
+import Control.Monad
+import Data.Maybe
+
+import System.Exit
+import System.Process
+import System.FilePath
+
+-- This expression contains quotation marks and spaces which must be escaped.
+expr :: String
+expr = "'$' == '\\x0024'"
+
+-- Check that evaluation of expr succeeds.
+check_output :: String -> IO ()
+check_output out =
+ unless (lines out == ["True"]) $
+ exitWith (ExitFailure 13)
+
+-- A name for the .t file.
+tfilename :: String
+tfilename = "T13676.t"
+
+newtype GhcPath = GhcPath FilePath
+
+-- GHC arguments for the initial invocation.
+initial_cmd_args :: [String]
+initial_cmd_args = ["-e", expr, "+RTS", "-t" ++ tfilename]
+
+test_t13676 :: GhcPath -> IO ()
+test_t13676 (GhcPath ghcPath) = do
+ initial_out <- readCreateProcess (proc ghcPath initial_cmd_args) ""
+ check_output initial_out
+ tfile_content <- readFile tfilename
+ dumped_cmd <-
+ case listToMaybe (lines tfile_content) of
+ Nothing -> exitWith (ExitFailure 14)
+ Just str -> return str
+ secondary_out <- readCreateProcess (shell dumped_cmd) ""
+ check_output secondary_out