diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-12-27 10:50:01 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-01-03 11:56:14 -0800 |
commit | 2223e196b2dc5340d70e58be011c279d381b4319 (patch) | |
tree | 3c587547990df7c62d73598f9dfe991afb0b4880 /testsuite/tests | |
parent | af4d99803ea7676f88f250ad56a8c31c1c8cd5bc (diff) | |
download | haskell-2223e196b2dc5340d70e58be011c279d381b4319.tar.gz |
Fix #9243 so recompilation avoidance works with -fno-code
Summary:
Where we track timestamps of object files, also track timestamps
for interface files. When -fno-code -fwrite-interface is enabled, use
the interface file timestamp as an extra check to see if the files are
up-to-date. We had to apply this logic to one-shot and make modes.
This fix would be good to merge into 7.10; it makes using -fno-code
-fwrite-interface for flywheel type checking usable.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate and new test cases
Reviewers: austin
Subscribers: carter, thomie
Differential Revision: https://phabricator.haskell.org/D596
GHC Trac Issues: #9243
Diffstat (limited to 'testsuite/tests')
20 files changed, 126 insertions, 1 deletions
diff --git a/testsuite/tests/driver/recomp001/Makefile b/testsuite/tests/driver/recomp001/Makefile index f264e0255c..dc7d492cb1 100644 --- a/testsuite/tests/driver/recomp001/Makefile +++ b/testsuite/tests/driver/recomp001/Makefile @@ -18,6 +18,5 @@ clean: recomp001: clean cp B1.hs B.hs '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) --make -v0 C.hs - sleep 1 cp B2.hs B.hs -'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) --make -v0 C.hs diff --git a/testsuite/tests/driver/retc001/A.hs b/testsuite/tests/driver/retc001/A.hs new file mode 100644 index 0000000000..d7fc96e70e --- /dev/null +++ b/testsuite/tests/driver/retc001/A.hs @@ -0,0 +1,4 @@ +module A where + +foo :: Int +foo = 4 diff --git a/testsuite/tests/driver/retc001/B1.hs b/testsuite/tests/driver/retc001/B1.hs new file mode 100644 index 0000000000..d0efd79bf0 --- /dev/null +++ b/testsuite/tests/driver/retc001/B1.hs @@ -0,0 +1,3 @@ +module B (foo) where + +import A (foo) diff --git a/testsuite/tests/driver/retc001/B2.hs b/testsuite/tests/driver/retc001/B2.hs new file mode 100644 index 0000000000..213d77d5eb --- /dev/null +++ b/testsuite/tests/driver/retc001/B2.hs @@ -0,0 +1,3 @@ +module B () where + +import A () diff --git a/testsuite/tests/driver/retc001/C.hs b/testsuite/tests/driver/retc001/C.hs new file mode 100644 index 0000000000..d38b2ff51c --- /dev/null +++ b/testsuite/tests/driver/retc001/C.hs @@ -0,0 +1,6 @@ +module Main (main) where + +import B (foo) + +main :: IO () +main = print foo diff --git a/testsuite/tests/driver/retc001/Makefile b/testsuite/tests/driver/retc001/Makefile new file mode 100644 index 0000000000..a3cf6ebf3d --- /dev/null +++ b/testsuite/tests/driver/retc001/Makefile @@ -0,0 +1,24 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# -fforce-recomp makes lots of driver tests trivially pass, so we +# filter it out from $(TEST_HC_OPTS). +TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS)) + +# Recompilation tests + +clean: + rm -f *.o *.hi + rm -f B.hs C + +# 001: removing an export should force a retypecheck of dependent modules. + +retc001: clean + cp B1.hs B.hs + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface --make C.hs + echo 'Middle' + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface --make C.hs + echo 'End' + cp B2.hs B.hs + -'$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface --make C.hs diff --git a/testsuite/tests/driver/retc001/all.T b/testsuite/tests/driver/retc001/all.T new file mode 100644 index 0000000000..7e5fda589c --- /dev/null +++ b/testsuite/tests/driver/retc001/all.T @@ -0,0 +1,5 @@ +test('retc001', + [clean_cmd('$MAKE -s clean')], + run_command, + ['$MAKE -s --no-print-directory retc001']) + diff --git a/testsuite/tests/driver/retc001/retc001.stderr b/testsuite/tests/driver/retc001/retc001.stderr new file mode 100644 index 0000000000..724326e081 --- /dev/null +++ b/testsuite/tests/driver/retc001/retc001.stderr @@ -0,0 +1,2 @@ + +C.hs:3:11: Module ‘B’ does not export ‘foo’ diff --git a/testsuite/tests/driver/retc001/retc001.stdout b/testsuite/tests/driver/retc001/retc001.stdout new file mode 100644 index 0000000000..381850d9a4 --- /dev/null +++ b/testsuite/tests/driver/retc001/retc001.stdout @@ -0,0 +1,7 @@ +[1 of 3] Compiling A ( A.hs, nothing ) +[2 of 3] Compiling B ( B.hs, nothing ) +[3 of 3] Compiling Main ( C.hs, nothing ) +Middle +End +[2 of 3] Compiling B ( B.hs, nothing ) +[3 of 3] Compiling Main ( C.hs, nothing ) [B changed] diff --git a/testsuite/tests/driver/retc002/Makefile b/testsuite/tests/driver/retc002/Makefile new file mode 100644 index 0000000000..528df4b471 --- /dev/null +++ b/testsuite/tests/driver/retc002/Makefile @@ -0,0 +1,20 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# -fforce-recomp makes lots of driver tests trivially pass, so we +# filter it out from $(TEST_HC_OPTS). +TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS)) + +# Recompilation tests + +clean: + rm -f *.o* + rm -f *.hi* + +# Only the first invocation should print any "Compiling" messages + +retc002: clean + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fwrite-interface -fno-code --make Q.hs + echo Middle >&2 + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fwrite-interface -fno-code --make Q.hs diff --git a/testsuite/tests/driver/retc002/Q.hs b/testsuite/tests/driver/retc002/Q.hs new file mode 100644 index 0000000000..3565f02de4 --- /dev/null +++ b/testsuite/tests/driver/retc002/Q.hs @@ -0,0 +1,3 @@ +module Q where + +import {-# SOURCE #-} W diff --git a/testsuite/tests/driver/retc002/W.hs b/testsuite/tests/driver/retc002/W.hs new file mode 100644 index 0000000000..3dd7ff92c8 --- /dev/null +++ b/testsuite/tests/driver/retc002/W.hs @@ -0,0 +1,3 @@ +module W where + +import Q diff --git a/testsuite/tests/driver/retc002/W.hs-boot b/testsuite/tests/driver/retc002/W.hs-boot new file mode 100644 index 0000000000..4992c51af8 --- /dev/null +++ b/testsuite/tests/driver/retc002/W.hs-boot @@ -0,0 +1 @@ +module W where diff --git a/testsuite/tests/driver/retc002/all.T b/testsuite/tests/driver/retc002/all.T new file mode 100644 index 0000000000..47794fbe39 --- /dev/null +++ b/testsuite/tests/driver/retc002/all.T @@ -0,0 +1,6 @@ +test('retc002', + [when(fast(), skip), + clean_cmd('$MAKE -s clean')], + run_command, + ['$MAKE -s --no-print-directory retc002']) + diff --git a/testsuite/tests/driver/retc002/retc002.stderr b/testsuite/tests/driver/retc002/retc002.stderr new file mode 100644 index 0000000000..56cdd85e1d --- /dev/null +++ b/testsuite/tests/driver/retc002/retc002.stderr @@ -0,0 +1 @@ +Middle diff --git a/testsuite/tests/driver/retc002/retc002.stdout b/testsuite/tests/driver/retc002/retc002.stdout new file mode 100644 index 0000000000..e76853f8f8 --- /dev/null +++ b/testsuite/tests/driver/retc002/retc002.stdout @@ -0,0 +1,3 @@ +[1 of 3] Compiling W[boot] ( W.hs-boot, nothing ) +[2 of 3] Compiling Q ( Q.hs, nothing ) +[3 of 3] Compiling W ( W.hs, nothing ) diff --git a/testsuite/tests/driver/retc003/A.hs b/testsuite/tests/driver/retc003/A.hs new file mode 100644 index 0000000000..f3902c5c06 --- /dev/null +++ b/testsuite/tests/driver/retc003/A.hs @@ -0,0 +1,2 @@ +module A where +import Data.Char diff --git a/testsuite/tests/driver/retc003/Makefile b/testsuite/tests/driver/retc003/Makefile new file mode 100644 index 0000000000..c58d0c580c --- /dev/null +++ b/testsuite/tests/driver/retc003/Makefile @@ -0,0 +1,24 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# -fforce-recomp makes lots of driver tests trivially pass, so we +# filter it out from $(TEST_HC_OPTS). +TEST_HC_OPTS_NO_RECOMP = $(filter-out -fforce-recomp,$(TEST_HC_OPTS)) + +OBJSUFFIX = .o + +# Test that adding a new module that shadows a package module causes +# recompilation. Part of bug #1372. +retc003: + $(RM) A.hi A$(OBJSUFFIX) out + $(RM) -rf Data + mkdir Data + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface -c A.hs + echo 'Middle' + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface -c A.hs + echo 'End' + echo "module Data.Char where" > Data/Char.hs + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface -c Data/Char.hs + # Should now recompile A.hs, because Char is now a home module: + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -fno-code -fwrite-interface -c A.hs diff --git a/testsuite/tests/driver/retc003/all.T b/testsuite/tests/driver/retc003/all.T new file mode 100644 index 0000000000..836ee62676 --- /dev/null +++ b/testsuite/tests/driver/retc003/all.T @@ -0,0 +1,6 @@ +test('retc003', + extra_clean(['Data/Char.hs', 'Data/Char.hi', 'Data/Char.o', + 'A.o', 'A.hi', + 'err']), + run_command, + ['$MAKE -s --no-print-directory retc003']) diff --git a/testsuite/tests/driver/retc003/retc003.stdout b/testsuite/tests/driver/retc003/retc003.stdout new file mode 100644 index 0000000000..36a358e064 --- /dev/null +++ b/testsuite/tests/driver/retc003/retc003.stdout @@ -0,0 +1,3 @@ +Middle +compilation IS NOT required +End |