[Git][NTPsec/ntpsec][master] Revert "wafhelpers/bin_test.py: never set PYTHONPATH ..."
Hal Murray (@hal.murray)
gitlab at mg.gitlab.com
Tue Sep 2 21:25:21 UTC 2025
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
29a78cc0 by Hal Murray at 2025-09-02T14:00:21-07:00
Revert "wafhelpers/bin_test.py: never set PYTHONPATH ..."
This undoes the testing after install.
This reverts commit b4aa2029642fd673e9f821f527a5440704f238cb.
- - - - -
1 changed file:
- wafhelpers/bin_test.py
Changes:
=====================================
wafhelpers/bin_test.py
=====================================
@@ -2,15 +2,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
-"""Run a suite of tests on the listed binaries.
-
-| command | DESTDIR | value | tests |
-| === | === | === | === |
-| bin_test, build, check | n/a | False as TEST_BUILD | build/main |
-| install | no | True as TEST_INSTALL | $PREFIX/bin, $PREFIX/sbin |
-| install | yes | None as TEST_NO | nothing |
-| * | n/a | None as TEST_NO | nothing |
-"""
+"""Run a suite of tests on the listed binaries."""
from __future__ import print_function
import os
import os.path
@@ -25,9 +17,6 @@ NTPD = "main/ntpd"
NTPFROB = "main/ntpfrob"
NTPTIME = "main/ntptime"
POPEN = waflib.Utils.subprocess.Popen
-TEST_BUILD = 0
-TEST_NO = 1
-TEST_INSTALL = 2
test_logs = []
@@ -43,7 +32,7 @@ def bin_test_summary(_ctx):
waflib.Logs.pprint(i[0], i[1])
-def run(cmd, expected):
+def run(cmd, expected, python=None):
"""Run an individual test."""
prefix = "running: " + " ".join(cmd)
@@ -51,7 +40,11 @@ def run(cmd, expected):
addLog("YELLOW", prefix + " SKIPPING (does not exist)")
return None
- p = POPEN(cmd, env={"PATH": os.environ["PATH"]},
+ if python:
+ cmd = [python[0]] + list(cmd)
+ p = POPEN(cmd, env={'PATH': os.environ['PATH'],
+ 'PYTHONPATH': '%s/main/tests/pylib' %
+ waflib.Context.out_dir},
universal_newlines=True,
stdin=waflib.Utils.subprocess.PIPE,
stdout=waflib.Utils.subprocess.PIPE,
@@ -72,35 +65,11 @@ def run(cmd, expected):
return False
-def do_we_test(ctx):
- """Evaluate if we should test and how."""
- if ctx.cmd in ["build", "check", "bin_test"]:
- return TEST_BUILD
- if ctx.cmd == "install":
- if bool(waflib.Options.options.destdir):
- waflib.Logs.pprint(
- "YELLOW", "bin_test disabled in DESTDIR installs."
- )
- return TEST_NO
- return TEST_INSTALL
- if "uninstall" == ctx.cmd:
- return TEST_NO
- # Probably add more cases here...
- waflib.Logs.pprint(
- "RED", "Please report that bin_test is broken for `./waf %s`!"
- % ctx.cmd
- )
- sys.exit(1)
-
-
-def etl_cases(ctx, version, params):
+def etl_cases(installed, version, params):
"""Convert cmd_list_* to run() arguments."""
ret = []
- installed = do_we_test(ctx)
- if installed is TEST_NO:
- return []
for dest_dir, bld_dir, name, flag in params:
- if installed != TEST_INSTALL:
+ if not installed:
prefix = waflib.Context.out_dir + os.sep + bld_dir
else:
prefix = waflib.Options.options.destdir + dest_dir
@@ -148,11 +117,12 @@ def cmd_bin_test(ctx):
if ctx.env['PYTHON_CURSES']:
cmd_list_python += cmd_list_python_curses
- for cmd in etl_cases(ctx, version, cmd_list):
+ INSTALL = bool('install' == ctx.cmd)
+ for cmd in etl_cases(INSTALL, version, cmd_list):
rets.append(run(cmd[0], cmd[1]))
if 'none' != ctx.env['ntpc']:
- for cmd in etl_cases(ctx, version, cmd_list_python):
- rets.append(run(cmd[0], cmd[1]))
+ 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."""
@@ -160,13 +130,10 @@ def cmd_bin_test(ctx):
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)
if skips:
waflib.Logs.pprint('YELLOW', "%d binary test%s skipped!"
% test_s(skips))
if fails:
- # on failure print number of failed tests and the summary
- waflib.Logs.pprint(
- "RED", "%d binary test%s failed!" % test_s(fails)
- )
- bin_test_summary(ctx)
- sys.exit(1)
+ ctx.fatal("%d binary test%s failed!" % test_s(fails))
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/29a78cc01fc71c3cf6cdd8862ce9d28d9769839b
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/29a78cc01fc71c3cf6cdd8862ce9d28d9769839b
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/20250902/9c6f0c3a/attachment-0001.htm>
More information about the vc
mailing list