diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2016-05-25 13:24:34 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2016-05-27 22:49:29 +0200 |
commit | d40682ec74d802376d7cf50f2d3612b3292b29c5 (patch) | |
tree | cfde4072ce14677621aa99d75a59228aea5922b1 | |
parent | d0dd572b707631a104e060711faf9bd169bdc968 (diff) | |
download | haskell-d40682ec74d802376d7cf50f2d3612b3292b29c5.tar.gz |
Testsuite: don't use --interactive in Makefiles
Add a linter to encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)`
instead of `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's
too easy to forget one of those flags when adding a new test.
Update submodule hpc.
Reviewed by: austin
Differential Revision: https://phabricator.haskell.org/D2265
GHC Trac Issues: #11468
-rwxr-xr-x | .arc-linters/check-cpp.py | 3 | ||||
-rw-r--r-- | .arc-linters/check-makefiles.py | 27 | ||||
-rw-r--r-- | .arclint | 5 | ||||
m--------- | libraries/hpc | 0 | ||||
-rw-r--r-- | testsuite/tests/driver/Makefile | 26 | ||||
-rw-r--r-- | testsuite/tests/driver/mode001.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/linking/Makefile | 16 | ||||
-rw-r--r-- | testsuite/tests/ghci/linking/dyn/Makefile | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/Makefile | 2 |
9 files changed, 60 insertions, 25 deletions
diff --git a/.arc-linters/check-cpp.py b/.arc-linters/check-cpp.py index 1d07b4ed37..2f32f9be6a 100755 --- a/.arc-linters/check-cpp.py +++ b/.arc-linters/check-cpp.py @@ -7,7 +7,6 @@ import sys import logging import os import json -import re def setup_logging(logger): """ @@ -28,7 +27,7 @@ warnings = [] if os.path.isfile(path): with open(path) as f: for lineno, line in enumerate(f): - if re.search('ASSERT \(', line) is not None: + if 'ASSERT (' in line: warning = { 'severity': 'warning', 'message': 'CPP macros should not have a space between the macro name and their argument list', diff --git a/.arc-linters/check-makefiles.py b/.arc-linters/check-makefiles.py new file mode 100644 index 0000000000..7080954477 --- /dev/null +++ b/.arc-linters/check-makefiles.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +# Warn for use of `--interactive` inside Makefiles (#11468). +# +# Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of +# `$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to +# forget one of those flags when adding a new test. + +import sys +import os +import json +import re + +path = sys.argv[1] +warnings = [] +if os.path.isfile(path): + with open(path) as f: + for lineno, line in enumerate(f): + if '--interactive' in line: + warning = { + 'severity': 'warning', + 'message': 'Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`', + 'line': lineno+1, + } + warnings.append(warning) + +print(json.dumps(warnings)) @@ -57,6 +57,11 @@ "type": "external-json", "external-json.script": "python .arc-linters/check-binaries.py" }, + "check-makefiles": { + "type": "external-json", + "include": ["(Makefile$)"], + "external-json.script": "python .arc-linters/check-makefiles.py" + }, "bad-assert-clang-cpp": { "type": "external-json", "include": ["(\\.(l?hs|x|y\\.pp)(\\.in)?$)", "(\\.(c|h)$)"], diff --git a/libraries/hpc b/libraries/hpc -Subproject 88b389f368d1222078ee9592236b107d061cd5f +Subproject d8b5381bd5d03a3a75f4a1b91f1ede6fe0fd0ce diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile index 8c986817b0..51fb71a39b 100644 --- a/testsuite/tests/driver/Makefile +++ b/testsuite/tests/driver/Makefile @@ -432,16 +432,20 @@ T2566:: # ghc: <stdout>: hFlush: resource vanished (Broken pipe) # on OS X mode001: - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --make --help | sed '2,$$d' - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --help --make | sed '2,$$d' - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --interactive --help -ignore-dot-ghci | sed '2,$$d' - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --help --interactive -ignore-dot-ghci | sed '2,$$d' - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --version --help | sed "s/, version.*//" - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --help --version | sed '2,$$d' - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --interactive --version -ignore-dot-ghci | sed "s/, version.*//" - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --version --interactive -ignore-dot-ghci | sed "s/, version.*//" - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --interactive --show-options -ignore-dot-ghci | grep -- --interactive | sed '2,$$d' - "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --show-options --interactive -ignore-dot-ghci | grep -- --interactive | sed '2,$$d' + "$(TEST_HC)" $(TEST_HC_OPTS) --make --help | sed '2,$$d' + "$(TEST_HC)" $(TEST_HC_OPTS) --help --make | sed '2,$$d' + + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) --help | sed '2,$$d' + "$(TEST_HC)" --help $(TEST_HC_OPTS_INTERACTIVE) | sed '2,$$d' + + "$(TEST_HC)" $(TEST_HC_OPTS) --version --help | sed "s/, version.*//" + "$(TEST_HC)" $(TEST_HC_OPTS) --help --version | sed '2,$$d' + + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) --version | sed "s/, version.*//" + "$(TEST_HC)" --version $(TEST_HC_OPTS_INTERACTIVE) | sed "s/, version.*//" + + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) --show-options | grep -- --show-options | sed '2,$$d' + "$(TEST_HC)" --show-options $(TEST_HC_OPTS_INTERACTIVE) | grep -- --show-options | sed '2,$$d' # Test for building DLLs with ghc -shared, see #2745 shared001: @@ -503,7 +507,7 @@ T706: "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) $(ghciWayFlags) -c T706.hs cp T706b.hs T706.hs "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) $(ghciWayFlags) -c T706.hs - echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_NO_RECOMP) --interactive -ignore-dot-ghci -v0 T706 + echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T706 .PHONY: T5584 T5584: diff --git a/testsuite/tests/driver/mode001.stdout b/testsuite/tests/driver/mode001.stdout index e94602d96e..3fa84ad13b 100644 --- a/testsuite/tests/driver/mode001.stdout +++ b/testsuite/tests/driver/mode001.stdout @@ -6,5 +6,5 @@ The Glorious Glasgow Haskell Compilation System Usage: The Glorious Glasgow Haskell Compilation System The Glorious Glasgow Haskell Compilation System ---interactive ---interactive +--show-options +--show-options diff --git a/testsuite/tests/ghci/linking/Makefile b/testsuite/tests/ghci/linking/Makefile index 12676500e4..0bbd848b9d 100644 --- a/testsuite/tests/ghci/linking/Makefile +++ b/testsuite/tests/ghci/linking/Makefile @@ -13,7 +13,7 @@ ghcilink001 : mkdir dir001 "$(TEST_HC)" -c f.c -o dir001/foo.o "$(AR)" cqs dir001/libfoo.a dir001/foo.o - echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -Ldir001 -lfoo TestLink.hs + echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -Ldir001 -lfoo TestLink.hs # Test 2: ghci -Ldir -lfoo # with dir/libfoo.so @@ -32,7 +32,7 @@ ghcilink002 : mkdir dir002 "$(TEST_HC)" -c -dynamic f.c -o dir002/foo.o "$(TEST_HC)" -no-auto-link-packages -shared -v0 -o dir002/$(call DLL,foo) dir002/foo.o - echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -Ldir002 -lfoo TestLink.hs + echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -Ldir002 -lfoo TestLink.hs # Test 3: ghci -lstdc++ # where libstdc++.so is normally found in a directory private to gcc, @@ -41,9 +41,9 @@ ghcilink002 : .PHONY: ghcilink003 ghcilink003 : ifeq "$(WINDOWS)" "YES" - echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++-6 + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -lstdc++-6 else - echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++ + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -lstdc++ endif # Test 4: @@ -72,7 +72,7 @@ ghcilink004 : # "$(TEST_HC)" -c f.c -o dir004/foo.o "$(AR)" cqs dir004/libfoo.a dir004/foo.o - echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs + echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs # Test 5: # package P @@ -100,7 +100,7 @@ ghcilink005 : # "$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o "$(TEST_HC)" -no-auto-link-packages -shared -o dir005/$(call DLL,foo) dir005/foo.o - echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF005) -package test TestLink.hs + echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF005) -package test TestLink.hs # Test 6: # package P @@ -126,9 +126,9 @@ endif '$(GHC_PKG)' init $(LOCAL_PKGCONF006) '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF006) register $(PKG006) -v0 # - echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF006) -package test + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF006) -package test .PHONY: T3333 T3333: "$(TEST_HC)" -c T3333.c -o T3333.o - echo "weak_test 10" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 T3333.hs T3333.o + echo "weak_test 10" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T3333.hs T3333.o diff --git a/testsuite/tests/ghci/linking/dyn/Makefile b/testsuite/tests/ghci/linking/dyn/Makefile index 6319f4bc7e..fd954bfa55 100644 --- a/testsuite/tests/ghci/linking/dyn/Makefile +++ b/testsuite/tests/ghci/linking/dyn/Makefile @@ -42,7 +42,7 @@ load_short_name: mkdir bin_short '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_short" -shared A.c -o "bin_short/$(call DLL,A)" rm -f bin_short/*.a - echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -L"./bin_short" -lA -v0 + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -L"./bin_short" -lA .PHONY: compile_libT1407 compile_libT1407: diff --git a/testsuite/tests/ghci/scripts/Makefile b/testsuite/tests/ghci/scripts/Makefile index 545c4e9e96..5f848656c5 100644 --- a/testsuite/tests/ghci/scripts/Makefile +++ b/testsuite/tests/ghci/scripts/Makefile @@ -59,5 +59,5 @@ T10408: T11389: # Test that "Loaded GHCi configuration" message is printed by default # (without -v0) - '$(TEST_HC)' $(TEST_HC_OPTS) --interactive -ignore-dot-ghci \ + '$(TEST_HC)' $(filter-out -v0,$(TEST_HC_OPTS_INTERACTIVE)) \ -ghci-script T11389.script < /dev/null | grep 'configuration' |