From: Bruno Haible Date: Fri, 22 Mar 2024 15:10:29 +0000 (+0100) Subject: gnulib-tool: Remove test-driver.{orig,rej} if patching succeeded. X-Git-Tag: v1.0~254 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d384d69e136163af075dbe277865e7202b20390d;p=gnulib.git gnulib-tool: Remove test-driver.{orig,rej} if patching succeeded. * gnulib-tool.sh (func_create_testdir, func_create_megatestdir): After a 'patch' command failed, remove the leftover files test-driver.orig and test-driver.rej. * pygnulib/GLTestDir.py (_patch_test_driver): Likewise. --- diff --git a/ChangeLog b/ChangeLog index dfe91dbc36..ed61c774d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-03-22 Bruno Haible + + gnulib-tool: Remove test-driver.{orig,rej} if patching succeeded. + * gnulib-tool.sh (func_create_testdir, func_create_megatestdir): After + a 'patch' command failed, remove the leftover files test-driver.orig and + test-driver.rej. + * pygnulib/GLTestDir.py (_patch_test_driver): Likewise. + 2024-03-22 Bruno Haible gnulib-tool.py: Fix an error in --create-testdir. diff --git a/gnulib-tool.sh b/gnulib-tool.sh index d5bbd06f3e..da879cb01a 100755 --- a/gnulib-tool.sh +++ b/gnulib-tool.sh @@ -7072,8 +7072,12 @@ func_create_testdir () (cd "$testdir" if test -f build-aux/test-driver; then patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff \ - || patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff \ - || func_exit 1 + || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej + patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff \ + || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej + func_exit 1 + } + } fi ) || func_exit 1 } @@ -7179,8 +7183,12 @@ func_create_megatestdir () rm -rf autom4te.cache if test -f build-aux/test-driver; then patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff \ - || patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff \ - || func_exit 1 + || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej + patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff \ + || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej + func_exit 1 + } + } fi ) || func_exit 1 } diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index f85a5f6dbb..ea16d808a3 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -72,10 +72,18 @@ def _patch_test_driver() -> None: try: result = sp.call(command, shell=True) except OSError: + if isfile(f'{test_driver}.orig'): + os.remove(f'{test_driver}.orig') + if isfile(f'{test_driver}.rej'): + os.remove(f'{test_driver}.rej') raise GLError(20, None) if result == 0: patched = True break + if isfile(f'{test_driver}.orig'): + os.remove(f'{test_driver}.orig') + if isfile(f'{test_driver}.rej'): + os.remove(f'{test_driver}.rej') if not patched: raise GLError(20, None)