GraphicsMagick: BatchCommand(): Added a '-tap-mode on' option to...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.8128.1681910149.1602.graphicsmagick-commit@lists.sourceforge.net>
changeset 5bef7aeb196d in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=5bef7aeb196d
summary: BatchCommand(): Added a '-tap-mode on' option to 'gm batch'

diffstat:

 ChangeLog                              |   7 ++++
 VisualMagick/installer/inc/version.isx |   4 +-
 magick/command.c                       |  55 ++++++++++++++++++++++++++-------
 magick/version.h                       |   4 +-
 utilities/tests/convert-batch.tap      |   2 +-
 www/Changelog.html                     |   9 +++++
 6 files changed, 64 insertions(+), 17 deletions(-)

diffs (190 lines):

diff -r 1eeb539e61c5 -r 5bef7aeb196d ChangeLog
--- a/ChangeLog	Sun Apr 16 14:27:04 2023 -0500
+++ b/ChangeLog	Wed Apr 19 08:15:38 2023 -0500
@@ -1,3 +1,10 @@
+2023-04-19  Bob Friesenhahn  <[email protected]>
+
+	* magick/command.c (BatchCommand): Implement simple Test Anything
+	Protocol (TAP) test counting and "ok N"/"not ok N" messaging for
+	'gm batch' via the '-tap-mode on' option.  This is still a work in
+	progress, but is already useful.
+
 2023-04-16  Bob Friesenhahn  <[email protected]>
 
 	* utilities/tests/convert-batch.tap: Added a TAP-like test script
diff -r 1eeb539e61c5 -r 5bef7aeb196d VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sun Apr 16 14:27:04 2023 -0500
+++ b/VisualMagick/installer/inc/version.isx	Wed Apr 19 08:15:38 2023 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020230416"
-#define public MagickPackageReleaseDate "snapshot-20230416"
+#define public MagickPackageVersionAddendum ".020230419"
+#define public MagickPackageReleaseDate "snapshot-20230419"
diff -r 1eeb539e61c5 -r 5bef7aeb196d magick/command.c
--- a/magick/command.c	Sun Apr 16 14:27:04 2023 -0500
+++ b/magick/command.c	Wed Apr 19 08:15:38 2023 -0500
@@ -129,13 +129,19 @@
 
 #define SIZE_OPTION_VALUE 256
 typedef struct _BatchOptions {
-  MagickBool        stop_on_error,
-                    is_feedback_enabled,
-                    is_echo_enabled;
-  char              prompt[SIZE_OPTION_VALUE],
-                    pass[SIZE_OPTION_VALUE],
-                    fail[SIZE_OPTION_VALUE];
-  CommandLineParser command_line_parser;
+  MagickBool
+    stop_on_error,
+    is_feedback_enabled,
+    is_echo_enabled,
+    is_tap_mode;
+
+  char
+    prompt[SIZE_OPTION_VALUE],
+    pass[SIZE_OPTION_VALUE],
+    fail[SIZE_OPTION_VALUE];
+
+  CommandLineParser
+    command_line_parser;
 } BatchOptions;
 
 typedef MagickPassFail (*CommandVectorHandler)(ImageInfo *image_info,
@@ -1547,6 +1553,7 @@
   MagickBool hasInputFile;
   int ac;
   char *av[MAX_PARAM+1];
+  unsigned int line_no = 0;
 
 #if defined(MSWINDOWS)
   InitializeMagick((char *) NULL);
@@ -1600,9 +1607,15 @@
       (void) fflush(stdout);
     }
 
+
   while (!(ferror(stdin) || ferror(stdout) || ferror(stderr) || feof(stdin)))
     {
-      if (batch_options.prompt[0])
+      if (batch_options.is_tap_mode)
+        {
+          (void) fputs("# ", stdout);
+          (void) fflush(stdout);
+        }
+      else if (batch_options.prompt[0])
         {
           (void) fputs(batch_options.prompt, stdout);
           (void) fflush(stdout);
@@ -1614,7 +1627,7 @@
           result = MagickPass;
           break;
         };
-      if (batch_options.is_echo_enabled)
+      if (batch_options.is_tap_mode || batch_options.is_echo_enabled)
         {
           int i;
           for (i = 1; i < ac; i++)
@@ -1641,8 +1654,14 @@
                            MAX_PARAM);
           result = MagickFail;
         }
-
-      if (batch_options.is_feedback_enabled)
+      ++line_no;
+
+      if (batch_options.is_tap_mode)
+        {
+          /* FIXME: Support TAP test description */
+          (void) fprintf(stdout, "%s %u\n", result ? "ok" : "not ok", line_no);
+        }
+      else if (batch_options.is_feedback_enabled)
         {
           (void) fputs(result ? batch_options.pass : batch_options.fail, stdout);
           (void) fputc('\n', stdout);
@@ -1654,7 +1673,7 @@
         break;
     }
 
-  if (batch_options.prompt[0])
+  if (!batch_options.is_tap_mode && batch_options.prompt[0])
     {
       (void) fputs("\n", stdout);
       (void) fflush(stdout);
@@ -1702,6 +1721,12 @@
          "  -stop-on-error on|off\n"
          "                       when turned on, batch execution quits prematurely when\n"
          "                       any command returns error\n"
+         "  -tap-mode on|off\n"
+         "                       when turned on, a simple implementation of Test Anything\n"
+         "                       Protocol (TAP) is enabled to produce \"ok N\" and \n"
+         "                       \"not ok N\" feedback to indicate the test number, and to\n"
+         "                       supplant the function of -fail, -pass, -feedback in order\n"
+         "                       to support simple TAP output messaging\n"
          "\n"
          "Unix escape allows the use backslash(\\), single quote(') and double quote(\") in\n"
          "the command line. Windows escape only uses double quote(\").  For example,\n"
@@ -16749,6 +16774,10 @@
           if (LocaleCompare(option = "-stop-on-error", p) == 0)
             status = GetOnOffOptionValue(option, argv[++i], &options->stop_on_error);
           break;
+        case 't':
+          if (LocaleCompare(option = "-tap-mode", p) == 0)
+            status = GetOnOffOptionValue(option, argv[++i], &options->is_tap_mode);
+          break;
         }
       if (status == OptionSuccess)
         continue;
@@ -16825,6 +16854,8 @@
   printf("stop-on-error : %s\n", on_off_option_values[batch_options.stop_on_error]);
   printf("pass          : %s\n", batch_options.pass);
   printf("prompt        : %s\n", batch_options.prompt);
+  printf("tap-mode      : %s\n", on_off_option_values[batch_options.is_tap_mode]);
+
   return MagickTrue;
 }
 
diff -r 1eeb539e61c5 -r 5bef7aeb196d magick/version.h
--- a/magick/version.h	Sun Apr 16 14:27:04 2023 -0500
+++ b/magick/version.h	Wed Apr 19 08:15:38 2023 -0500
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x272402
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 27,24,2
-#define MagickChangeDate   "20230416"
-#define MagickReleaseDate  "snapshot-20230416"
+#define MagickChangeDate   "20230419"
+#define MagickReleaseDate  "snapshot-20230419"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 1eeb539e61c5 -r 5bef7aeb196d utilities/tests/convert-batch.tap
--- a/utilities/tests/convert-batch.tap	Sun Apr 16 14:27:04 2023 -0500
+++ b/utilities/tests/convert-batch.tap	Wed Apr 19 08:15:38 2023 -0500
@@ -22,4 +22,4 @@
     subcommande1=$(printf '%s' "${subcommand}" | sed "s/'/\\\'/g")
     printf "convert identity:10 -comment \"%s\" %s -format '%s' info:-\n" "${subcommand}" "${subcommand}" '%r %g %# %c'
     #set +x
-done | gm batch -echo on -prompt off -feedback on -pass PASS -fail FAIL
+done | gm batch -tap-mode on -prompt '# '  #-echo on -prompt off -feedback on -pass PASS -fail FAIL
diff -r 1eeb539e61c5 -r 5bef7aeb196d www/Changelog.html
--- a/www/Changelog.html	Sun Apr 16 14:27:04 2023 -0500
+++ b/www/Changelog.html	Wed Apr 19 08:15:38 2023 -0500
@@ -37,6 +37,15 @@
 </div>
 
 <div class="document">
+<p>2023-04-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><p>magick/command.c (BatchCommand): Implement simple Test Anything
+Protocol (TAP) test counting and &quot;ok N&quot;/&quot;not ok N&quot; messaging for
+'gm batch' via the '-tap-mode on' option.  This is still a work in
+progress, but is already useful.</p></li>
+</ul>
+</blockquote>
 <p>2023-04-16  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.