Skip to content

Commit 0ec522d

Browse files
committed
changed how test_sources is checked for undefined. Tried adding common lib back into group() target
1 parent ec94bd8 commit 0ec522d

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

build/chip/chip_test_suite.gni

+36-35
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,13 @@ declare_args() {
5353
template("chip_test_suite") {
5454
_suite_name = target_name
5555

56-
if (!defined(invoker.test_sources)) {
57-
invoker.test_sources = []
58-
}
59-
6056
if (chip_build_test_static_libraries) {
6157
_target_type = "static_library"
6258
} else {
6359
_target_type = "source_set"
6460
}
6561
target(_target_type, "${_suite_name}.lib") {
66-
forward_variables_from(invoker, "*", [ "tests", "test_sources", ])
62+
forward_variables_from(invoker, "*", [ "tests", "test_sources" ])
6763

6864
output_dir = "${root_out_dir}/lib"
6965

@@ -84,40 +80,42 @@ template("chip_test_suite") {
8480

8581
tests = []
8682

87-
foreach(_test, invoker.test_sources) {
88-
_test_name = string_replace(_test, ".cpp", "")
89-
90-
_test_output_dir = "${root_out_dir}/tests"
91-
if (defined(invoker.output_dir)) {
92-
_test_output_dir = invoker.output_dir
93-
}
83+
if (defined(invoker.test_sources)) {
84+
foreach(_test, invoker.test_sources) {
85+
_test_name = string_replace(_test, ".cpp", "")
9486

95-
pw_test(_test_name) {
96-
# Forward certain variables from the invoker.
97-
forward_variables_from(invoker,
98-
[
99-
"deps",
100-
"public_deps",
101-
"cflags",
102-
"configs",
103-
])
104-
105-
# Link to the common lib for this suite so we get its `sources`.
106-
public_deps += [ ":${_suite_name}.lib" ]
107-
108-
# Set variables that the platform executable may need.
109-
if (test_executable_output_name != "") {
110-
output_name = test_executable_output_name + _test_name +
111-
test_executable_output_name_suffix
87+
_test_output_dir = "${root_out_dir}/tests"
88+
if (defined(invoker.output_dir)) {
89+
_test_output_dir = invoker.output_dir
11290
}
113-
ldflags = test_executable_ldflags
11491

115-
# Add the individual test source file (e.g. "TestSomething.cpp").
116-
sources = [ _test ]
117-
118-
output_dir = _test_output_dir
92+
pw_test(_test_name) {
93+
# Forward certain variables from the invoker.
94+
forward_variables_from(invoker,
95+
[
96+
"deps",
97+
"public_deps",
98+
"cflags",
99+
"configs",
100+
])
101+
102+
# Link to the common lib for this suite so we get its `sources`.
103+
public_deps += [ ":${_suite_name}.lib" ]
104+
105+
# Set variables that the platform executable may need.
106+
if (test_executable_output_name != "") {
107+
output_name = test_executable_output_name + _test_name +
108+
test_executable_output_name_suffix
109+
}
110+
ldflags = test_executable_ldflags
111+
112+
# Add the individual test source file (e.g. "TestSomething.cpp").
113+
sources = [ _test ]
114+
115+
output_dir = _test_output_dir
116+
}
117+
tests += [ _test_name ]
119118
}
120-
tests += [ _test_name ]
121119
}
122120

123121
group(_suite_name) {
@@ -127,6 +125,9 @@ template("chip_test_suite") {
127125
foreach(_test, tests) {
128126
deps += [ ":${_test}" ]
129127
}
128+
129+
# Add the common library.
130+
deps += [ ":${_suite_name}.lib" ]
130131
}
131132

132133
if (chip_pw_run_tests) {

0 commit comments

Comments
 (0)