49e4ec20f1aa3456d1157181191a7eb27c9ecf21
[ghc.git] / testsuite / tests / safeHaskell / check / pkg01 / all.T
1 # Just do the normal way, SafeHaskell is all in the frontend
2 def f( name, opts ):
3   opts.only_ways = ['normal']
4
5 def ignoreLdOutput(str):
6     return re.sub('Creating library file: pdb.safePkg01/dist.build.libHSsafePkg01-1.0-ghc[0-9.]*.dll.a\n', '', str)
7
8 setTestOpts(f)
9
10 if config.have_vanilla:
11     vanilla = '--enable-library-vanilla'
12 else:
13     vanilla = '--disable-library-vanilla'
14
15 if config.have_profiling:
16     prof = '--enable-library-profiling'
17 else:
18     prof = '--disable-library-profiling'
19
20 if config.have_shared_libs:
21     dyn = '--enable-shared'
22 else:
23     dyn = '--disable-shared'
24
25 make_args = 'VANILLA=' + vanilla + ' PROF=' + prof + ' DYN=' + dyn
26
27 # Test building a package, that trust values are set correctly
28 # and can be changed correctly
29 test('safePkg01',
30      [clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.safePkg01'),
31       normalise_errmsg_fun(ignoreLdOutput),
32       normalise_version("array", "integer-gmp", "integer-simple", "bytestring",
33                         "base", "deepseq", "ghc-prim"),
34      ],
35      run_command,
36      ['$MAKE -s --no-print-directory safePkg01 ' + make_args])
37
38 # Fail since we enable package trust
39 test('ImpSafe01', normal, compile_fail, ['-fpackage-trust -distrust base'])
40
41 # Succeed since we don't enable package trust
42 test('ImpSafe02', normal, compile, ['-distrust base'])
43
44 # Fail since we don't trust base of bytestring
45 test('ImpSafe03',
46   [normalise_version("bytestring")],
47   multi_compile_fail,
48   ['ImpSafe03 -trust base -distrust bytestring', [
49    ('ImpSafe03_A.hs', ' -trust base -trust bytestring')
50   ], '-fpackage-trust' ])
51
52 # Fail same as ImpSafe01 but testing with -XTrustworthy now
53 test('ImpSafe04', normal, compile_fail, ['-fpackage-trust -distrust base'])
54
55 test('ImpSafeOnly01',
56      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly01 ' + make_args),
57       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly01')],
58      compile,
59      ['-fpackage-trust -package-db pdb.ImpSafeOnly01/local.db -trust base'])
60
61 test('ImpSafeOnly02',
62      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly02 ' + make_args),
63       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly02')],
64      compile,
65      ['-fpackage-trust -package-db pdb.ImpSafeOnly02/local.db -trust base -trust safePkg01'])
66
67 # Fail since we enable package trust (and still need safePkg01 trusted)
68 test('ImpSafeOnly03',
69      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly03 ' + make_args),
70       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly03')],
71      compile_fail,
72      ['-fpackage-trust -package-db pdb.ImpSafeOnly03/local.db -trust base'])
73
74 # Succeed since we don't enable package trust
75 test('ImpSafeOnly04',
76      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly04 ' + make_args),
77       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly04')],
78      compile,
79      ['-package-db pdb.ImpSafeOnly04/local.db -trust base'])
80
81 # fail due to missing trust of safePkg01, next test succeeds.
82 test('ImpSafeOnly05',
83      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly05 ' + make_args),
84       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly05')],
85      compile_fail,
86      ['-fpackage-trust -package-db pdb.ImpSafeOnly05/local.db -trust base'])
87 test('ImpSafeOnly06',
88      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly06 ' + make_args),
89       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly06')],
90      compile,
91      ['-fpackage-trust -package-db pdb.ImpSafeOnly06/local.db -trust base -trust safePkg01'])
92
93 # fail due to missing trust
94 test('ImpSafeOnly07',
95      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly07 ' + make_args),
96       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly07'),
97       normalise_version("bytestring", "base")],
98      compile_fail,
99      ['-fpackage-trust -package-db pdb.ImpSafeOnly07/local.db -trust safePkg01 -distrust bytestring'])
100 test('ImpSafeOnly08',
101      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly08 ' + make_args),
102       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly08'),
103       normalise_version("bytestring", "base")],
104      compile_fail,
105      ['-fpackage-trust -package-db pdb.ImpSafeOnly08/local.db -trust safePkg01'])
106 test('ImpSafeOnly09',
107      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly09 ' + make_args),
108       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly09'),
109       normalise_version("bytestring")],
110      compile_fail,
111      ['-fpackage-trust -package-db pdb.ImpSafeOnly09/local.db -trust safePkg01'])
112
113 # finally succeed
114 test('ImpSafeOnly10',
115      [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly10 ' + make_args),
116       clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly10')],
117      compile,
118      ['-fpackage-trust -package-db pdb.ImpSafeOnly10/local.db -trust safePkg01 -trust base -trust bytestring'])
119