Debian Codegraph @

testsuite/tests/build_profile/alr_build_switches/test.py

raw
1 """
2 Check `alr build` switches to control root profile
3 """
4
5 import os
6
7 from drivers.alr import run_alr, init_local_crate, alr_with, alr_manifest
8 from drivers.helpers import content_of
9 from drivers.asserts import assert_match
10
11 init_local_crate('lib_1', binary=False, enter=False)
12 init_local_crate('bin_1', binary=True, enter=True)
13 run_alr('update')
14
15 def check_config(path, profile):
16 conf = content_of(path)
17 assert_match('.*Build_Profile : Build_Profile_Kind := "%s"' % profile,
18 conf)
19
20 lib1_config = "../lib_1/config/lib_1_config.gpr"
21 bin_config = "config/bin_1_config.gpr"
22
23 mtime = os.path.getmtime(bin_config)
24
25 def check_config_changed():
26 global mtime
27 last_mtime = mtime
28 mtime = os.path.getmtime(bin_config)
29 assert last_mtime != mtime, "config file did not change"
30
31
32 def check_config_not_changed():
33 global mtime
34 last_mtime = mtime
35 mtime = os.path.getmtime(bin_config)
36 assert last_mtime == mtime, "config file did not change"
37
38
39 # Check default profiles for root and dependency
40 check_config(bin_config, 'development')
41
42 # Check that the project builds
43 run_alr('build')
44
45 # Build in validation mode
46 run_alr('build', '--validation')
47 check_config_changed()
48 check_config(bin_config, 'validation')
49
50 # Build in validation mode
51 run_alr('build', '--development')
52 check_config_changed()
53 check_config(bin_config, 'development')
54
55 # Build in release mode
56 run_alr('build', '--release')
57 check_config_changed()
58 check_config(bin_config, 'release')
59
60 # Alr with will re-generate the crate config and default to DEVELOPMENT
61 alr_with('lib_1', path='../lib_1')
62 check_config_changed()
63 check_config(bin_config, 'development')
64
65 # Build with default profile, the config should not change
66 run_alr('build')
67 check_config_not_changed()
68
69 print('SUCCESS')