Commit d40682ec authored by thomie's avatar thomie
Browse files

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
parent d0dd572b
......@@ -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',
......
#!/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)$)"],
......
Subproject commit 88b389f368d1222078ee9592236b107d061cd5f2
Subproject commit d8b5381bd5d03a3a75f4a1b91f1ede6fe0fd0ce9
......@@ -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:
......
......@@ -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
......@@ -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
......@@ -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:
......
......@@ -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'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment