| 1 |
""" |
| 2 |
Check switches for default profiles |
| 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 default profiles for root and dependency |
| 31 |
check_config(lib1_config, 'release', ['-O3', '-gnatn']) |
| 32 |
check_config(lib2_config, 'release', ['-O3', '-gnatn']) |
| 33 |
check_config(bin_config, 'development', ['-Og', '-g', '-gnatwa', '-gnaty3']) |
| 34 |
|
| 35 |
# Check if we can change the profile of a dependency |
| 36 |
with open(alr_manifest(), "a") as manifest: |
| 37 |
manifest.write('[build-profiles]\n') |
| 38 |
manifest.write('lib_1 = "development"\n') |
| 39 |
run_alr('update') |
| 40 |
check_config(lib1_config, 'development', ['-Og']) |
| 41 |
|
| 42 |
# Check wildcard profile setting |
| 43 |
with open(alr_manifest(), "a") as manifest: |
| 44 |
manifest.write('"*" = "validation"\n') |
| 45 |
run_alr('update') |
| 46 |
check_config(lib1_config, 'development', ['-Og']) |
| 47 |
check_config(lib2_config, 'validation', ['-gnatwe']) |
| 48 |
check_config(bin_config, 'validation', ['-gnatwe']) |
| 49 |
|
| 50 |
# Check that the project builds |
| 51 |
run_alr('build') |
| 52 |
|
| 53 |
print('SUCCESS') |