This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit 21af0e5a958f8b2d4b1ad22debc83853a71af969
Author: Kim Woelders <[email protected]>
AuthorDate: Wed Feb 1 19:40:17 2023 +0100

    test: Print some progress info in a couple of tests
---
 test/test.cpp        | 33 +++++++++++++++++++++++++++++++++
 test/test.h          |  2 ++
 test/test_grab.cpp   |  4 ++--
 test/test_load.cpp   |  1 +
 test/test_load_2.cpp |  2 +-
 test/test_save.cpp   |  3 ++-
 6 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/test/test.cpp b/test/test.cpp
index 6360d15..2f22bb3 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -4,12 +4,15 @@
 #include "test.h"
 
 int                 debug = 0;
+static bool         ttyout = false;
 
 int
 main(int argc, char **argv)
 {
    const char         *s;
 
+   ttyout = isatty(STDOUT_FILENO);
+
    ::testing::InitGoogleTest(&argc, argv);
 
    for (argc--, argv++; argc > 0; argc--, argv++)
@@ -32,6 +35,36 @@ main(int argc, char **argv)
    return RUN_ALL_TESTS();
 }
 
+#define COL_RST  "\x1B[0m"
+#define COL_RED  "\x1B[31m"
+#define COL_GRN  "\x1B[32m"
+#define COL_YEL  "\x1B[33m"
+#define COL_BLU  "\x1B[34m"
+#define COL_MAG  "\x1B[35m"
+#define COL_CYN  "\x1B[36m"
+#define COL_WHT  "\x1B[37m"
+
+#include <stdarg.h>
+void
+pr_info(const char *fmt, ...)
+{
+   char                fmtx[1024];
+   va_list             args;
+
+   va_start(args, fmt);
+
+   if (ttyout)
+      snprintf(fmtx, sizeof(fmtx), COL_YEL "[          ] -  %s%s\n",
+               fmt, COL_RST);
+   else
+      snprintf(fmtx, sizeof(fmtx), "[          ] -  %s", fmt);
+   fmt = fmtx;
+
+   vprintf(fmt, args);
+
+   va_end(args);
+}
+
 #include <Imlib2.h>
 #include <zlib.h>
 
diff --git a/test/test.h b/test/test.h
index 6a574d8..724bea0 100644
--- a/test/test.h
+++ b/test/test.h
@@ -11,6 +11,8 @@
 
 extern int          debug;
 
+void                pr_info(const char *fmt, ...);
+
 unsigned int        image_get_crc32(Imlib_Image im);
 
 #endif /* TEST_H */
diff --git a/test/test_grab.cpp b/test/test_grab.cpp
index 8d55796..65d82a3 100644
--- a/test/test_grab.cpp
+++ b/test/test_grab.cpp
@@ -351,8 +351,8 @@ _test_grab_2(const char *test, int depth, int func, int opt, int mask)
    Pixmap              pmap;
    int                 w, h, d, d2;
 
-   D("%s: %s: depth=%d func=%d opt=%d mask=%d", __func__,
-     test, depth, func, opt, mask);
+   pr_info("%s: %s: depth=%d func=%d opt=%d mask=%d", __func__,
+           test, depth, func, opt, mask);
 
    snprintf(buf, sizeof(buf), "%s_d%02d_f%d_o%d_m%d",
             test, depth, func, opt, mask);
diff --git a/test/test_load.cpp b/test/test_load.cpp
index 9dbdacd..cd34cec 100644
--- a/test/test_load.cpp
+++ b/test/test_load.cpp
@@ -117,6 +117,7 @@ test_load(void)
      {
         // Load files of all types
         snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMG_SRC, "icon-64", pfxs[i]);
+        pr_info("Load '%s'", fileo);
 
         D("Load '%s' (deferred)\n", fileo);
         im = imlib_load_image(fileo);
diff --git a/test/test_load_2.cpp b/test/test_load_2.cpp
index 6cdecc6..d409185 100644
--- a/test/test_load_2.cpp
+++ b/test/test_load_2.cpp
@@ -113,7 +113,7 @@ TEST(LOAD2, load_1)
              snprintf(buf, sizeof(buf), "%s/%s", IMG_SRC, fn);
              fn = buf;
           }
-        D("Load '%s'\n", fn);
+        pr_info("Load '%s'", fn);
 
         im = imlib_load_image(fn);
         ASSERT_TRUE(im);
diff --git a/test/test_save.cpp b/test/test_save.cpp
index 3bd1563..fdb4b96 100644
--- a/test/test_save.cpp
+++ b/test/test_save.cpp
@@ -97,7 +97,8 @@ test_save_1(const char *file, int prog, int check = 0)
         h = imlib_image_get_height();
         snprintf(fileo, sizeof(fileo), "%s/save-%s-%dx%d.%s",
                  IMG_GEN, file, w, h, ext);
-        D("Save '%s'\n", fileo);
+        pr_info("Save '%s'", fileo);
+
         imlib_save_image_with_errno_return(fileo, &err);
         EXPECT_EQ(err, 0);
         if (err)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to