]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mk-unity.pl: `#include`, and not concatenate input headers
authorViktor Szakats <commit@vsz.me>
Mon, 18 May 2026 09:50:37 +0000 (11:50 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 18 May 2026 11:57:13 +0000 (13:57 +0200)
When using `-D_CURL_TESTS_CONCAT=ON` with CMake, do not concatenate
`first.h` (or any future header) into the output C file, but `#include`
it instead. This is to play nice with compilers and analyzers which may
apply different checker rules on logic found in headers, vs. the input
source file. As seen for example with `-Wunused-macro` enabled in CI.
After this patch concatenated sources behave closer to regular C
sources.

Also:
- first.h: drop some `-Wunused-macro` silencers that became redundant
  with this patch.

Follow-up to 47f411c6d840dcee63a2ac9cbc0bfbea522ac5cd #21554
Follow-up to 39542f09935aba0b7130c20b6aae0be5cd6ff709 #20667

Closes #21656

scripts/mk-unity.pl
tests/libtest/first.h

index 014cfe8eceb92e37018f205beea9a22162bcc726..41354c15d1202fe6866fa0a0737eb16f9a878579 100755 (executable)
@@ -65,7 +65,7 @@ foreach my $src (@ARGV) {
 
 sub include($@) {
     my $filename = shift;
-    if($concat) {
+    if($concat && $filename =~ /([a-z0-9_]+)\.c$/) {
         if(! -f $filename) {
             foreach my $path (@incpath) {
                 my $fullfn = $path . "/" . $filename;
index 21da11394c37499580b93bc98b3f130c70692aa8..d0b22df79b6153ecaba41103835942aee8f33814 100644 (file)
@@ -108,10 +108,7 @@ void ws_close(CURL *curl);  /* just close the connection */
  *
  * For portability reasons TEST_ERR_* values should be less than 127.
  */
-#if !defined(UNITTESTS) || defined(BUILDING_LIBCURL)
 #define TEST_ERR_MAJOR_BAD    CURLE_OBSOLETE20
-#endif
-#ifndef UNITTESTS
 #define TEST_ERR_RUNS_FOREVER CURLE_OBSOLETE24
 #define TEST_ERR_EASY_INIT    CURLE_OBSOLETE29
 #define TEST_ERR_MULTI        CURLE_OBSOLETE32
@@ -152,6 +149,7 @@ void ws_close(CURL *curl);  /* just close the connection */
  * TEST_ERR_* values defined above. It is advisable to return this value
  * as test result.
  */
+#ifndef UNITTESTS
 
 /* ---------------------------------------------------------------- */