From 8fc654c3a00ab0cd842c3e8316f832170ea561d6 Mon Sep 17 00:00:00 2001 From: David Eichmann Date: Tue, 9 Apr 2019 13:17:34 +0100 Subject: Include CPP preprocessor dependencies in -M output Issue #16521 --- testsuite/tests/driver/T16521/A.hs | 14 ++++++++++++++ testsuite/tests/driver/T16521/Makefile | 9 +++++++++ testsuite/tests/driver/T16521/a.h | 1 + testsuite/tests/driver/T16521/all.T | 7 +++++++ testsuite/tests/driver/T16521/b.h | 2 ++ testsuite/tests/driver/T16521/b2.h | 1 + testsuite/tests/driver/T16521/check.sh | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 testsuite/tests/driver/T16521/A.hs create mode 100644 testsuite/tests/driver/T16521/Makefile create mode 100644 testsuite/tests/driver/T16521/a.h create mode 100644 testsuite/tests/driver/T16521/all.T create mode 100644 testsuite/tests/driver/T16521/b.h create mode 100644 testsuite/tests/driver/T16521/b2.h create mode 100755 testsuite/tests/driver/T16521/check.sh (limited to 'testsuite/tests') diff --git a/testsuite/tests/driver/T16521/A.hs b/testsuite/tests/driver/T16521/A.hs new file mode 100644 index 0000000000..ddcfdbcf41 --- /dev/null +++ b/testsuite/tests/driver/T16521/A.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE CPP #-} + +module A where + +#include "a.h" +#include "b.h" + +-- Test including a header from an external package. +#include "processFlags.h" + +main :: IO () +main = do + putStrLn a + putStrLn b \ No newline at end of file diff --git a/testsuite/tests/driver/T16521/Makefile b/testsuite/tests/driver/T16521/Makefile new file mode 100644 index 0000000000..4b3fb94742 --- /dev/null +++ b/testsuite/tests/driver/T16521/Makefile @@ -0,0 +1,9 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T16521 : + rm -f Makefile.out + '$(TEST_HC)' $(TEST_HC_OPTS) -package process -M -include-cpp-deps -dep-suffix "" -dep-makefile Makefile1.out A.hs 2>&1 > /dev/null + '$(TEST_HC)' $(TEST_HC_OPTS) -package process -M -include-cpp-deps -dep-suffix "" -dep-suffix "_" -dep-makefile Makefile2.out A.hs 2>&1 > /dev/null + ./check.sh \ No newline at end of file diff --git a/testsuite/tests/driver/T16521/a.h b/testsuite/tests/driver/T16521/a.h new file mode 100644 index 0000000000..1fc4634db4 --- /dev/null +++ b/testsuite/tests/driver/T16521/a.h @@ -0,0 +1 @@ +a = "a" \ No newline at end of file diff --git a/testsuite/tests/driver/T16521/all.T b/testsuite/tests/driver/T16521/all.T new file mode 100644 index 0000000000..e00a23262f --- /dev/null +++ b/testsuite/tests/driver/T16521/all.T @@ -0,0 +1,7 @@ +test('T16521', extra_files( \ + [ 'A.hs' \ + , 'a.h' \ + , 'b.h' \ + , 'b2.h' \ + , 'check.sh' + ]), makefile_test, []) diff --git a/testsuite/tests/driver/T16521/b.h b/testsuite/tests/driver/T16521/b.h new file mode 100644 index 0000000000..a6d6eaf067 --- /dev/null +++ b/testsuite/tests/driver/T16521/b.h @@ -0,0 +1,2 @@ +#include "b2.h" +b = "b" ++ b2 \ No newline at end of file diff --git a/testsuite/tests/driver/T16521/b2.h b/testsuite/tests/driver/T16521/b2.h new file mode 100644 index 0000000000..cbbc1af9e7 --- /dev/null +++ b/testsuite/tests/driver/T16521/b2.h @@ -0,0 +1 @@ +b2 = "bb" \ No newline at end of file diff --git a/testsuite/tests/driver/T16521/check.sh b/testsuite/tests/driver/T16521/check.sh new file mode 100755 index 0000000000..1fbecd6231 --- /dev/null +++ b/testsuite/tests/driver/T16521/check.sh @@ -0,0 +1,33 @@ +#! /bin/sh + +checkDups() { + # Check for duplicate lines + if [ $(uniq $1 -d | wc -l) -ne 0 ] + then + echo "Duplicate dependencies:" + uniq $1 -d + fi +} + +expectDep() { + if ! grep -q $1 "$2" $3 + then + echo "Missing: \"$2\"" + fi +} + +checkDups Makefile1.out +expectDep -F "A.o : A.hs" Makefile1.out +expectDep -F "A.o : a.h" Makefile1.out +expectDep -F "A.o : b.h" Makefile1.out +expectDep -F "A.o : b2.h" Makefile1.out +expectDep "" "A\.o : .*/ghcversion.h" Makefile1.out +expectDep "" "A\.o : .*/processFlags.h" Makefile1.out + +checkDups Makefile2.out +expectDep -F "A._o A.o : A.hs" Makefile2.out +expectDep -F "A._o A.o : a.h" Makefile2.out +expectDep -F "A._o A.o : b.h" Makefile2.out +expectDep -F "A._o A.o : b2.h" Makefile2.out +expectDep "" "A\._o A\.o : .*/ghcversion.h" Makefile2.out +expectDep "" "A\._o A\.o : .*/processFlags.h" Makefile2.out \ No newline at end of file -- cgit v1.2.1