Hi Collin, > I've pushed the attached patch. In gnulib-tool.sh the following is > done: > > ../configure || func_exit 1 > $MAKE || func_exit 1 > [...] > > So here we can just use sp.run([command, arg], check=True) and exit if > an exception occurs.
Thanks. I confirm that --test now behaves as expected. But --megatest has the same problem. It was apparently overlooked in commit 42a01df09d7f13f15a54e0c4b09d121c5bf7ac66, in 2006. The default should be to reflect errors in the exit code. If a user wants to ignore the build errors, they can 'cd' into the directory and run "make -k" or "make -k check". Done through the patch below. > As a side note, gradually I'll start changing sp.call(), > sp.check_call(), etc. to sp.run(). Under the hood they all call the > same internal functions, but the latter is newer and "recommended" > [1]. > > I always forget how that module works and just using the recommended > sp.run() makes scanning the documentation easier. > > [1] > https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module Sounds good. 2024-05-08 Bruno Haible <br...@clisp.org> gnulib-tool: In --megatestdir mode, stop when there is an error. * gnulib-tool.sh (megatest): Fail when one of the 'configure' or 'make' steps fails. * pygnulib/main.py (main): Likewise. diff --git a/gnulib-tool.sh b/gnulib-tool.sh index 521d16e47a..b5aadcaeaa 100755 --- a/gnulib-tool.sh +++ b/gnulib-tool.sh @@ -7501,10 +7501,10 @@ s/\([.*$]\)/[\1]/g' cd "$destdir" mkdir build cd build - ../configure - $MAKE - $MAKE check - $MAKE distclean + ../configure || func_exit 1 + $MAKE || func_exit 1 + $MAKE check || func_exit 1 + $MAKE distclean || func_exit 1 remaining=`find . -type f -print` if test -n "$remaining"; then echo "Remaining files:" $remaining 1>&2 diff --git a/pygnulib/main.py b/pygnulib/main.py index 128f25f9c1..8462916653 100644 --- a/pygnulib/main.py +++ b/pygnulib/main.py @@ -1130,10 +1130,13 @@ def main(temp_directory: str) -> None: os.chdir(destdir) os.mkdir('build') os.chdir('build') - sp.call(['../configure']) - sp.call([UTILS['make']]) - sp.call([UTILS['make'], 'check']) - sp.call([UTILS['make'], 'distclean']) + try: # Try to execute commands + sp.run(['../configure'], check=True) + sp.run([UTILS['make']], check=True) + sp.run([UTILS['make'], 'check'], check=True) + sp.run([UTILS['make'], 'distclean'], check=True) + except Exception: + sys.exit(1) args = ['find', '.', '-type', 'f', '-print'] remaining = sp.check_output(args).decode(ENCS['shell']) lines = [ line.strip()