[Git][ghc/ghc][wip/marge_bot_batch_merge_job] Remove `extra_src_files` variable from `testsuite/driver/testlib.py`
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a1678ea6 by Michael Alan Dorman at 2026-02-09T03:30:30-05:00 Remove `extra_src_files` variable from `testsuite/driver/testlib.py` While reading through the test harness code, I noticed this variable with a TODO attached that referenced #12223. Although that bug is closed, it strongly implied that this special-case variable that only affected a single test was expected to be removed at some point. I also looked at 3415bcaa0b1903b5e12dfaadb5b774718e406eab---where it was added---whose commit message suggested that it would have been desirable to remove it, but that there were special circumstances that meant it had to remain (though it doesn't elucidate what those special circumstances are). However, the special circumstances were mentioned as if the test was in a different location than is currently is, so I decided to try changing the test to use the standard `extra_files` mechanism, which works in local testing. This also seems like a reasonable time to remove the script that was originally used in the transition, since it doesn't really serve a purpose anymore. - - - - - 3 changed files: - − testsuite/driver/kill_extra_files.py - testsuite/driver/testlib.py - testsuite/tests/process/all.T Changes: ===================================== testsuite/driver/kill_extra_files.py deleted ===================================== @@ -1,101 +0,0 @@ -#!/usr/bin/env python3 -from typing import Dict, List, Set, NamedTuple - -import os -import subprocess -import ast - -import extra_files -extra_src_files = extra_files.extra_src_files # type: Dict[str, List[str]] - -found_tests = set() # type: Set[str] -fixed_tests = set() # type: Set[str] - -def extras(name: str) -> str: - return 'extra_files(%s)' % (extra_src_files[name],) - -def list_extras(name: str, col: int) -> str: - return extras(name) + ',\n' + ' ' * (col + 1) - -def find_all_T_files(basedir: bytes) -> List[bytes]: - result = [] # type: List[bytes] - for dirpath, dirnames, filenames in os.walk(basedir): - for f in filenames: - if f.endswith(b'.T'): - result.append(os.path.join(dirpath, f)) - return result - -# Delete del bytes from (line, col) and then insert the string ins there. -Fixup = NamedTuple('Fixup', [('line', int), - ('col', int), - ('delete', int), - ('insert', str)]) - -class TestVisitor(ast.NodeVisitor): - def __init__(self) -> None: - self.fixups = [] # type: List[Fixup] - - def visit_Call(self, node: ast.AST) -> None: - self.generic_visit(node) - assert isinstance(node, ast.Call) - - if isinstance(node.func, ast.Name) and node.func.id == 'test': - assert(len(node.args) == 4) - name_expr, setup, test_fn, args = node.args - if not(isinstance(name_expr, ast.Str)): - return - name = name_expr.s - if name in extra_src_files: - found_tests.add(name) - if isinstance(setup, ast.Name): - if setup.id == 'normal': - # Kill it - self.fixups.append(Fixup( - line=setup.lineno, col=setup.col_offset, - delete=len(setup.id), insert=extras(name))) - else: - # Make a lit - self.fixups.append(Fixup( - line=setup.lineno, col=setup.col_offset, - delete=0, - insert='[' + list_extras(name, setup.col_offset))) - self.fixups.append(Fixup( - line=setup.lineno, - col=setup.col_offset + len(setup.id), - delete=0, insert=']')) - fixed_tests.add(name) - elif isinstance(setup, ast.List): - # Insert into list at start - if not setup.elts: - ins = extras(name) # no need for comma, newline - # Don't try to delete the list because someone - # might have written "[ ]" for some reason - else: - ins = list_extras(name, setup.col_offset) - self.fixups.append(Fixup( - line=setup.lineno, col=setup.col_offset + 1, - delete=0, insert=ins)) - fixed_tests.add(name) - else: - assert False # we fixed them all manually already - -basedir = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']) -basedir = basedir[0:-1] # delete trailing newline -print(basedir) -for f in find_all_T_files(basedir): - print(f) - text = open(f).read() - mod = ast.parse(text) - tv = TestVisitor() - tv.visit(mod) - - lines = text.split('\n') - if not tv.fixups: - # Don't rewrite files unnecessarily - # (libraries/Win32 has Windows line endings) - continue - for fixup in reversed(tv.fixups): - l = list(lines[fixup.line-1]) - l[fixup.col:fixup.col + fixup.delete] = fixup.insert - lines[fixup.line-1] = ''.join(l) - open(f, 'w').write('\n'.join(lines)) ===================================== testsuite/driver/testlib.py ===================================== @@ -31,7 +31,6 @@ import testutil from cpu_features import have_cpu_feature import perf_notes as Perf from perf_notes import MetricChange, PerfStat, StatsException, AlwaysAccept, RelativeMetricAcceptanceWindow -extra_src_files = {'T4198': ['exitminus1.c']} # TODO: See #12223 from my_typing import * @@ -1644,7 +1643,7 @@ async def test_common_work(name: TestName, opts, if f.startswith(name) and not f == name and not f.endswith(testdir_suffix) and not os.path.splitext(f)[1] in do_not_copy) - for filename in (opts.extra_files + extra_src_files.get(name, [])): + for filename in (opts.extra_files): if filename.startswith('/'): framework_fail(name, None, 'no absolute paths in extra_files please: ' + filename) ===================================== testsuite/tests/process/all.T ===================================== @@ -27,6 +27,7 @@ test('T3231', ['']) test('T4198', [pre_cmd('{compiler} exitminus1.c -no-hs-main -o exitminus1'), + extra_files(['exitminus1.c']), js_broken(22349), req_process], compile_and_run, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a1678ea6aa3722b4de008e4ed24150cd... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a1678ea6aa3722b4de008e4ed24150cd... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)