all.T 4.65 KB
Newer Older
dterei's avatar
dterei committed
1 2 3 4
# Just do the normal way, SafeHaskell is all in the frontend
def f( opts ):
  opts.only_ways = ['normal']

5 6 7
def normaliseArrayPackage(str):
    return re.sub('array-[0-9]+(\.[0-9]+)*', 'array-<VERSION>', str)

8 9 10
def normaliseBytestringPackage(str):
    return re.sub('bytestring-[0-9]+(\.[0-9]+)*', 'bytestring-<VERSION>', str)

dterei's avatar
dterei committed
11 12
setTestOpts(f)

13 14 15 16 17
if config.have_vanilla:
    vanilla = '--enable-library-vanilla'
else:
    vanilla = '--disable-library-vanilla'

dterei's avatar
dterei committed
18 19 20
if config.have_profiling:
    prof = '--enable-library-profiling'
else:
21 22 23 24 25 26
    prof = '--disable-library-profiling'

if config.have_shared_libs:
    dyn = '--enable-shared'
else:
    dyn = '--disable-shared'
dterei's avatar
dterei committed
27

28 29
make_args = 'VANILLA=' + vanilla + ' PROF=' + prof + ' DYN=' + dyn

30 31
# Test building a package, that trust values are set correctly
# and can be changed correctly
dterei's avatar
dterei committed
32
test('safePkg01',
33
     [clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.safePkg01'),
34 35
      two_normalisers(normalise_fun(normaliseArrayPackage),
                      normalise_fun(normaliseBytestringPackage))],
dterei's avatar
dterei committed
36
     run_command, 
37
     ['$MAKE -s --no-print-directory safePkg01 ' + make_args])
dterei's avatar
dterei committed
38

39 40 41 42 43
# Fail since we enable package trust
test('ImpSafe01', normal, compile_fail, ['-fpackage-trust -distrust base'])

# Succeed since we don't enable package trust
test('ImpSafe02', normal, compile, ['-distrust base'])
dterei's avatar
dterei committed
44

45 46 47 48 49
test('ImpSafeOnly01',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly01 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly01')],
     compile,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly01/local.db -trust base'])
dterei's avatar
dterei committed
50

51 52 53 54 55
test('ImpSafeOnly02',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly02 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly02')],
     compile,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly02/local.db -trust base -trust safePkg01'])
dterei's avatar
dterei committed
56

dterei's avatar
dterei committed
57
# Fail since we enable package trust (and still need safePkg01 trusted)
58 59 60 61 62
test('ImpSafeOnly03',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly03 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly03')],
     compile_fail,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly03/local.db -trust base'])
63 64

# Succeed since we don't enable package trust
65 66 67 68 69
test('ImpSafeOnly04',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly04 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly04')],
     compile,
     ['-package-db pdb.ImpSafeOnly04/local.db -trust base'])
dterei's avatar
dterei committed
70

dterei's avatar
dterei committed
71
# fail due to missing trust of safePkg01, next test succeeds.
72 73 74 75 76 77 78 79 80 81
test('ImpSafeOnly05',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly05 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly05')],
     compile_fail,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly05/local.db -trust base'])
test('ImpSafeOnly06',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly06 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly06')],
     compile,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly06/local.db -trust base -trust safePkg01'])
dterei's avatar
dterei committed
82 83

# fail due to missing trust
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
test('ImpSafeOnly07',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly07 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly07'),
      normalise_errmsg_fun(normaliseBytestringPackage)],
     compile_fail,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly07/local.db -trust safePkg01'])
test('ImpSafeOnly08',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly08 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly08'),
      normalise_errmsg_fun(normaliseBytestringPackage)],
     compile_fail,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly08/local.db -trust safePkg01'])
test('ImpSafeOnly09',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly09 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly09'),
      normalise_errmsg_fun(normaliseBytestringPackage)],
     compile_fail,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly09/local.db -trust safePkg01'])
dterei's avatar
dterei committed
102 103

# finally succeed
104 105 106 107 108
test('ImpSafeOnly10',
     [pre_cmd('$MAKE -s --no-print-directory mkPackageDatabase.ImpSafeOnly10 ' + make_args),
      clean_cmd('$MAKE -s --no-print-directory cleanPackageDatabase.ImpSafeOnly10')],
     compile,
     ['-fpackage-trust -package-db pdb.ImpSafeOnly10/local.db -trust safePkg01 -trust base -trust bytestring'])
dterei's avatar
dterei committed
109