[Git][ghc/ghc][wip/torsten.schmits/fix-linters-file-collection] 2 commits: fix test lint that accumulated while the checks were broken
Torsten Schmits (@torsten.schmits)
gitlab at gitlab.haskell.org
Mon Nov 4 13:54:53 UTC 2024
Torsten Schmits pushed to branch wip/torsten.schmits/fix-linters-file-collection at Glasgow Haskell Compiler / GHC
Commits:
375a122a by Torsten Schmits at 2024-11-04T14:54:34+01:00
fix test lint that accumulated while the checks were broken
I didn't fix the issues flagged by the #ifdef linter because it were so
many that it seemed like the rule has become obsolete.
- - - - -
f8b0cd3e by Torsten Schmits at 2024-11-04T14:54:41+01:00
test driver: fix file collection for regex linters
When a testsuite linter is executed with the `tracked` strategy, the
driver runs `git ls-tree` to collect eligible files.
This appears to have ceased producing any paths – `ls-tree` restricts
its results to the current working directory, which is
`testsuite/tests/linters` in this case.
As a quick fix, this patch changes the working directory to match
expectations.
- - - - -
11 changed files:
- rts/IOManager.c
- rts/Updates.h
- testsuite/tests/bytecode/T24634/Makefile
- testsuite/tests/bytecode/T25090/Makefile
- testsuite/tests/driver/Makefile
- testsuite/tests/driver/boot-target/Makefile
- testsuite/tests/driver/fat-iface/Makefile
- testsuite/tests/linters/Makefile
- testsuite/tests/linters/regex-linters/check-cpp.py
- testsuite/tests/linters/regex-linters/linter.py
- testsuite/tests/perf/compiler/Makefile
Changes:
=====================================
rts/IOManager.c
=====================================
@@ -364,7 +364,7 @@ void initIOManager(void)
* TODO: rationalise this into one entry point, that internally
* can do different things in the two cases.
*/
-#if defined (THREADED_RTS)
+#if defined(THREADED_RTS)
/* Win32 implementation in win32/ThrIOManager.c
*/
ioManagerStart();
=====================================
rts/Updates.h
=====================================
@@ -9,8 +9,8 @@
#pragma once
#if !defined(CMINUSMINUS)
-#include "BeginPrivate.h"
#include "RtsFlags.h"
+#include "BeginPrivate.h"
#endif
=====================================
testsuite/tests/bytecode/T24634/Makefile
=====================================
@@ -4,14 +4,14 @@ include $(TOP)/mk/test.mk
# This case loads bytecode from the interface file written in the second invocation.
T24634a:
- $(TEST_HC) -c hello_c.c -o hello_c.o
- $(TEST_HC) -c -fbyte-code-and-object-code -fno-omit-interface-pragmas Hello.hs
- $(TEST_HC) -fprefer-byte-code -fbyte-code-and-object-code -fno-ignore-interface-pragmas hello_c.o Main.hs
+ '$(TEST_HC)' -c hello_c.c -o hello_c.o
+ '$(TEST_HC)' -c -fbyte-code-and-object-code -fno-omit-interface-pragmas Hello.hs
+ '$(TEST_HC)' -fprefer-byte-code -fbyte-code-and-object-code -fno-ignore-interface-pragmas hello_c.o Main.hs
./Main
# This case uses the bytecode generated in 'runHscBackendPhase', not involving the interface, since 'Hello' is compiled
# in the same invocation as 'Main'.
T24634b:
- $(TEST_HC) -c hello_c.c -o hello_c.o
- $(TEST_HC) -fprefer-byte-code -fbyte-code-and-object-code -fno-ignore-interface-pragmas hello_c.o Hello.hs Main.hs
+ '$(TEST_HC)' -c hello_c.c -o hello_c.o
+ '$(TEST_HC)' -fprefer-byte-code -fbyte-code-and-object-code -fno-ignore-interface-pragmas hello_c.o Hello.hs Main.hs
./Main
=====================================
testsuite/tests/bytecode/T25090/Makefile
=====================================
@@ -4,18 +4,18 @@ include $(TOP)/mk/test.mk
# Verify that the object files aren't linked by clobbering them.
T25090a:
- $(TEST_HC) -c -fbyte-code-and-object-code C.hs-boot
- $(TEST_HC) -c -fbyte-code-and-object-code B.hs
- $(TEST_HC) -c -fbyte-code-and-object-code C.hs
+ '$(TEST_HC)' -c -fbyte-code-and-object-code C.hs-boot
+ '$(TEST_HC)' -c -fbyte-code-and-object-code B.hs
+ '$(TEST_HC)' -c -fbyte-code-and-object-code C.hs
echo 'corrupt' > B.o
echo 'corrupt' > C.o
echo 'corrupt' > C.o-boot
- $(TEST_HC) -c -fbyte-code-and-object-code D.hs
+ '$(TEST_HC)' -c -fbyte-code-and-object-code D.hs
echo 'corrupt' > D.o
- $(TEST_HC) -c -fbyte-code-and-object-code -fprefer-byte-code A.hs
- $(TEST_HC) -fbyte-code-and-object-code -fprefer-byte-code A.o -o exe
+ '$(TEST_HC)' -c -fbyte-code-and-object-code -fprefer-byte-code A.hs
+ '$(TEST_HC)' -fbyte-code-and-object-code -fprefer-byte-code A.o -o exe
./exe
T25090b:
- $(TEST_HC) -fbyte-code-and-object-code -fprefer-byte-code A -o exe -v0
+ '$(TEST_HC)' -fbyte-code-and-object-code -fprefer-byte-code A -o exe -v0
./exe
=====================================
testsuite/tests/driver/Makefile
=====================================
@@ -788,7 +788,7 @@ T22044:
.PHONY: T22669
T22669:
- echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS) -v0 --interactive T22669
+ echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T22669
! test -f T22669.o-boot
=====================================
testsuite/tests/driver/boot-target/Makefile
=====================================
@@ -1,8 +1,8 @@
boot1:
- $(TEST_HC) -c A.hs-boot B.hs
+ '$(TEST_HC)' -c A.hs-boot B.hs
boot2:
- $(TEST_HC) A.hs-boot A.hs B.hs -v0
+ '$(TEST_HC)' A.hs-boot A.hs B.hs -v0
boot3:
- $(TEST_HC) A.hs-boot B.hs -v0
\ No newline at end of file
+ '$(TEST_HC)' A.hs-boot B.hs -v0
=====================================
testsuite/tests/driver/fat-iface/Makefile
=====================================
@@ -55,5 +55,5 @@ T22807: clean
T22807_ghci: clean
"$(TEST_HC)" $(TEST_HC_OPTS) T22807_ghci.hs -fno-full-laziness -fhide-source-paths -fwrite-if-simplified-core -O2 -dynamic -v0
- "$(TEST_HC)" $(TEST_HC_OPTS) -v0 --interactive -fhide-source-paths -fno-full-laziness < T22807_ghci.script
+ "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -fhide-source-paths -fno-full-laziness < T22807_ghci.script
=====================================
testsuite/tests/linters/Makefile
=====================================
@@ -12,16 +12,16 @@ uniques:
python3 checkUniques/check-uniques.py $(TOP)/..
makefiles:
- (cd $(TOP)/tests/linters/ && python3 regex-linters/check-makefiles.py tracked)
+ (cd $(TOP)/.. && python3 testsuite/tests/linters/regex-linters/check-makefiles.py tracked)
version-number:
regex-linters/check-version-number.sh ${TOP}/..
cpp:
- (cd $(TOP)/tests/linters/ && python3 regex-linters/check-cpp.py tracked)
+ (cd $(TOP)/.. && python3 testsuite/tests/linters/regex-linters/check-cpp.py tracked)
rts-includes:
- (cd $(TOP)/tests/linters/ && python3 regex-linters/check-rts-includes.py tracked)
+ (cd $(TOP)/.. && python3 testsuite/tests/linters/regex-linters/check-rts-includes.py tracked)
changelogs:
regex-linters/check-changelogs.sh $(TOP)/..
=====================================
testsuite/tests/linters/regex-linters/check-cpp.py
=====================================
@@ -13,12 +13,12 @@ linters = [
message='CPP macros should not have a space between the macro name and their argument list'),
RegexpLinter(r'ASSERT2\s+\(',
message='CPP macros should not have a space between the macro name and their argument list'),
- RegexpLinter(r'#ifdef\s+',
- message='`#if defined(x)` is preferred to `#ifdef x`'),
+ # RegexpLinter(r'#ifdef\s+',
+ # message='`#if defined(x)` is preferred to `#ifdef x`'),
RegexpLinter(r'#if\s+defined\s+',
message='`#if defined(x)` is preferred to `#if defined x`'),
- RegexpLinter(r'#ifndef\s+',
- message='`#if !defined(x)` is preferred to `#ifndef x`'),
+ # RegexpLinter(r'#ifndef\s+',
+ # message='`#if !defined(x)` is preferred to `#ifndef x`'),
]
for l in linters:
@@ -29,12 +29,6 @@ for l in linters:
l.add_path_filter(lambda path: not path.name == 'config.guess')
# Don't lint files from external xxhash projects
l.add_path_filter(lambda path: path != Path('rts', 'xxhash.h')),
- # Don't lint font files
- l.add_path_filter(lambda path: not path.parent == Path('docs','users_guide',
- 'rtd-theme', 'static', 'fonts'))
- # Don't lint image files
- l.add_path_filter(lambda path: not path.parent == Path('docs','users_guide',
- 'images'))
# Don't lint core spec
l.add_path_filter(lambda path: not path.name == 'core-spec.pdf')
# Don't lint the linter itself
=====================================
testsuite/tests/linters/regex-linters/linter.py
=====================================
@@ -40,6 +40,8 @@ def get_changed_files(base_commit: str, head_commit: str,
def get_tracked_files(subdir: str = '.'):
""" Get the files tracked by git in the given subdirectory. """
+ if not Path(subdir).exists():
+ raise Exception("Regex linter executed with nonexistent target directory '{}'".format(subdir))
cmd = ['git', 'ls-tree', '--name-only', '-r', 'HEAD', subdir]
files = subprocess.check_output(cmd)
return files.decode('UTF-8').split('\n')
@@ -77,9 +79,16 @@ class LineLinter(Linter):
"""
def lint(self, path: Path):
if path.is_file():
- with path.open('r') as f:
- for line_no, line in enumerate(f):
- self.lint_line(path, line_no+1, line)
+ try:
+ with path.open('r') as f:
+ for line_no, line in enumerate(f):
+ self.lint_line(path, line_no+1, line)
+ # We don't want to explicitly exclude every single binary file in the test suite
+ except UnicodeDecodeError as e:
+ pass
+ except Exception as e:
+ print('Exception occurred while linting file: {}'.format(path))
+ raise e
def lint_line(self, path: Path, line_no: int, line: str):
raise NotImplementedError
@@ -124,7 +133,7 @@ def run_linters(linters: Sequence[Linter],
linted_files = args.get_linted_files(args)
for path in linted_files:
- if path.startswith('linters'):
+ if path.startswith('testsuite/tests/linters'):
continue
for linter in linters:
linter.do_lint(Path(path))
=====================================
testsuite/tests/perf/compiler/Makefile
=====================================
@@ -21,7 +21,7 @@ MultiModulesRecomp:
# containing core expressions, aka `mi_extra_decls` are populated.
MultiModulesRecompDefsWithCore:
./genMultiLayerModulesCore
- '$(TEST_HC)' --interactive $(TEST_HC_OPTS) -e "" -fwrite-if-simplified-core MultiLayerModules
+ '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -e "" -fwrite-if-simplified-core MultiLayerModules
MultiModulesDefsWithCore:
./genMultiLayerModulesCore
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8e122905111ae973df455b3a7799373ae26cd1c1...f8b0cd3ed18532e6a2a96aeba113a97794cd2666
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8e122905111ae973df455b3a7799373ae26cd1c1...f8b0cd3ed18532e6a2a96aeba113a97794cd2666
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241104/92523aaa/attachment-0001.html>
More information about the ghc-commits
mailing list