summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Garrood harry@garrood.me <harry@garrood.me>2021-03-04 21:37:19 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-05 04:49:18 -0500
commitb5155a6c74e774d99a67f2b5c8c06b70ad5e5b2e (patch)
tree4872ea83165bd9de6a4d988fc20778f0f3469b7a
parent4cd98bd2c91cac4a10831ab7111c7be8153bdd33 (diff)
downloadhaskell-b5155a6c74e774d99a67f2b5c8c06b70ad5e5b2e.tar.gz
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.
-rw-r--r--testsuite/tests/driver/recomp019/B1.hs4
-rw-r--r--testsuite/tests/driver/recomp019/B2.hs4
-rw-r--r--testsuite/tests/driver/recomp019/C.hs4
-rw-r--r--testsuite/tests/driver/recomp019/Main.hs6
-rw-r--r--testsuite/tests/driver/recomp019/Makefile26
-rw-r--r--testsuite/tests/driver/recomp019/all.T6
-rw-r--r--testsuite/tests/driver/recomp019/recomp019.stdout11
7 files changed, 61 insertions, 0 deletions
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