[Git][NTPsec/ntpsec][master] bin_test: Fix new perceived shortcomings.

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Fri Feb 14 05:22:50 UTC 2025


Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
4fc612bb by James Browning at 2025-02-14T05:19:10+00:00
bin_test: Fix new perceived shortcomings.

- - - - -


1 changed file:

- wafhelpers/bin_test.py


Changes:

=====================================
wafhelpers/bin_test.py
=====================================
@@ -6,6 +6,7 @@
 from __future__ import print_function
 import os
 import os.path
+import sys
 import waflib.Context
 import waflib.Logs
 import waflib.Utils
@@ -40,7 +41,7 @@ def run(cmd, expected, python=None):
         return None
 
     if python:
-        cmd = python + list(cmd)
+        cmd = [python[0]] + list(cmd)
     p = POPEN(cmd, env={'PYTHONPATH': '%s/main/tests/pylib' %
                         waflib.Context.out_dir},
               universal_newlines=True,
@@ -80,8 +81,7 @@ def cmd_bin_test(ctx):
     """Run a suite of binary tests."""
     BIN = ctx.env.BINDIR
     SBIN = ctx.env.SBINDIR
-    skips = 0
-    fails = 0
+    rets = []
 
     cmd_list = [
         (BIN, NTPCLIENTS, "ntpleapfetch", "--version"),
@@ -98,11 +98,14 @@ def cmd_bin_test(ctx):
         (BIN, NTPCLIENTS, "ntptrace", "--version"),
         (BIN, NTPCLIENTS, "ntpwait", "--version"),
     ]
-    cmd_list_python_argparse = [  # Need argparse
+    cmd_list_python_argparse = [  # Needs argparse
         (BIN, NTPCLIENTS, "ntplogtemp", "--version"),
         (BIN, NTPCLIENTS, "ntpviz", "--version"),
     ]
-    cmd_list_python_curses = [  # Need python curses
+    cmd_list_python_gps = [  # Needs argparse & gps
+        (BIN, NTPCLIENTS, "ntploggps", "--version"),
+    ]
+    cmd_list_python_curses = [  # Needs python curses
         (BIN, NTPCLIENTS, "ntpmon", "--version"),
     ]
 
@@ -110,34 +113,30 @@ def cmd_bin_test(ctx):
         version = fp.read().strip()
 
     if ctx.env['PYTHON_ARGPARSE']:
+        if ctx.env['PYTHON_GPS']:
+            cmd_list_python += cmd_list_python_gps
         cmd_list_python += cmd_list_python_argparse
 
     if ctx.env['PYTHON_CURSES']:
         cmd_list_python += cmd_list_python_curses
 
-    INSTALL = False
-    if 'install' == ctx.cmd:
-        cmd_list += cmd_list_python
-        cmd_list_python = []
-        INSTALL = True
-
+    INSTALL = bool('install' == ctx.cmd)
     for cmd in etl_cases(INSTALL, version, cmd_list):
-        ret = run(cmd[0], cmd[1])
-        if ret is True:
-            pass
-        elif ret is None:
-            skips += 1
-        elif ret is False:
-            fails += 1
-
-    if 1 == skips:
-        waflib.Logs.pprint("YELLOW", "Skipped one binary test.")
-    elif 1 < skips:
-        waflib.Logs.pprint("YELLOW", "Skipped %d binary tests." % skips)
-
-    if 1 == fails:
-        bin_test_summary(ctx)
-        ctx.fatal("Failed one binary test!")
-    elif 1 < fails:
+        rets.append(run(cmd[0], cmd[1]))
+    if 'none' != ctx.env['ntpc']:
+        for cmd in etl_cases(INSTALL, version, cmd_list_python):
+            rets.append(run(cmd[0], cmd[1], ctx.env['PYTHON']))
+
+    def test_s(number):
+        """Return values for string formatting."""
+        return number, '' if 1 == number else 's'
+
+    skips = sum(int(None is i) for i in rets)
+    fails = sum(int(False is i) for i in rets)
+    if fails:
         bin_test_summary(ctx)
-        ctx.fatal("Failed %d binary tests!" % fails)
+    if skips:
+        waflib.Logs.pprint('YELLOW', "%d binary test%s skipped!"
+                           % test_s(skips))
+    if fails:
+        ctx.fatal("%d binary test%s failed!" % test_s(fails))



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/4fc612bbd2efe63e03c5ba53339382378d87d1cd

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/4fc612bbd2efe63e03c5ba53339382378d87d1cd
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20250214/f3c63c1e/attachment-0001.htm>


More information about the vc mailing list