Hannes Siebenhandl pushed to branch wip/fendor/ghci-multiple-home-units at Glasgow Haskell Compiler / GHC

Commits:

20 changed files:

Changes:

  • testsuite/driver/testlib.py
    ... ... @@ -1543,7 +1543,7 @@ async def test_common_work(name: TestName, opts,
    1543 1543
                 all_ways = config.compile_ways
    
    1544 1544
             elif func in [compile_and_run, multi_compile_and_run, multimod_compile_and_run]:
    
    1545 1545
                 all_ways = config.run_ways
    
    1546
    -        elif func == ghci_script:
    
    1546
    +        elif func == ghci_script or func == ghci_multiunit_script:
    
    1547 1547
                 if config.have_interp:
    
    1548 1548
                     all_ways = [WayName('ghci'), WayName('ghci-opt')]
    
    1549 1549
                 else:
    
    ... ... @@ -1874,6 +1874,20 @@ async def ghci_script( name, way, script):
    1874 1874
         getTestOpts().stdin = script
    
    1875 1875
         return await simple_run( name, way, cmd, getTestOpts().extra_run_opts )
    
    1876 1876
     
    
    1877
    +async def ghci_multiunit_script( name, way, units, script):
    
    1878
    +    flags = ' '.join(get_compiler_flags())
    
    1879
    +    way_flags = ' '.join(config.way_flags[way])
    
    1880
    +    unit_flags = ' '.join(['-unit @%s' % unit for unit in units])
    
    1881
    +
    
    1882
    +    # We pass HC and HC_OPTS as environment variables, so that the
    
    1883
    +    # script can invoke the correct compiler by using ':! $HC $HC_OPTS'
    
    1884
    +    cmd = ('HC={{compiler}} HC_OPTS="{flags}" {{compiler}} {way_flags} {flags} {units}'
    
    1885
    +          ).format(flags=flags, way_flags=way_flags, units=unit_flags)
    
    1886
    +      # NB: put way_flags before flags so that flags in all.T can override others
    
    1887
    +
    
    1888
    +    getTestOpts().stdin = script
    
    1889
    +    return await simple_run( name, way, cmd, getTestOpts().extra_run_opts )
    
    1890
    +
    
    1877 1891
     # -----------------------------------------------------------------------------
    
    1878 1892
     # Compile-only tests
    
    1879 1893
     
    

  • testsuite/tests/ghci/prog-mhu001/Makefile
    1
    +TOP=../../..
    
    2
    +include $(TOP)/mk/boilerplate.mk
    
    3
    +include $(TOP)/mk/test.mk

  • testsuite/tests/ghci/prog-mhu001/e/E.hs
    1
    +module E where
    
    2
    +
    
    3
    +foo = 4
    
    4
    +
    
    5
    +main = putStrLn "Hello, World"
    
    6
    +
    
    7
    +class Test a where
    
    8
    +  test :: a -> String
    
    9
    +
    
    10
    +instance Test Int where
    
    11
    +  test = show

  • testsuite/tests/ghci/prog-mhu001/prog-mhu001.T
    1
    +test('prog-mhu001',
    
    2
    +     [extra_files(['../shell.hs', 'e/', 'unitE', 'prog-mhu001.script']),
    
    3
    +      cmd_prefix('ghciWayFlags=' + config.ghci_way_flags),
    
    4
    +      req_interp],
    
    5
    +     ghci_multiunit_script, [['unitE'], 'prog-mhu001.script'])

  • testsuite/tests/ghci/prog-mhu001/prog-mhu001.script
    1
    +:m + E
    
    2
    +foo
    
    3
    +test (5 :: Int)
    
    4
    +main
    
    5
    +:main

  • testsuite/tests/ghci/prog-mhu001/prog-mhu001.stdout
    1
    +4
    
    2
    +"5"
    
    3
    +Hello, World
    
    4
    +Hello, World

  • testsuite/tests/ghci/prog-mhu001/unitE
    1
    +-i
    
    2
    +-ie/
    
    3
    +E
    
    4
    +-this-unit-id e-0.0.0
    
    5
    +-package base

  • testsuite/tests/ghci/prog-mhu002/Makefile
    1
    +TOP=../../..
    
    2
    +include $(TOP)/mk/boilerplate.mk
    
    3
    +include $(TOP)/mk/test.mk

  • testsuite/tests/ghci/prog-mhu002/a/A.hs
    1
    +module A where
    
    2
    +
    
    3
    +import B
    
    4
    +
    
    5
    +baz = foo + foobar
    
    6
    +
    
    7
    +foobar = 18
    
    8
    +
    
    9
    +data A = A deriving (Show)
    
    10
    +
    
    11
    +instance Test A where
    
    12
    +  test = show

  • testsuite/tests/ghci/prog-mhu002/b/B.hs
    1
    +module B where
    
    2
    +
    
    3
    +foo = 50
    
    4
    +
    
    5
    +class Test a where
    
    6
    +  test :: a -> String
    
    7
    +
    
    8
    +instance Test Int where
    
    9
    +  test = show

  • testsuite/tests/ghci/prog-mhu002/c/C.hs
    1
    +module C (bar) where
    
    2
    +
    
    3
    +bar = 3
    
    4
    +foo = 4

  • testsuite/tests/ghci/prog-mhu002/d/Main.hs
    1
    +module Main where
    
    2
    +
    
    3
    +main = putStrLn "Hello, World"
    
    4
    +
    
    5
    +test = 5

  • testsuite/tests/ghci/prog-mhu002/prog-mhu002.T
    1
    +test('prog-mhu002',
    
    2
    +     [extra_files(['../shell.hs', 'a/', 'b/', 'c/', 'd/'
    
    3
    +                  , 'unitA', 'unitB', 'unitC', 'unitD',
    
    4
    +                  ]),
    
    5
    +     cmd_prefix('ghciWayFlags=' + config.ghci_way_flags),
    
    6
    +     unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext'])),
    
    7
    +     req_interp],
    
    8
    +     ghci_multiunit_script, [['unitA', 'unitB', 'unitC', 'unitD'], 'prog-mhu002.script'])

  • testsuite/tests/ghci/prog-mhu002/prog-mhu002.script
    1
    +:m + A B C Main
    
    2
    +baz
    
    3
    +foobar
    
    4
    +:m - A B C Main
    
    5
    +baz
    
    6
    +foobar
    
    7
    +:m + C
    
    8
    +bar
    
    9
    +foo
    
    10
    +:m + Main
    
    11
    +main
    
    12
    +

  • testsuite/tests/ghci/prog-mhu002/prog-mhu002.stderr
    1
    +<interactive>:5:1: error: [GHC-88464] Variable not in scope: baz
    
    2
    +
    
    3
    +<interactive>:6:1: error: [GHC-88464] Variable not in scope: foobar
    
    4
    +
    
    5
    +<interactive>:9:1: error: [GHC-88464] Variable not in scope: foo
    
    6
    +

  • testsuite/tests/ghci/prog-mhu002/prog-mhu002.stdout
    1
    +68
    
    2
    +18
    
    3
    +3
    
    4
    +Hello, World

  • testsuite/tests/ghci/prog-mhu002/unitA
    1
    +-i
    
    2
    +-ia/
    
    3
    +A
    
    4
    +-this-unit-id a-0.0.0
    
    5
    +-package base
    
    6
    +-package-id b-0.0.0

  • testsuite/tests/ghci/prog-mhu002/unitB
    1
    +-i
    
    2
    +-ib/
    
    3
    +B
    
    4
    +-this-unit-id b-0.0.0
    
    5
    +-package base

  • testsuite/tests/ghci/prog-mhu002/unitC
    1
    +-i
    
    2
    +-ic/
    
    3
    +C
    
    4
    +-this-unit-id c-0.0.0
    
    5
    +-package base
    
    6
    +-package-id b-0.0.0

  • testsuite/tests/ghci/prog-mhu002/unitD
    1
    +-i
    
    2
    +-id/
    
    3
    +d/Main.hs
    
    4
    +-this-unit-id d-0.0.0
    
    5
    +-package base