Sven Tennie pushed to branch wip/supersven/flags-pin-test at Glasgow Haskell Compiler / GHC
Commits:
ba973f65 by Sven Tennie at 2026-06-07T16:21:49+00:00
testsuite: simplify config-pins scripts
- Extract platform_key() to ConfigPinsExpected.py; import in both scripts
- Build actual dict directly in GhcInfoPins.py (drop list→dict roundtrip)
- Add comment to all.T explaining why tests are Python not Haskell
Co-Authored-By: Claude Sonnet 4.6
- - - - -
4 changed files:
- testsuite/tests/driver/config-pins/ConfigPinsExpected.py
- testsuite/tests/driver/config-pins/GhcInfoPins.py
- testsuite/tests/driver/config-pins/TestsuiteConfigPins.py
- testsuite/tests/driver/config-pins/all.T
Changes:
=====================================
testsuite/tests/driver/config-pins/ConfigPinsExpected.py
=====================================
@@ -9,6 +9,14 @@
#
# When a new platform is encountered the test prints a ready-to-paste entry.
+
+def platform_key(platform, is_cross, is_unreg, no_tntc):
+ key = platform
+ if is_cross: key += "-cross"
+ if is_unreg: key += "-unreg"
+ elif no_tntc: key += "-no_tntc"
+ return key
+
PINNED_GHC_INFO_FIELDS = [
"target arch",
"target os",
=====================================
testsuite/tests/driver/config-pins/GhcInfoPins.py
=====================================
@@ -5,19 +5,16 @@ import subprocess
import sys
sys.path.insert(0, '.')
-from ConfigPinsExpected import GHC_INFO_EXPECTED, PINNED_GHC_INFO_FIELDS
+from ConfigPinsExpected import GHC_INFO_EXPECTED, PINNED_GHC_INFO_FIELDS, platform_key
-def platform_key(info_map):
- platform = info_map.get("target platform string", "<unknown>")
- is_cross = info_map.get("cross compiling", "NO") == "YES"
- is_unreg = info_map.get("Unregisterised", "NO") == "YES"
- no_tntc = info_map.get("Tables next to code", "YES") == "NO"
- key = platform
- if is_cross: key += "-cross"
- if is_unreg: key += "-unreg"
- elif no_tntc: key += "-no_tntc"
- return key
+def info_platform_key(info_map):
+ return platform_key(
+ info_map.get("target platform string", "<unknown>"),
+ info_map.get("cross compiling", "NO") == "YES",
+ info_map.get("Unregisterised", "NO") == "YES",
+ info_map.get("Tables next to code", "YES") == "NO",
+ )
def main():
@@ -39,26 +36,25 @@ def main():
except (ValueError, SyntaxError) as e:
print(f"Failed to parse {compiler!r} --info output: {e}")
sys.exit(1)
- key = platform_key(info_map)
+ key = info_platform_key(info_map)
- actual = [(f, info_map.get(f, "<missing>")) for f in PINNED_GHC_INFO_FIELDS]
+ actual = {f: info_map.get(f, "<missing>") for f in PINNED_GHC_INFO_FIELDS}
if key not in GHC_INFO_EXPECTED:
print(f"Platform key {key!r} not in ConfigPinsExpected.")
print("Add this entry to GHC_INFO_EXPECTED in ConfigPinsExpected.py:")
print()
print(f" {key!r}: {{")
- for f, v in actual:
+ for f, v in actual.items():
print(f" {f!r}: {v!r},")
print(" },")
sys.exit(1)
expected = GHC_INFO_EXPECTED[key]
- actual_map = dict(actual)
mismatches = [
- (f, ev, actual_map.get(f, "<missing>"))
+ (f, ev, actual.get(f, "<missing>"))
for f, ev in sorted(expected.items())
- if ev != actual_map.get(f, "<missing>")
+ if ev != actual.get(f, "<missing>")
]
if mismatches:
=====================================
testsuite/tests/driver/config-pins/TestsuiteConfigPins.py
=====================================
@@ -3,15 +3,7 @@
import sys
sys.path.insert(0, '.')
-from ConfigPinsExpected import TESTSUITE_CONFIG_EXPECTED
-
-
-def platform_key(platform, is_cross, is_unreg, no_tntc):
- key = platform
- if is_cross: key += "-cross"
- if is_unreg: key += "-unreg"
- elif no_tntc: key += "-no_tntc"
- return key
+from ConfigPinsExpected import TESTSUITE_CONFIG_EXPECTED, platform_key
def main():
=====================================
testsuite/tests/driver/config-pins/all.T
=====================================
@@ -1,5 +1,9 @@
import sys
+# Python run_command rather than compiled Haskell: wasm32/WASI targets cannot
+# call runInteractiveProcess from compiled binaries (no process creation in
+# WASI). Python scripts run on the host regardless of the target under test.
+
test('GhcInfoPins',
[extra_files(['ConfigPinsExpected.py', 'GhcInfoPins.py']),
ignore_stdout],
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba973f65f52302c0cc76db713f3020c3...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba973f65f52302c0cc76db713f3020c3...
You're receiving this email because of your account on gitlab.haskell.org.