4
4
5
5
import os
6
6
7
+ from e3 .fs import mkdir , sync_tree
8
+
7
9
from SCOV .tc import TestCase
8
10
from SCOV .tctl import CovControl
9
11
from SUITE .control import env
19
21
'boolops-andthen.adb' , 'boolops-orelse.adb' ],
20
22
'intops' : ['intops.ads' , 'intops.adb' ,
21
23
'intops-add.adb' , 'intops-sub.adb' ],
22
- 'counters' : ['counters.ads' , 'counters.adb' ]
23
- }
24
-
25
-
26
- def _gpr_for (prj ):
27
- """
28
- Assuming we're in the tmpdir created by the SCOV TestCase
29
- instance, return the relative file name for the project file
30
- corresponding to the `prj` project shortname.
31
- """
32
-
33
- # <tcgroup_dir>
34
- # /intops
35
- # /boolops
36
- # /counters
37
- # /<tcdir>/<tmpdir_for_check>/<tmpdir_by_TestCase>
24
+ 'counters' : ['counters.ads' , 'counters.adb' ],
25
+ }
26
+ all_projects = list (_xreports )
38
27
39
- return '../../../%s/%s.gpr' % (prj , prj )
40
28
41
-
42
- def check (root_project , recurse ,
43
- projects = None , units = None ,
44
- xreports = None ):
29
+ def check (root_project , recurse , projects = None , units = None , xreports = None ):
45
30
"""
46
31
Check that running our test with
47
32
@@ -64,48 +49,39 @@ def check(root_project, recurse,
64
49
`recurse` None means "arrange not to pass any option influencing
65
50
recursiveness".
66
51
"""
67
-
68
52
projects = to_list (projects )
69
53
units = to_list (units )
70
54
71
- # root_project, projects, and units arguments we will provide to the
72
- # GPRswitches class:
73
- gprsw_root_project = (
74
- root_project if root_project .endswith ('.gpr' )
75
- else _gpr_for (root_project ))
76
-
77
- gprsw_projects = [_gpr_for (prj ) for prj in projects ]
78
-
79
- gprsw_units = units
80
-
81
- # Arrange to execute each check in its own tmp dir and
82
- # passing a unique --subdirs prevent mixups across test variants
83
- # within the shared projects.
84
-
85
- # Start with 'wd_foo' from .../.../foo.gpr or a project short
86
- # name intended for -P.
87
- tmpdir = 'wd_' + os .path .basename (root_project ).split ('.' )[0 ]
55
+ # Create a label for this variant that is unique in this testcase. Start
56
+ # including the root project.
57
+ label = os .path .splitext (os .path .basename (root_project ))[0 ]
88
58
89
59
# Append the first letter of each project name will pass through
90
60
# --project, if any:
91
61
if projects :
92
- tmpdir += '-' + '' .join (prj [0 ] for prj in projects )
62
+ label += '-' + '' .join (prj [0 ] for prj in projects )
93
63
94
64
# Append indication on recursion request:
95
65
if recurse :
96
- tmpdir += '-rt'
66
+ label += '-rt'
97
67
elif recurse is None :
98
- tmpdir += '-rn'
68
+ label += '-rn'
99
69
else :
100
- tmpdir += '-rf'
70
+ label += '-rf'
101
71
102
- # For the --subdirs argument, relative to each subproject's object dir,
103
- # prepend our testcase local directory name:
104
- gprsw_subdirs = os .path .basename (os .getcwd ()) + '_' + tmpdir
72
+ # Arrange to execute each check in its own temporary directory and copying
73
+ # shared projects in that directory prevent mixups across test variants.
74
+ tmpdir = f'wd_{ label } '
75
+ wd = Wdir (tmpdir )
76
+
77
+ # Copy shared projects in the temporary directory and create their object
78
+ # directory to avoid spurious warnings.
79
+ for p in all_projects :
80
+ sync_tree (os .path .join (wd .homedir , '..' , p ), p )
81
+ mkdir (os .path .join (p , "obj" ))
105
82
106
83
# If a list of expected reports is provided, convert into list of
107
84
# corresponding sources, which the CovControl class expects:
108
-
109
85
if xreports is not None :
110
86
ctl_xreports = []
111
87
for xr in xreports :
@@ -114,34 +90,32 @@ def check(root_project, recurse,
114
90
else :
115
91
ctl_xreports = None
116
92
117
- # Getting the default behavior wrt recursiveness consists
118
- # in requesting not to pass --no-subprojects.
119
- gprsw_no_subprojects = False if recurse is None else not recurse
120
-
121
- wd = Wdir ()
122
- wd .to_subdir (tmpdir )
93
+ # Getting the default behavior wrt recursiveness consists in requesting not
94
+ # to pass --no-subprojects.
95
+ no_subprojects = False if recurse is None else not recurse
123
96
124
97
TestCase (category = None ).run (
125
98
covcontrol = CovControl (
126
99
127
- # The programs we build and exercise alway depend on
128
- # the three subprojects:
129
- deps = [_gpr_for ('boolops' ),
130
- _gpr_for ('intops' ),
131
- _gpr_for ('counters' )],
100
+ # The programs we build and exercise always depend on the three
101
+ # subprojects (copied above in the parent directory relative to the
102
+ # TestCase temporary directory).
103
+ deps = [f'../{ p } /{ p } ' for p in all_projects ],
132
104
133
105
# What we analyse and check depends on our arguments:
134
106
gprsw = GPRswitches (
135
- root_project = gprsw_root_project ,
136
- projects = gprsw_projects ,
137
- units = gprsw_units ,
138
- no_subprojects = gprsw_no_subprojects ,
139
- subdirs = gprsw_subdirs ,
140
- xvars = [( 'BOARD' , env . target . machine )] ),
107
+ root_project = root_project ,
108
+ projects = projects ,
109
+ units = units ,
110
+ no_subprojects = no_subprojects ,
111
+ xvars = [( 'BOARD' , env . target . machine )] ,
112
+ ),
141
113
142
114
xreports = ctl_xreports ,
143
115
144
116
# The test driver and the likes are never of interest
145
- units_in = []))
117
+ units_in = [],
118
+ ),
119
+ )
146
120
147
121
wd .to_homedir ()
0 commit comments