@@ -85,7 +85,7 @@ template("chip_test_suite") {
85
85
} else {
86
86
_target_type = " source_set"
87
87
}
88
- target (_target_type , " ${ _suite_name } _lib " ) {
88
+ target (_target_type , " ${ _suite_name } .lib " ) {
89
89
forward_variables_from (invoker , " *" , [ " tests" ])
90
90
91
91
output_dir = " ${ root_out_dir } /lib"
@@ -99,7 +99,104 @@ template("chip_test_suite") {
99
99
public_deps += [ " ${ chip_root } /src/platform/logging:force_stdio" ]
100
100
}
101
101
}
102
+ if (chip_link_tests ) {
103
+ tests = []
104
+
105
+ if (defined (invoker .test_sources )) {
106
+ foreach (_test , invoker .test_sources ) {
107
+ _test_name = string_replace (_test , " .cpp" , " " )
108
+
109
+ pw_test (_test_name ) {
110
+ forward_variables_from (invoker ,
111
+ [
112
+ " deps" ,
113
+ " public_deps" ,
114
+ " cflags" ,
115
+ " configs" ,
116
+ ])
117
+ public_deps += [ " :${ _suite_name } .lib" ]
118
+ sources = [ _test ]
119
+ }
120
+ tests += [ _test_name ]
121
+ }
122
+ }
123
+
124
+ if (defined (invoker .tests )) {
125
+ foreach (_test , invoker .tests ) {
126
+ pw_test (_test ) {
127
+ forward_variables_from (invoker ,
128
+ [
129
+ " deps" ,
130
+ " public_deps" ,
131
+ " cflags" ,
132
+ " configs" ,
133
+ ])
134
+ public_deps += [ " :${ _suite_name } .lib" ]
135
+ test_main = " "
136
+ sources = [
137
+ " ${ _test } .cpp" ,
138
+ " ${ _test } Driver.cpp" ,
139
+ ]
140
+ }
141
+ tests += [ _test ]
142
+ }
143
+ }
102
144
145
+ group (_suite_name ) {
146
+ deps = []
147
+ foreach (_test , tests ) {
148
+ deps += [ " :${ _test } " ]
149
+ }
150
+ }
151
+
152
+ if (chip_pw_run_tests ) {
153
+ group (" ${ _suite_name } _run" ) {
154
+ deps = []
155
+ foreach (_test , tests ) {
156
+ deps += [ " :${ _test } .run" ]
157
+ }
158
+ }
159
+ }
160
+ } else {
161
+ group (_suite_name ) {
162
+ deps = [ " :${ _suite_name } .lib" ]
163
+ }
164
+ }
165
+ }
166
+
167
+ # TODO: remove this once transition away from nlunit-test is completed
168
+ template (" chip_test_suite_using_nltest" ) {
169
+ _suite_name = target_name
170
+
171
+ # Ensures that the common library has sources containing both common
172
+ # and individual unit tests.
173
+ if (! defined (invoker .sources )) {
174
+ invoker .sources = []
175
+ }
176
+
177
+ if (defined (invoker .test_sources )) {
178
+ invoker .sources += invoker .test_sources
179
+ }
180
+
181
+ if (chip_build_test_static_libraries ) {
182
+ _target_type = " static_library"
183
+ } else {
184
+ _target_type = " source_set"
185
+ }
186
+ target (_target_type , " ${ _suite_name } .lib" ) {
187
+ forward_variables_from (invoker , " *" , [ " tests" ])
188
+
189
+ output_dir = " ${ root_out_dir } /lib"
190
+
191
+ if (! defined (invoker .public_deps )) {
192
+ public_deps = []
193
+ }
194
+
195
+ if (current_os != " zephyr" && current_os != " mbed" ) {
196
+ # Depend on stdio logging, and have it take precedence over the default platform backend
197
+ public_deps += [ " ${ chip_root } /src/platform/logging:force_stdio" ]
198
+ }
199
+ }
103
200
if (chip_link_tests ) {
104
201
tests = []
105
202
@@ -123,11 +220,10 @@ template("chip_test_suite") {
123
220
chip_test (_test_name ) {
124
221
sources = [ _driver_name ]
125
222
public_deps = [
126
- " :${ _suite_name } _lib " ,
223
+ " :${ _suite_name } .lib " ,
127
224
" :${ _test_name } _generate_driver" ,
128
225
]
129
226
}
130
-
131
227
tests += [ _test_name ]
132
228
}
133
229
}
@@ -137,9 +233,8 @@ template("chip_test_suite") {
137
233
chip_test (_test ) {
138
234
sources = [ " ${ _test } Driver.cpp" ]
139
235
140
- public_deps = [ " :${ _suite_name } _lib " ]
236
+ public_deps = [ " :${ _suite_name } .lib " ]
141
237
}
142
-
143
238
tests += [ _test ]
144
239
}
145
240
}
@@ -155,13 +250,13 @@ template("chip_test_suite") {
155
250
group (" ${ _suite_name } _run" ) {
156
251
deps = []
157
252
foreach (_test , tests ) {
158
- deps += [ " :${ _test } _run " ]
253
+ deps += [ " :${ _test } .run " ]
159
254
}
160
255
}
161
256
}
162
257
} else {
163
258
group (_suite_name ) {
164
- deps = [ " :${ _suite_name } _lib " ]
259
+ deps = [ " :${ _suite_name } .lib " ]
165
260
}
166
261
}
167
262
}
0 commit comments