44
55import os
66
7+ from e3 .fs import mkdir , sync_tree
8+
79from SCOV .tc import TestCase
810from SCOV .tctl import CovControl
911from SUITE .control import env
1921 'boolops-andthen.adb' , 'boolops-orelse.adb' ],
2022 'intops' : ['intops.ads' , 'intops.adb' ,
2123 '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 )
3827
39- return '../../../%s/%s.gpr' % (prj , prj )
4028
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 ):
4530 """
4631 Check that running our test with
4732
@@ -64,48 +49,39 @@ def check(root_project, recurse,
6449 `recurse` None means "arrange not to pass any option influencing
6550 recursiveness".
6651 """
67-
6852 projects = to_list (projects )
6953 units = to_list (units )
7054
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 ]
8858
8959 # Append the first letter of each project name will pass through
9060 # --project, if any:
9161 if projects :
92- tmpdir += '-' + '' .join (prj [0 ] for prj in projects )
62+ label += '-' + '' .join (prj [0 ] for prj in projects )
9363
9464 # Append indication on recursion request:
9565 if recurse :
96- tmpdir += '-rt'
66+ label += '-rt'
9767 elif recurse is None :
98- tmpdir += '-rn'
68+ label += '-rn'
9969 else :
100- tmpdir += '-rf'
70+ label += '-rf'
10171
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" ))
10582
10683 # If a list of expected reports is provided, convert into list of
10784 # corresponding sources, which the CovControl class expects:
108-
10985 if xreports is not None :
11086 ctl_xreports = []
11187 for xr in xreports :
@@ -114,34 +90,32 @@ def check(root_project, recurse,
11490 else :
11591 ctl_xreports = None
11692
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
12396
12497 TestCase (category = None ).run (
12598 covcontrol = CovControl (
12699
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 ],
132104
133105 # What we analyse and check depends on our arguments:
134106 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+ ),
141113
142114 xreports = ctl_xreports ,
143115
144116 # The test driver and the likes are never of interest
145- units_in = []))
117+ units_in = [],
118+ ),
119+ )
146120
147121 wd .to_homedir ()
0 commit comments