When running gnulib-tool.py --create-megatestdirs:

Traceback (most recent call last):
  File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 1209, in <module>
    main()
  File "/home/collin/.local/src/gnulib/pygnulib/main.py", line 959, in main
    testdir.execute()
  File "/home/collin/.local/src/gnulib/pygnulib/GLTestDir.py", line 980, in 
execute
    emit += 'AC_CONFIG_SUBDIRS([%s])\n' % ' '.megasubdirs
                                          ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'megasubdirs'

This is because megasubdirs is a list. The correct call should be
' '.join(megasubdirs). Other than that there were a few more issues
with --create-megatestdir.

The calls the create the individual testdirs were commented out. Once
the were uncommented, I had to join the megatestdir with the module
name to create a subdirectory. Then the 'configure.ac' file was being
printed to 'Makefile.am'. Lastly, the calls to aclocal, automake, etc.
were being called from the wrong directory.

I've attached a patch that fixes all of these so --create-megatestdir
should work properly now.

Collin
From ac8654c35c8b6ee49106d5e120839407ae47ffe0 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 7 Mar 2024 03:11:55 -0800
Subject: [PATCH 3/3] gnulib-tool.py: Fix errors when executing
 --create-megatestdir.

* pygnulib/GLTestDir.py (GLMegaTestDir.execute): Create a testdir for
each module in its own subdirectory. Create a testdir with all modules
in 'ALL'. Add missing join call on str object. Don't emit 'configure.ac'
into 'Makefile.am'. Make sure commands are executed in the proper
directory.
---
 ChangeLog             |  9 +++++++++
 pygnulib/GLTestDir.py | 11 ++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e429687622..fb199ddeba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-03-07  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Fix errors when executing --create-megatestdir.
+	* pygnulib/GLTestDir.py (GLMegaTestDir.execute): Create a testdir for
+	each module in its own subdirectory. Create a testdir with all modules
+	in 'ALL'. Add missing join call on str object. Don't emit 'configure.ac'
+	into 'Makefile.am'. Make sure commands are executed in the proper
+	directory.
+
 2024-03-06  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 46.
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 296356bd91..8a3072ea09 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -894,7 +894,7 @@ class GLMegaTestDir(object):
         # First, all modules one by one.
         for module in modules:
             self.config.setModules([str(module)])
-            #GLTestDir(self.config, self.megatestdir).execute()
+            GLTestDir(self.config, joinpath(self.megatestdir, str(module))).execute()
             megasubdirs += [str(module)]
 
         # Then, all modules all together.
@@ -904,7 +904,7 @@ class GLMegaTestDir(object):
                     if str(module) != 'config-h' ]
         self.config.setModules([ str(module)
                                  for module in modules ])
-        #GLTestDir(self.config, self.megatestdir).execute()
+        GLTestDir(self.config, joinpath(self.megatestdir, 'ALL')).execute()
         megasubdirs += ['ALL']
 
         # Create autobuild.
@@ -977,16 +977,16 @@ class GLMegaTestDir(object):
             emit += 'AC_CONFIG_AUX_DIR([%s])\n' % auxdir
         emit += 'AM_INIT_AUTOMAKE\n\n'
         emit += 'AC_PROG_MAKE_SET\n\n'
-        emit += 'AC_CONFIG_SUBDIRS([%s])\n' % ' '.megasubdirs
+        emit += 'AC_CONFIG_SUBDIRS([%s])\n' % ' '.join(megasubdirs)
         emit += 'AC_CONFIG_FILES([Makefile])\n'
         emit += 'AC_OUTPUT\n'
         emit = constants.nlconvert(emit)
-        path = joinpath(self.megatestdir, 'Makefile.am')
+        path = joinpath(self.megatestdir, 'configure.ac')
         with codecs.open(path, 'wb', 'UTF-8') as file:
             file.write(emit)
 
         # Create autogenerated files.
-        os.chdir(DIRS['cwd'])
+        os.chdir(self.megatestdir)
         args = [UTILS['aclocal']]
         constants.execute(args, verbose)
         try:  # Try to make a directory
@@ -999,4 +999,5 @@ class GLMegaTestDir(object):
         args = [UTILS['automake'], '--add-missing', '--copy']
         constants.execute(args, verbose)
         shutil.rmtree('autom4te.cache')
+        os.chdir(DIRS['cwd'])
         sp.call(['rm', '-rf', self.config['tempdir']], shell=False)
-- 
2.44.0

Reply via email to