pw_unit_test: Detect missing sources when disabled
Use an empty action with the source files as inputs rather than an empty
group as the stand-in target for a disabled test. This ensures that the
input files for disabled tests at least exist, even if they don't
compile.
Change-Id: I7ac6a7066d817cb394d320277a5d5caadb5650da
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13682
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_unit_test/test.gni b/pw_unit_test/test.gni
index 22e9e40..42b1c51 100644
--- a/pw_unit_test/test.gni
+++ b/pw_unit_test/test.gni
@@ -47,8 +47,20 @@
} else {
_actual_target_name = target_name + "_DISABLED"
- group(target_name) {
- forward_variables_from(invoker, [ "testonly" ])
+ # If the target is disabled, create an empty target in its place. Use an
+ # action with the original target's sources as inputs to ensure that
+ # the source files exist (even if they don't compile).
+ pw_python_script(target_name) {
+ script = "$dir_pw_build/py/nop.py"
+ stamp = true
+
+ inputs = []
+ if (defined(invoker.sources)) {
+ inputs += invoker.sources
+ }
+ if (defined(invoker.public)) {
+ inputs += invoker.public
+ }
}
}