Implement recompilation checking for -fignore-asserts
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Mon, 3 Jul 2017 20:53:31 +0000 (16:53 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 3 Jul 2017 22:58:10 +0000 (18:58 -0400)
Test Plan: Added a test which was previously failing

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13914

Differential Revision: https://phabricator.haskell.org/D3698

compiler/iface/FlagChecker.hs
testsuite/tests/driver/T13914/Makefile [new file with mode: 0644]
testsuite/tests/driver/T13914/T13914.stdout [new file with mode: 0644]
testsuite/tests/driver/T13914/all.T [new file with mode: 0644]
testsuite/tests/driver/T13914/main.hs [new file with mode: 0644]

index 2c0b6c4..fd0459d 100644 (file)
@@ -61,8 +61,12 @@ fingerprintDynFlags dflags@DynFlags{..} this_mod nameio =
         -- hpcDir is output-only, so we should recompile if it changes
         hpc = if gopt Opt_Hpc dflags then Just hpcDir else Nothing
 
+        -- -fignore-asserts, which affects how `Control.Exception.assert` works
+        ignore_asserts = gopt Opt_IgnoreAsserts dflags
+
         -- Nesting just to avoid ever more Binary tuple instances
-        flags = (mainis, safeHs, lang, cpp, paths, (prof, opt, hpc))
+        flags = (mainis, safeHs, lang, cpp, paths,
+                 (prof, opt, hpc, ignore_asserts))
 
     in -- pprTrace "flags" (ppr flags) $
        computeFingerprint nameio flags
diff --git a/testsuite/tests/driver/T13914/Makefile b/testsuite/tests/driver/T13914/Makefile
new file mode 100644 (file)
index 0000000..764942c
--- /dev/null
@@ -0,0 +1,16 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+t13914:
+       echo "Without -fignore-asserts"
+       '$(TEST_HC)' $(TEST_HC_OPTS) main.hs
+       (./main 2>&1); true
+       sleep 1
+       echo "With -fignore-asserts"
+       '$(TEST_HC)' $(TEST_HC_OPTS) -fignore-asserts main.hs
+       ./main 2>&1
+       sleep 1
+       echo "Without -fignore-asserts"
+       '$(TEST_HC)' $(TEST_HC_OPTS) main.hs
+       (./main 2>&1); true
diff --git a/testsuite/tests/driver/T13914/T13914.stdout b/testsuite/tests/driver/T13914/T13914.stdout
new file mode 100644 (file)
index 0000000..04d14aa
--- /dev/null
@@ -0,0 +1,16 @@
+Without -fignore-asserts
+[1 of 1] Compiling Main             ( main.hs, main.o )
+Linking main ...
+main: Assertion failed
+CallStack (from HasCallStack):
+  assert, called at main.hs:3:8 in main:Main
+With -fignore-asserts
+[1 of 1] Compiling Main             ( main.hs, main.o ) [flags changed]
+Linking main ...
+OK
+Without -fignore-asserts
+[1 of 1] Compiling Main             ( main.hs, main.o ) [flags changed]
+Linking main ...
+main: Assertion failed
+CallStack (from HasCallStack):
+  assert, called at main.hs:3:8 in main:Main
diff --git a/testsuite/tests/driver/T13914/all.T b/testsuite/tests/driver/T13914/all.T
new file mode 100644 (file)
index 0000000..2e6a952
--- /dev/null
@@ -0,0 +1,4 @@
+test('T13914',
+     [extra_files(['main.hs'])],
+     run_command,
+     ['$MAKE -s --no-print-directory t13914'])
diff --git a/testsuite/tests/driver/T13914/main.hs b/testsuite/tests/driver/T13914/main.hs
new file mode 100644 (file)
index 0000000..859f3e6
--- /dev/null
@@ -0,0 +1,3 @@
+import Control.Exception (assert)
+
+main = assert False (putStrLn "OK")