Debian Codegraph @

testsuite/tests/build_profile/custom_switches/test.py

raw
1 """
2 Check that crates can define custom switches
3 """
4
5 from drivers.alr import run_alr, init_local_crate, alr_with, alr_manifest
6 from drivers.helpers import content_of
7 from drivers.asserts import assert_match
8
9 init_local_crate('lib_1', binary=False, enter=False)
10 init_local_crate('lib_2', binary=False, enter=False)
11 init_local_crate('bin_1', binary=True, enter=True)
12 alr_with('lib_1', path='../lib_1')
13 alr_with('lib_2', path='../lib_2')
14 run_alr('update')
15
16
17 def check_config(path, profile, expected_switches=[]):
18 conf = content_of(path)
19 assert_match('.*Build_Profile : Build_Profile_Kind := "%s"' % profile,
20 conf)
21
22 for sw in expected_switches:
23 assert_match('.*"%s"' % sw,conf)
24
25
26 lib1_config = "../lib_1/config/lib_1_config.gpr"
27 lib2_config = "../lib_2/config/lib_2_config.gpr"
28 bin_config = "config/bin_1_config.gpr"
29
30 # Check if we can change the profile of a dependency
31 manifests = [alr_manifest(), '../lib_1/alire.toml', '../lib_2/alire.toml']
32
33 for path in manifests:
34 with open(path, "a") as manifest:
35 manifest.write('[build-switches]\n')
36 manifest.write('"*".optimization = ["-opt-switch", "-opt-switch2"]\n')
37 manifest.write('"*".debug_info = ["-debug-info-switch"]\n')
38 manifest.write('"*".runtime_checks = ["-runtime-checks-switch"]\n')
39 manifest.write('"*".compile_checks = ["-compile-checks-switch"]\n')
40 manifest.write('"*".contracts = ["-contracts-switch"]\n')
41 manifest.write('"*".style_checks = ["-style-switch", "-style-switch2"]\n')
42 manifest.write('"*".ada_version = ["-ada-version"]\n')
43
44 run_alr('update')
45
46 expected_switches = ['-opt-switch',
47 '-opt-switch2',
48 '-debug-info-switch',
49 '-runtime-checks-switch',
50 '-compile-checks-switch',
51 '-contracts-switch',
52 '-style-switch',
53 '-style-switch2',
54 '-ada-version']
55
56 check_config(lib1_config, 'release', expected_switches)
57 check_config(lib2_config, 'release', expected_switches)
58 check_config(bin_config, 'development', expected_switches)
59
60 print('SUCCESS')