]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Remove test-driver.{orig,rej} if patching succeeded.
authorBruno Haible <bruno@clisp.org>
Fri, 22 Mar 2024 15:10:29 +0000 (16:10 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 22 Mar 2024 15:10:29 +0000 (16:10 +0100)
* 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.

ChangeLog
gnulib-tool.sh
pygnulib/GLTestDir.py

index dfe91dbc369f43543463bf59eb2b8b33fce42e5f..ed61c774d144b6006c871706f6d76e66e0c217b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-03-22  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        gnulib-tool.py: Fix an error in --create-testdir.
index d5bbd06f3ee0274b7fa5364bc23bfa80735e9527..da879cb01a8b05fe6d7ce56a809cf6e5078ecf2e 100755 (executable)
@@ -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
 }
index f85a5f6dbb3d239b8bb6c9be61d53b0b39121464..ea16d808a39cc9ca912b40e64bed8ceba29c8fe3 100644 (file)
@@ -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)