[libcxx-commits] [PATCH] D145405: [libc++] Extract std::fprintf into a function for use within the test suite
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 7 06:07:35 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdbe6894ac634: [libc++] Extract std::fprintf into a function for use within the test suite (authored by ldionne).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145405/new/
https://reviews.llvm.org/D145405
Files:
libcxx/test/support/assert_macros.h
libcxx/test/support/concat_macros.h
Index: libcxx/test/support/concat_macros.h
===================================================================
--- libcxx/test/support/concat_macros.h
+++ libcxx/test/support/concat_macros.h
@@ -12,6 +12,7 @@
#include <cstdio>
#include <string>
+#include "assert_macros.h"
#include "test_macros.h"
#ifndef TEST_HAS_NO_LOCALIZATION
@@ -46,7 +47,7 @@
}
// Writes its arguments to stderr, using the test_concat_message helper.
-# define TEST_WRITE_CONCATENATED(...) [&] { ::std::fprintf(stderr, "%s", ::test_concat_message(__VA_ARGS__).c_str()); }
+# define TEST_WRITE_CONCATENATED(...) [&] { ::test_eprintf("%s", ::test_concat_message(__VA_ARGS__).c_str()); }
#endif // TEST_STD_VER > 17
Index: libcxx/test/support/assert_macros.h
===================================================================
--- libcxx/test/support/assert_macros.h
+++ libcxx/test/support/assert_macros.h
@@ -29,14 +29,23 @@
#include <cstdio>
#include <cstdlib>
+// This function prints the given arguments to standard error.
+//
+// Keeping this as a separate function is important since it provides a single point for
+// downstreams to customize how errors are printed on exotic targets, if needed.
+template <class ...Args>
+void test_eprintf(char const* fmt, Args const& ...args) {
+ std::fprintf(stderr, fmt, args...);
+}
+
void test_log(const char* condition, const char* file, int line, const char* message) {
const char* msg = condition ? "Assertion failure: " : "Unconditional failure:";
- std::fprintf(stderr, "%s%s %s %d\n%s", msg, condition, file, line, message);
+ test_eprintf("%s%s %s %d\n%s", msg, condition, file, line, message);
}
template <class F>
void test_log(const char* condition, const char* file, int line, const F& functor) {
- std::fprintf(stderr, "Assertion failure: %s %s %d\n", condition, file, line);
+ test_eprintf("Assertion failure: %s %s %d\n", condition, file, line);
functor();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145405.503013.patch
Type: text/x-patch
Size: 1934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230307/62c4d3a0/attachment.bin>
More information about the libcxx-commits
mailing list