From b5155a6c74e774d99a67f2b5c8c06b70ad5e5b2e Mon Sep 17 00:00:00 2001 From: "Harry Garrood harry@garrood.me" Date: Thu, 4 Mar 2021 21:37:19 +0000 Subject: Add new driver test for use of outdated .o files This is something that's quite important for the correctness of the incremental build system and doesn't appear to be tested currently; this test fails on my hashing branch, whereas all of the other (non-perf) tests pass. --- testsuite/tests/driver/recomp019/B1.hs | 4 ++++ testsuite/tests/driver/recomp019/B2.hs | 4 ++++ testsuite/tests/driver/recomp019/C.hs | 4 ++++ testsuite/tests/driver/recomp019/Main.hs | 6 ++++++ testsuite/tests/driver/recomp019/Makefile | 26 +++++++++++++++++++++++ testsuite/tests/driver/recomp019/all.T | 6 ++++++ testsuite/tests/driver/recomp019/recomp019.stdout | 11 ++++++++++ 7 files changed, 61 insertions(+) create mode 100644 testsuite/tests/driver/recomp019/B1.hs create mode 100644 testsuite/tests/driver/recomp019/B2.hs create mode 100644 testsuite/tests/driver/recomp019/C.hs create mode 100644 testsuite/tests/driver/recomp019/Main.hs create mode 100644 testsuite/tests/driver/recomp019/Makefile create mode 100644 testsuite/tests/driver/recomp019/all.T create mode 100644 testsuite/tests/driver/recomp019/recomp019.stdout diff --git a/testsuite/tests/driver/recomp019/B1.hs b/testsuite/tests/driver/recomp019/B1.hs new file mode 100644 index 0000000000..9943eab231 --- /dev/null +++ b/testsuite/tests/driver/recomp019/B1.hs @@ -0,0 +1,4 @@ +module B where + +x :: Int +x = 2 diff --git a/testsuite/tests/driver/recomp019/B2.hs b/testsuite/tests/driver/recomp019/B2.hs new file mode 100644 index 0000000000..bed169b09c --- /dev/null +++ b/testsuite/tests/driver/recomp019/B2.hs @@ -0,0 +1,4 @@ +module B where + +x :: Int +x = 12 diff --git a/testsuite/tests/driver/recomp019/C.hs b/testsuite/tests/driver/recomp019/C.hs new file mode 100644 index 0000000000..365ddd9655 --- /dev/null +++ b/testsuite/tests/driver/recomp019/C.hs @@ -0,0 +1,4 @@ +module C where + +x :: Int +x = 3 diff --git a/testsuite/tests/driver/recomp019/Main.hs b/testsuite/tests/driver/recomp019/Main.hs new file mode 100644 index 0000000000..084ba0a49a --- /dev/null +++ b/testsuite/tests/driver/recomp019/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import qualified B +import qualified C + +main = putStrLn $ show $ B.x + C.x diff --git a/testsuite/tests/driver/recomp019/Makefile b/testsuite/tests/driver/recomp019/Makefile new file mode 100644 index 0000000000..8e66f82abb --- /dev/null +++ b/testsuite/tests/driver/recomp019/Makefile @@ -0,0 +1,26 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# Recompilation test for when .hi files are up to date but .o files are +# not + +clean: + rm -f Main *.o *.hi B.hs + +recomp019: clean + cp B1.hs B.hs + echo 'first run' + '$(TEST_HC)' $(TEST_HC_OPTS) --make Main + ./Main + + # Update B.hs + cp B2.hs B.hs + + # Update B.hi (but not B.o) + '$(TEST_HC)' $(TEST_HC_OPTS) --make B -fno-code -fwrite-interface + + # Recompile + echo 'second run' + '$(TEST_HC)' $(TEST_HC_OPTS) --make Main + ./Main diff --git a/testsuite/tests/driver/recomp019/all.T b/testsuite/tests/driver/recomp019/all.T new file mode 100644 index 0000000000..9b2481eab1 --- /dev/null +++ b/testsuite/tests/driver/recomp019/all.T @@ -0,0 +1,6 @@ +# Recompilation test for when .hi files are up to date but .o files are +# not + +test('recomp019', + [extra_files(['Main.hs', 'B1.hs', 'B2.hs', 'C.hs'])], + makefile_test, []) diff --git a/testsuite/tests/driver/recomp019/recomp019.stdout b/testsuite/tests/driver/recomp019/recomp019.stdout new file mode 100644 index 0000000000..f1e4cd4d73 --- /dev/null +++ b/testsuite/tests/driver/recomp019/recomp019.stdout @@ -0,0 +1,11 @@ +first run +[1 of 3] Compiling B ( B.hs, B.o ) +[2 of 3] Compiling C ( C.hs, C.o ) +[3 of 3] Compiling Main ( Main.hs, Main.o ) +Linking Main ... +5 +[1 of 1] Compiling B ( B.hs, nothing ) +second run +[2 of 3] Compiling B ( B.hs, B.o ) +Linking Main ... +15 -- cgit v1.2.1