bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool: Remove test-driver.{orig,rej} if patching succeeded


From: Bruno Haible
Subject: gnulib-tool: Remove test-driver.{orig,rej} if patching succeeded
Date: Fri, 22 Mar 2024 16:14:51 +0100

When running "gnulib-tool --create-testdir ..." with Automake 1.16.3 in $PATH,
two files build-aux/test-driver.orig and build-aux/test-driver.rej are created
in the destination directory. This is not useful, because
  - the second 'patch' command succeeded,
  - the user is not interested in debugging a failed 'patch' command here anyway
    (only Gnulib developers are).

So, this patch removes them. Making the results with Automake 1.16.3 and 1.16.5
more similar.


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.

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)
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]