+2024-05-13 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Don't continue creating testdirs when destdir exists.
+ * pygnulib/GLError.py (GLError.__init__, GLError.__repr__): Add a new
+ error number for destination directories that already exist.
+ * pygnulib/main.py (main_with_exception_handling): Print the message.
+ * pygnulib/GLTestDir.py (GLTestDir.__init__, GLMegaTestdir.__init__):
+ Fail if the destination directory exists instead of creating files and
+ failing to patch test driver.
+
2024-05-13 Paul Eggert <eggert@cs.ucla.edu>
stdbit: redo clzll without lookcup table
19: could not create destination directory: <directory>
20: could not patch test-driver script
21: Option --automake-subdir is only supported if the definition of AUTOMAKE_OPTIONS in Makefile.am contains 'subdir-objects'.
+ 22: not overwriting destination directory: <directory>
errinfo: additional information'''
self.errno = errno
self.errinfo = errinfo
message = ('Option --automake-subdir/--automake-subdir-tests are only '
'supported if the definition of AUTOMAKE_OPTIONS in '
'Makefile.am contains \'subdir-objects\'.')
+ elif errno == 22:
+ message = 'not overwriting destination directory: %s' % repr(errinfo)
self.message = '[Errno %d] %s' % (errno, message)
return self.message
% type(testdir).__name__)
self.config = config
self.testdir = os.path.normpath(testdir)
- if not os.path.exists(self.testdir):
- try: # Try to create directory
- os.mkdir(self.testdir)
- except Exception as exc:
- raise GLError(19, self.testdir) from exc
+ # Don't overwrite the directory.
+ if os.path.exists(self.testdir):
+ raise GLError(22, self.testdir)
+ # Try to create directory.
+ try:
+ os.mkdir(self.testdir)
+ except Exception as exc:
+ raise GLError(19, self.testdir) from exc
self.emitter = GLEmiter(self.config)
self.filesystem = GLFileSystem(self.config)
self.modulesystem = GLModuleSystem(self.config)
% type(megatestdir).__name__)
self.config = config
self.megatestdir = os.path.normpath(megatestdir)
- if not os.path.exists(self.megatestdir):
- try: # Try to create directory
- os.mkdir(self.megatestdir)
- except Exception as exc:
- raise GLError(19, self.megatestdir) from exc
+ # Don't overwrite the directory.
+ if os.path.exists(self.megatestdir):
+ raise GLError(22, self.megatestdir)
+ # Try to create directory.
+ try:
+ os.mkdir(self.megatestdir)
+ except Exception as exc:
+ raise GLError(19, self.megatestdir) from exc
self.modulesystem = GLModuleSystem(self.config)
def execute(self) -> None:
message += ('Option --automake-subdir/--automake-subdir-tests are only '
'supported if the definition of AUTOMAKE_OPTIONS in '
'Makefile.am contains \'subdir-objects\'.')
+ elif errno == 22:
+ message = 'not overwriting destination directory: %s' % errinfo
message += '\n%s: *** Stop.\n' % APP['name']
sys.stderr.write(message)
sys.exit(1)