summaryrefslogtreecommitdiff
path: root/testsuite/tests/safeHaskell/check/all.T
blob: a4ac4b46cdd64ef92ffe503b4bf96f95d3eb20bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# check tests are about checking that the transitive safety
# check of safe haskell is working properly.

# Just do the normal way, SafeHaskell is all in the frontend
def f( name, opts ):
  opts.only_ways = ['normal']

setTestOpts(f)

test('CheckA', normal, compile, [''])
test('CheckB', [], multimod_compile, ['CheckB', '-trust base'])

# fail as we don't trust base when compiling Check01
test('Check01', normal, multi_compile_fail, ['Check01 -distrust base', [
                                            ('Check01_A.hs', ''),
                                            ('Check01_B.hs', '-trust base')
                                            ], '-fpackage-trust'])

# succeed this time since we trust base when we compile AND use CheckB
test('Check02', normal, multi_compile, ['Check02', [
                                       ('Check02_A.hs', ''),
                                       ('Check02_B.hs', '')
                                       ], '-trust base -fpackage-trust'])

# succeed as while like Check01_fail we don't import CheckB as a safe
# import this time, so don't require base trusted when used.
test('Check03', normal, multi_compile, ['Check03', [
                                       ('Check03_A.hs', ''),
                                       ('Check03_B.hs', '-trust base')
                                       ], '-fpackage-trust'])

# Check a slightly larger transitive program. Check01 isn't imported
# safely by Check03 so we don't require base trused at end.
test('Check04', normal, multi_compile, ['Check04', [
                                       ('Check04_A.hs', ''),
                                       ('Check04_B.hs', '-trust base'),
                                       ('Check04_1.hs', '-trust base')
                                       ], '-fpackage-trust'])

# Check -fpackage-trust with no safe haskell flag is an error
test('Check05', normal, compile, [''])

# Check safe-infered modules have correct pkg trust requirements
test('Check06', [], multimod_compile_fail, ['Check06', ''])

# Check selective safe imports bring in correct pkg trust requirements
test('Check07', [], multimod_compile, ['Check07', ''])

# Check selective safe imports bring in correct pkg trust requirements
test('Check08', [], multimod_compile_fail, ['Check08', ''])

# check -distrust-all-packages flag works
test('Check09',
     normalise_version("bytestring"),
     compile_fail,
     ['-fpackage-trust -distrust-all-packages'])

# as above but trust this time
test('Check10', normal, compile,
     ['-fpackage-trust -distrust-all-packages -trust bytestring -trust base'])