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