Sven Tennie pushed to branch wip/supersven/flags-pin-test at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • testsuite/tests/driver/config-pins/ConfigPinsExpected.py
    ... ... @@ -9,6 +9,14 @@
    9 9
     #
    
    10 10
     # When a new platform is encountered the test prints a ready-to-paste entry.
    
    11 11
     
    
    12
    +
    
    13
    +def platform_key(platform, is_cross, is_unreg, no_tntc):
    
    14
    +    key = platform
    
    15
    +    if is_cross:  key += "-cross"
    
    16
    +    if is_unreg:  key += "-unreg"
    
    17
    +    elif no_tntc: key += "-no_tntc"
    
    18
    +    return key
    
    19
    +
    
    12 20
     PINNED_GHC_INFO_FIELDS = [
    
    13 21
         "target arch",
    
    14 22
         "target os",
    

  • testsuite/tests/driver/config-pins/GhcInfoPins.py
    ... ... @@ -5,19 +5,16 @@ import subprocess
    5 5
     import sys
    
    6 6
     
    
    7 7
     sys.path.insert(0, '.')
    
    8
    -from ConfigPinsExpected import GHC_INFO_EXPECTED, PINNED_GHC_INFO_FIELDS
    
    8
    +from ConfigPinsExpected import GHC_INFO_EXPECTED, PINNED_GHC_INFO_FIELDS, platform_key
    
    9 9
     
    
    10 10
     
    
    11
    -def platform_key(info_map):
    
    12
    -    platform = info_map.get("target platform string", "<unknown>")
    
    13
    -    is_cross = info_map.get("cross compiling", "NO") == "YES"
    
    14
    -    is_unreg = info_map.get("Unregisterised", "NO") == "YES"
    
    15
    -    no_tntc  = info_map.get("Tables next to code", "YES") == "NO"
    
    16
    -    key = platform
    
    17
    -    if is_cross: key += "-cross"
    
    18
    -    if is_unreg: key += "-unreg"
    
    19
    -    elif no_tntc: key += "-no_tntc"
    
    20
    -    return key
    
    11
    +def info_platform_key(info_map):
    
    12
    +    return platform_key(
    
    13
    +        info_map.get("target platform string", "<unknown>"),
    
    14
    +        info_map.get("cross compiling", "NO") == "YES",
    
    15
    +        info_map.get("Unregisterised", "NO") == "YES",
    
    16
    +        info_map.get("Tables next to code", "YES") == "NO",
    
    17
    +    )
    
    21 18
     
    
    22 19
     
    
    23 20
     def main():
    
    ... ... @@ -39,26 +36,25 @@ def main():
    39 36
         except (ValueError, SyntaxError) as e:
    
    40 37
             print(f"Failed to parse {compiler!r} --info output: {e}")
    
    41 38
             sys.exit(1)
    
    42
    -    key = platform_key(info_map)
    
    39
    +    key = info_platform_key(info_map)
    
    43 40
     
    
    44
    -    actual = [(f, info_map.get(f, "<missing>")) for f in PINNED_GHC_INFO_FIELDS]
    
    41
    +    actual = {f: info_map.get(f, "<missing>") for f in PINNED_GHC_INFO_FIELDS}
    
    45 42
     
    
    46 43
         if key not in GHC_INFO_EXPECTED:
    
    47 44
             print(f"Platform key {key!r} not in ConfigPinsExpected.")
    
    48 45
             print("Add this entry to GHC_INFO_EXPECTED in ConfigPinsExpected.py:")
    
    49 46
             print()
    
    50 47
             print(f"    {key!r}: {{")
    
    51
    -        for f, v in actual:
    
    48
    +        for f, v in actual.items():
    
    52 49
                 print(f"        {f!r}: {v!r},")
    
    53 50
             print("    },")
    
    54 51
             sys.exit(1)
    
    55 52
     
    
    56 53
         expected = GHC_INFO_EXPECTED[key]
    
    57
    -    actual_map = dict(actual)
    
    58 54
         mismatches = [
    
    59
    -        (f, ev, actual_map.get(f, "<missing>"))
    
    55
    +        (f, ev, actual.get(f, "<missing>"))
    
    60 56
             for f, ev in sorted(expected.items())
    
    61
    -        if ev != actual_map.get(f, "<missing>")
    
    57
    +        if ev != actual.get(f, "<missing>")
    
    62 58
         ]
    
    63 59
     
    
    64 60
         if mismatches:
    

  • testsuite/tests/driver/config-pins/TestsuiteConfigPins.py
    ... ... @@ -3,15 +3,7 @@
    3 3
     import sys
    
    4 4
     
    
    5 5
     sys.path.insert(0, '.')
    
    6
    -from ConfigPinsExpected import TESTSUITE_CONFIG_EXPECTED
    
    7
    -
    
    8
    -
    
    9
    -def platform_key(platform, is_cross, is_unreg, no_tntc):
    
    10
    -    key = platform
    
    11
    -    if is_cross: key += "-cross"
    
    12
    -    if is_unreg: key += "-unreg"
    
    13
    -    elif no_tntc: key += "-no_tntc"
    
    14
    -    return key
    
    6
    +from ConfigPinsExpected import TESTSUITE_CONFIG_EXPECTED, platform_key
    
    15 7
     
    
    16 8
     
    
    17 9
     def main():
    

  • testsuite/tests/driver/config-pins/all.T
    1 1
     import sys
    
    2 2
     
    
    3
    +# Python run_command rather than compiled Haskell: wasm32/WASI targets cannot
    
    4
    +# call runInteractiveProcess from compiled binaries (no process creation in
    
    5
    +# WASI).  Python scripts run on the host regardless of the target under test.
    
    6
    +
    
    3 7
     test('GhcInfoPins',
    
    4 8
          [extra_files(['ConfigPinsExpected.py', 'GhcInfoPins.py']),
    
    5 9
           ignore_stdout],