diff options
author | Bruno Haible <bruno@clisp.org> | 2022-08-03 22:29:52 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-08-04 01:51:24 +0200 |
commit | de028fc3637de15c3c0535e168bc5dda6a6084e6 (patch) | |
tree | ce2c1cbe871a38f016fa8bec573a19e24cd37550 /pygnulib | |
parent | 1e57719d520683d08e8646fb2b778aa9d9afb294 (diff) | |
download | gnulib-de028fc3637de15c3c0535e168bc5dda6a6084e6.tar.gz |
gnulib-tool.py: Implement options --without-c++-tests etc.
* gnulib-tool.py (main): Accept options --without-c++-tests,
--without-longrunning-tests, --without-privileged-tests,
--without-unportable-tests.
Improve error message for --copy-file with invalid number of arguments.
Check for invalid options given in --import, --add-import,
--remove-import, --update modes.
Pass both sets of test categories to the GLConfig constructor.
* pygnulib/GLConfig.py (GLConfig.__init__): Accept incl_test_categories
and excl_test_categories instead of testflags.
(checkInclTestCategory): Renamed from checkTestFlag.
(enableInclTestCategory): Renamed from enableTestFlag.
(disableInclTestCategory): Renamed from disableTestFlag.
(getInclTestCategories): Renamed from getTestFlags.
(setInclTestCategories): Renamed from setTestFlags.
(resetInclTestCategories): Renamed from resetTestFlags.
(setInclTestCategory, checkExclTestCategory, enableExclTestCategory,
disableExclTestCategory, getExclTestCategories, setExclTestCategories,
resetExclTestCategories): New methods.
* pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Accept two
booleans as second and third constructor arguments.
(transitive_closure): Correct the determination of whether to include
each module, depending on the with-* and without-* options.
(transitive_closure_separately): Update.
* pygnulib/GLMakefileTable.py: Update.
* pygnulib/GLImport.py (__init__, actioncmd, gnulib_cache, execute):
Update.
* pygnulib/GLTestDir.py (GLTestDir.__init__, GLTestDir.execute,
GLMegaTestDir.__init__): Update.
Diffstat (limited to 'pygnulib')
-rw-r--r-- | pygnulib/GLConfig.py | 159 | ||||
-rw-r--r-- | pygnulib/GLImport.py | 59 | ||||
-rw-r--r-- | pygnulib/GLMakefileTable.py | 5 | ||||
-rw-r--r-- | pygnulib/GLModuleSystem.py | 106 | ||||
-rw-r--r-- | pygnulib/GLTestDir.py | 17 | ||||
-rw-r--r-- | pygnulib/constants.py | 2 |
6 files changed, 206 insertions, 142 deletions
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py index f59b883a91..37b30753ea 100644 --- a/pygnulib/GLConfig.py +++ b/pygnulib/GLConfig.py @@ -58,7 +58,8 @@ class GLConfig(object): def __init__(self, destdir=None, localpath=None, auxdir=None, sourcebase=None, m4base=None, pobase=None, docbase=None, testsbase=None, - modules=None, avoids=None, files=None, testflags=None, libname=None, + modules=None, avoids=None, files=None, + incl_test_categories=None, excl_test_categories=None, libname=None, lgpl=None, makefile=None, libtool=None, conddeps=None, macro_prefix=None, podomain=None, witness_c_macro=None, vc_files=None, symbolic=None, lsymbolic=None, modcache=None, configure_ac=None, ac_version=None, @@ -117,10 +118,14 @@ class GLConfig(object): self.resetFiles() if files != None: self.setFiles(files) - # testflags - self.resetTestFlags() - if testflags != None: - self.setTestFlags(testflags) + # test categories to include + self.resetInclTestCategories + if incl_test_categories != None: + self.setInclTestCategories(incl_test_categories) + # test categories to exclude + self.resetExclTestCategories + if excl_test_categories != None: + self.setExclTestCategories(excl_test_categories) # libname self.resetLibName() if libname != None: @@ -351,7 +356,7 @@ class GLConfig(object): return 0 elif key == 'copyrights': return True - elif key in ['modules', 'avoids', 'tests', 'testflags']: + elif key in ['modules', 'avoids', 'tests', 'incl_test_categories', 'excl_test_categories']: return list() elif key in ['libtool', 'lgpl', 'conddeps', 'modcache', 'symbolic', 'lsymbolic', 'libtests', 'dryrun']: @@ -681,52 +686,104 @@ class GLConfig(object): '''Reset the list of files.''' self.table['files'] = list() - # Define tests/testflags methods - def checkTestFlag(self, flag): - '''Return the status of the test flag.''' - if flag in TESTS.values(): - return flag in self.table['testflags'] - else: # if flag is not in TESTS - raise TypeError('unknown flag: %s' % repr(flag)) - - def enableTestFlag(self, flag): - '''Enable test flag. You can get flags from TESTS variable.''' - if flag in TESTS.values(): - if flag not in self.table['testflags']: - self.table['testflags'].append(flag) - else: # if flag is not in TESTS - raise TypeError('unknown flag: %s' % repr(flag)) - - def disableTestFlag(self, flag): - '''Disable test flag. You can get flags from TESTS variable.''' - if flag in TESTS.values(): - if flag in self.table['testflags']: - self.table['testflags'].remove(flag) - else: # if flag is not in TESTS - raise TypeError('unknown flag: %s' % repr(flag)) - - def getTestFlags(self): - '''Return test flags. You can get flags from TESTS variable.''' - return list(self.table['testflags']) - - def setTestFlags(self, testflags): - '''Specify test flags. You can get flags from TESTS variable.''' - if type(testflags) is list or type(testflags) is tuple: - self.table['testflags'] = list() - for flag in testflags: - try: # Try to enable each flag - self.enableTestFlag(flag) + # Define incl_test_categories methods + def checkInclTestCategory(self, category): + '''Tests whether the given test category is included.''' + if category in TESTS.values(): + return category in self.table['incl_test_categories'] + else: # if category is not in TESTS + raise TypeError('unknown category: %s' % repr(category)) + + def enableInclTestCategory(self, category): + '''Enable the given test category.''' + if category in TESTS.values(): + if category not in self.table['incl_test_categories']: + self.table['incl_test_categories'].append(category) + else: # if category is not in TESTS + raise TypeError('unknown category: %s' % repr(category)) + + def disableInclTestCategory(self, category): + '''Disable the given test category.''' + if category in TESTS.values(): + if category in self.table['incl_test_categories']: + self.table['incl_test_categories'].remove(category) + else: # if category is not in TESTS + raise TypeError('unknown category: %s' % repr(category)) + + def setInclTestCategory(self, category, enable): + '''Enable or disable the given test category.''' + if (enable): + self.enableInclTestCategory(category) + else: + self.disableInclTestCategory(category) + + def getInclTestCategories(self): + '''Return the test categories that should be included. + To get the list of all test categories, use the TESTS variable.''' + return list(self.table['incl_test_categories']) + + def setInclTestCategories(self, categories): + '''Specify the test categories that should be included.''' + if type(categories) is list or type(categories) is tuple: + self.table['incl_test_categories'] = list() + for category in categories: + try: # Try to enable each category + self.enableInclTestCategory(category) + except TypeError as error: + raise TypeError('each category must be one of TESTS integers') + else: # if type of categories is not list or tuple + raise TypeError('categories must be a list or a tuple, not %s' % + type(categories).__name__) + + def resetInclTestCategories(self): + '''Reset test categories.''' + self.table['incl_test_categories'] = list() + + # Define excl_test_categories methods + def checkExclTestCategory(self, category): + '''Tests whether the given test category is excluded.''' + if category in TESTS.values(): + return category in self.table['excl_test_categories'] + else: # if category is not in TESTS + raise TypeError('unknown category: %s' % repr(category)) + + def enableExclTestCategory(self, category): + '''Enable the given test category.''' + if category in TESTS.values(): + if category not in self.table['excl_test_categories']: + self.table['excl_test_categories'].append(category) + else: # if category is not in TESTS + raise TypeError('unknown category: %s' % repr(category)) + + def disableExclTestCategory(self, category): + '''Disable the given test category.''' + if category in TESTS.values(): + if category in self.table['excl_test_categories']: + self.table['excl_test_categories'].remove(category) + else: # if category is not in TESTS + raise TypeError('unknown category: %s' % repr(category)) + + def getExclTestCategories(self): + '''Return the test categories that should be excluded. + To get the list of all test categories, use the TESTS variable.''' + return list(self.table['excl_test_categories']) + + def setExclTestCategories(self, categories): + '''Specify the test categories that should be excluded.''' + if type(categories) is list or type(categories) is tuple: + self.table['excl_test_categories'] = list() + for category in categories: + try: # Try to enable each category + self.enableExclTestCategory(category) except TypeError as error: - raise TypeError('each flag must be one of TESTS integers') - self.table['testflags'] = testflags - else: # if type of testflags is not list or tuple - raise TypeError('testflags must be a list or a tuple, not %s' % - type(testflags).__name__) - - def resetTestFlags(self): - '''Reset test flags (only default flag will be enabled).''' - self.table['testflags'] = list() - self.table['tests'] = self.table['testflags'] + raise TypeError('each category must be one of TESTS integers') + else: # if type of categories is not list or tuple + raise TypeError('categories must be a list or a tuple, not %s' % + type(categories).__name__) + + def resetExclTestCategories(self): + '''Reset test categories.''' + self.table['excl_test_categories'] = list() # Define libname methods. def getLibName(self): diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 04b3fddaab..58b8eaab9f 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -149,25 +149,25 @@ class GLImport(object): self.cache.enableVCFiles() data = data.replace('gl_VC_FILES', '') if 'gl_WITH_TESTS' in data: - self.cache.enableTestFlag(TESTS['tests']) + self.cache.enableInclTestCategory(TESTS['tests']) data = data.replace('gl_WITH_TESTS', '') if 'gl_WITH_OBSOLETE' in data: - self.cache.enableTestFlag(TESTS['obsolete']) + self.cache.enableInclTestCategory(TESTS['obsolete']) data = data.replace('gl_WITH_OBSOLETE', '') if 'gl_WITH_CXX_TESTS' in data: - self.cache.enableTestFlag(TESTS['c++-test']) + self.cache.enableInclTestCategory(TESTS['c++-test']) data = data.replace('gl_WITH_CXX_TESTS', '') if 'gl_WITH_LONGRUNNING_TESTS' in data: - self.cache.enableTestFlag(TESTS['longrunning-test']) + self.cache.enableInclTestCategory(TESTS['longrunning-test']) data = data.replace('gl_WITH_LONGRUNNING_TESTS', '') if 'gl_WITH_PRIVILEGED_TESTS' in data: - self.cache.enableTestFlag(TESTS['privileged-test']) + self.cache.enableInclTestCategory(TESTS['privileged-test']) data = data.replace('gl_WITH_PRIVILEGED_TESTS', '') if 'gl_WITH_UNPORTABLE_TESTS' in data: - self.cache.enableTestFlag(TESTS['unportable-test']) + self.cache.enableInclTestCategory(TESTS['unportable-test']) data = data.replace('gl_WITH_UNPORTABLE_TESTS', '') if 'gl_WITH_ALL_TESTS' in data: - self.cache.enableTestFlag(TESTS['all-test']) + self.cache.enableInclTestCategory(TESTS['all-test']) data = data.replace('gl_WITH_ALL_TESTS', '') # Find string values result = dict(pattern.findall(data)) @@ -244,8 +244,8 @@ class GLImport(object): elif self.mode == MODES['update']: modules = self.cache.getModules() - # If user tries to apply conddeps and testflag['tests'] together. - if self.config['tests'] and self.config['conddeps']: + # If user tries to apply conddeps and TESTS['tests'] together. + if self.checkInclTestCategory(TESTS['tests']) and self.config['conddeps']: raise GLError(10, None) # Update configuration dictionary. @@ -257,7 +257,7 @@ class GLImport(object): self.config.setModules(modules) # Check if conddeps is enabled together with inctests. - inctests = self.config.checkTestFlag(TESTS['tests']) + inctests = self.config.checkInclTestCategory(TESTS['tests']) if self.config['conddeps'] and inctests: raise GLError(10, None) @@ -265,7 +265,9 @@ class GLImport(object): self.emiter = GLEmiter(self.config) self.filesystem = GLFileSystem(self.config) self.modulesystem = GLModuleSystem(self.config) - self.moduletable = GLModuleTable(self.config, list()) + self.moduletable = GLModuleTable(self.config, + self.config.checkInclTestCategory(TESTS['all-tests']), + self.config.checkInclTestCategory(TESTS['all-tests'])) self.makefiletable = GLMakefileTable(self.config) def __repr__(self): @@ -366,7 +368,6 @@ class GLImport(object): docbase = self.config.getDocBase() pobase = self.config.getPoBase() testsbase = self.config.getTestsBase() - testflags = self.config.getTestFlags() conddeps = self.config.checkCondDeps() libname = self.config.getLibName() lgpl = self.config.getLGPL() @@ -391,19 +392,19 @@ class GLImport(object): actioncmd += ' --doc-base=%s' % docbase actioncmd += ' --tests-base=%s' % testsbase actioncmd += ' --aux-dir=%s' % auxdir - if self.config.checkTestFlag(TESTS['tests']): + if self.config.checkInclTestCategory(TESTS['tests']): actioncmd += ' --with-tests' - if self.config.checkTestFlag(TESTS['obsolete']): + if self.config.checkInclTestCategory(TESTS['obsolete']): actioncmd += ' --with-obsolete' - if self.config.checkTestFlag(TESTS['c++-test']): + if self.config.checkInclTestCategory(TESTS['c++-test']): actioncmd += ' --with-c++-tests' - if self.config.checkTestFlag(TESTS['longrunning-test']): + if self.config.checkInclTestCategory(TESTS['longrunning-test']): actioncmd += ' --with-longrunning-tests' - if self.config.checkTestFlag(TESTS['privileged-test']): + if self.config.checkInclTestCategory(TESTS['privileged-test']): actioncmd += ' --with-privileged-test' - if self.config.checkTestFlag(TESTS['unportable-test']): + if self.config.checkInclTestCategory(TESTS['unportable-test']): actioncmd += ' --with-unportable-tests' - if self.config.checkTestFlag(TESTS['all-test']): + if self.config.checkInclTestCategory(TESTS['all-test']): actioncmd += ' --with-all-tests' for module in avoids: actioncmd += ' --avoid=%s' % module @@ -478,7 +479,6 @@ class GLImport(object): moduletable = self.moduletable actioncmd = self.actioncmd() localpath = self.config['localpath'] - testflags = list(self.config['testflags']) sourcebase = self.config['sourcebase'] m4base = self.config['m4base'] pobase = self.config['pobase'] @@ -514,15 +514,15 @@ class GLImport(object): emit += 'gl_MODULES([\n' emit += ' %s\n' % '\n '.join(modules) emit += '])\n' - if self.config.checkTestFlag(TESTS['obsolete']): + if self.config.checkInclTestCategory(TESTS['obsolete']): emit += 'gl_WITH_OBSOLETE\n' - if self.config.checkTestFlag(TESTS['cxx-tests']): + if self.config.checkInclTestCategory(TESTS['cxx-tests']): emit += 'gl_WITH_CXX_TESTS\n' - if self.config.checkTestFlag(TESTS['privileged-tests']): + if self.config.checkInclTestCategory(TESTS['privileged-tests']): emit += 'gl_WITH_PRIVILEGED_TESTS\n' - if self.config.checkTestFlag(TESTS['unportable-tests']): + if self.config.checkInclTestCategory(TESTS['unportable-tests']): emit += 'gl_WITH_UNPORTABLE_TESTS\n' - if self.config.checkTestFlag(TESTS['all-tests']): + if self.config.checkInclTestCategory(TESTS['all-tests']): emit += 'gl_WITH_ALL_TESTS\n' emit += 'gl_AVOID([%s])\n' % ' '.join(avoids) emit += 'gl_SOURCE_BASE([%s])\n' % sourcebase @@ -530,7 +530,7 @@ class GLImport(object): emit += 'gl_PO_BASE([%s])\n' % pobase emit += 'gl_DOC_BASE([%s])\n' % docbase emit += 'gl_TESTS_BASE([%s])\n' % testsbase - if self.config.checkTestFlag(TESTS['tests']): + if self.config.checkInclTestCategory(TESTS['tests']): emit += 'gl_WITH_TESTS\n' emit += 'gl_LIB([%s])\n' % libname if lgpl != None: @@ -561,7 +561,6 @@ class GLImport(object): moduletable = self.moduletable destdir = self.config['destdir'] auxdir = self.config['auxdir'] - testflags = list(self.config['testflags']) sourcebase = self.config['sourcebase'] m4base = self.config['m4base'] pobase = self.config['pobase'] @@ -764,7 +763,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix auxdir = self.config['auxdir'] modules = list(self.config['modules']) avoids = list(self.config['avoids']) - testflags = list(self.config['testflags']) sourcebase = self.config['sourcebase'] m4base = self.config['m4base'] pobase = self.config['pobase'] @@ -1004,7 +1002,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix auxdir = self.config['auxdir'] modules = list(self.config['modules']) avoids = list(self.config['avoids']) - testflags = list(self.config['testflags']) sourcebase = self.config['sourcebase'] m4base = self.config['m4base'] pobase = self.config['pobase'] @@ -1122,7 +1119,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix pobase_dir = os.path.dirname(pobase) pobase_base = os.path.basename(pobase) self.makefiletable.editor(pobase_dir, 'SUBDIRS', pobase_base) - if self.config.checkTestFlag(TESTS['tests']): + if self.config.checkInclTestCategory(TESTS['tests']): if makefile_am == 'Makefile.am': testsbase_dir = os.path.dirname(testsbase) testsbase_base = os.path.basename(testsbase) @@ -1313,7 +1310,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix os.remove(tmpfile) # Create tests Makefile. - inctests = self.config.checkTestFlag(TESTS['tests']) + inctests = self.config.checkInclTestCategory(TESTS['tests']) if inctests: basename = joinpath(testsbase, makefile_am) tmpfile = self.assistant.tmpfilename(basename) diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py index 4ee85b4d0c..fdb15ac132 100644 --- a/pygnulib/GLMakefileTable.py +++ b/pygnulib/GLMakefileTable.py @@ -90,12 +90,13 @@ class GLMakefileTable(object): Add a special row to Makefile.am table with the first parent directory which contains or will contain Makefile.am file. - GLConfig: sourcebase, m4base, testsbase, testflags, makefile.''' + GLConfig: sourcebase, m4base, testsbase, incl_test_categories, + excl_test_categories, makefile.''' m4base = self.config['m4base'] sourcebase = self.config['sourcebase'] testsbase = self.config['testsbase'] makefile = self.config['makefile'] - inctests = self.config.checkTestFlag(TESTS['tests']) + inctests = self.config.checkInclTestCategory(TESTS['tests']) dir1 = '%s%s' % (m4base, os.path.sep) mfd = 'Makefile.am' if not makefile: diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 25c34f8756..7e4c6148e3 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -868,18 +868,23 @@ Include:|Link:|License:|Maintainer:)' class GLModuleTable(object): '''GLModuleTable is used to work with the list of the modules.''' - def __init__(self, config, avoids=list()): - '''GLModuleTable.__init__(config, avoids) -> GLModuleTable + def __init__(self, config, inc_all_direct_tests, inc_all_indirect_tests): + '''GLModuleTable.__init__(config, inc_all_direct_tests, inc_all_indirect_tests) -> GLModuleTable Create new GLModuleTable instance. If modules are specified, then add every module from iterable as unconditional module. If avoids is specified, then in transitive_closure every dependency which is in avoids won't be - included in the final modules list. If testflags iterable is enabled, then - don't add module which status is in the testflags. If conddeps are enabled, + included in the final modules list. If conddeps are enabled, then store condition for each dependency if it has a condition. The only necessary argument is localpath, which is needed just to create - modulesystem instance to look for dependencies.''' - self.avoids = list() # Avoids + modulesystem instance to look for dependencies. + inc_all_direct_tests = True if all kinds of problematic unit tests among + the unit tests of the specified modules + should be included + inc_all_indirect_tests = True if all kinds of problematic unit tests + among the unit tests of the dependencies + should be included + ''' self.dependers = dict() # Dependencies self.conditionals = dict() # Conditional modules self.unconditionals = dict() # Unconditional modules @@ -890,11 +895,16 @@ class GLModuleTable(object): if type(config) is not GLConfig: raise TypeError('config must be a GLConfig, not %s' % type(config).__name__) - for avoid in avoids: + self.config = config + if type(inc_all_direct_tests) is not bool: + raise TypeError('inc_all_direct_tests must be a bool, not %s' % + type(inc_all_direct_tests).__name__) + self.inc_all_direct_tests = inc_all_direct_tests + self.inc_all_indirect_tests = inc_all_indirect_tests + self.avoids = list() # Avoids + for avoid in self.avoids: if type(avoid) is not GLModule: raise TypeError('each avoid must be a GLModule instance') - self.avoids += [avoids] - self.config = config self.filesystem = GLFileSystem(self.config) self.modulesystem = GLModuleSystem(self.config) @@ -982,14 +992,16 @@ class GLModuleTable(object): Use transitive closure to add module and its dependencies. Add every module and its dependencies from modules list, but do not add dependencies - which contain in avoids list. If any testflag is enabled, then do not add - dependencies which have the status as this flag. If conddeps are enabled, + which contain in avoids list. If any incl_test_categories is enabled, then + add dependencies which are in these categories. If any excl_test_categories, + then do not add dependencies which are in these categories. If conddeps are enabled, then store condition for each dependency if it has a condition. This method is used to update final list of modules. Method returns list of modules. - GLConfig: testflags.''' + GLConfig: incl_test_categories, excl_test_categories.''' for module in modules: if type(module) is not GLModule: raise TypeError('each module must be a GLModule instance') + inc_all_tests = self.inc_all_direct_tests handledmodules = list() inmodules = modules outmodules = list() @@ -1011,7 +1023,7 @@ class GLModuleTable(object): dependencies = module.getDependencies() depmodules = [pair[0] for pair in dependencies] conditions = [pair[1] for pair in dependencies] - if TESTS['tests'] in self.config['testflags']: + if self.config.checkInclTestCategory(TESTS['tests']): testsname = module.getTestsName() if self.modulesystem.exists(testsname): testsmodule = self.modulesystem.find(testsname) @@ -1019,34 +1031,34 @@ class GLModuleTable(object): conditions += [None] for depmodule in depmodules: include = True - includes = list() status = depmodule.getStatus() for word in status: if word == 'obsolete': - if TESTS['obsolete'] in self.config['testflags'] or \ - TESTS['all-test'] in self.config['testflags']: - includes += [False] + if not self.config.checkInclTestCategory(TESTS['obsolete']): + include = False elif word == 'c++-test': - if TESTS['c++-test'] in self.config['testflags'] or \ - TESTS['all-test'] in self.config['testflags']: - includes += [False] + if self.config.checkExclTestCategory(TESTS['c++-test']): + include = False + if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['c++-test'])): + include = False elif word == 'longrunning-test': - if TESTS['longrunning-test'] in self.config['testflags'] or \ - TESTS['all-test'] in self.config['testflags']: - includes += [False] + if self.config.checkExclTestCategory(TESTS['longrunning-test']): + include = False + if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['longrunning-test'])): + include = False elif word == 'privileged-test': - if TESTS['privileged-test'] in self.config['testflags'] or \ - TESTS['all-test'] in self.config['testflags']: - includes += [False] - elif word == 'all-test': - if TESTS['all-test'] in self.config['testflags'] or \ - TESTS['all-test'] in self.config['testflags']: - includes += [False] - else: # if any other word - if word.endswith('-tests'): - if TESTS['all-test'] in self.config['testflags']: - includes += [False] - include = any(includes) + if self.config.checkExclTestCategory(TESTS['privileged-test']): + include = False + if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['privileged-test'])): + include = False + elif word == 'unportable-test': + if self.config.checkExclTestCategory(TESTS['unportable-test']): + include = False + if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['unportable-test'])): + include = False + elif word.endswith('-test'): + if not inc_all_tests: + include = False if include and depmodule not in self.avoids: inmodules += [depmodule] if self.config['conddeps']: @@ -1064,11 +1076,12 @@ class GLModuleTable(object): listing = list() # Create empty list inmodules = sorted(set(inmodules)) handledmodules = sorted(set(handledmodules + inmodules_this_round)) - inmodules = \ - [ # Begin to filter inmodules - module for module in inmodules if module not in handledmodules - ] # Finish to filter inmodules + # Remove handledmodules from inmodules. + inmodules = [module + for module in inmodules + if module not in handledmodules] inmodules = sorted(set(inmodules)) + inc_all_tests = self.inc_all_indirect_tests modules = sorted(set(outmodules)) self.modules = modules return list(modules) @@ -1090,28 +1103,21 @@ class GLModuleTable(object): list after previous transitive_closure. Method returns tuple which contains two lists: the list of main modules and the list of tests-related modules. Both lists contain dependencies. - GLConfig: testflags.''' - inctests = False - main_modules = list() - tests_modules = list() - if TESTS['tests'] in self.config['testflags']: - self.config['testflags'].pop(TESTS['tests']) - inctests = True + GLConfig: incl_test_categories, excl_test_categories.''' for module in basemodules: if type(module) is not GLModule: raise TypeError('each module must be a GLModule instance') for module in finalmodules: if type(module) is not GLModule: raise TypeError('each module must be a GLModule instance') + saved_inctests = self.config.checkInclTestCategory(TESTS['tests']) + self.config.disableInclTestCategory(TESTS['tests']) main_modules = self.transitive_closure(basemodules) + self.config.setInclTestCategory(TESTS['tests'], saved_inctests) tests_modules = \ [m for m in finalmodules if m not in main_modules] + \ [m for m in main_modules if m.getApplicability() != 'main'] tests_modules = sorted(set(tests_modules)) - if inctests: - testflags = sorted( - set(self.config['testflags'] + [TESTS['tests']])) - self.config.setTestFlags(testflags) result = tuple([main_modules, tests_modules]) return result diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index 29c3010ce0..cb75ba1eab 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -87,7 +87,9 @@ class GLTestDir(object): self.emiter = GLEmiter(self.config) self.filesystem = GLFileSystem(self.config) self.modulesystem = GLModuleSystem(self.config) - self.moduletable = GLModuleTable(self.config) + self.moduletable = GLModuleTable(self.config, + True, + self.config.checkInclTestCategory(TESTS['all-tests'])) self.assistant = GLFileAssistant(self.config) self.makefiletable = GLMakefileTable(self.config) @@ -147,7 +149,6 @@ class GLTestDir(object): Create a scratch package with the given modules.''' auxdir = self.config['auxdir'] - testflags = list(self.config['testflags']) sourcebase = self.config['sourcebase'] m4base = self.config['m4base'] pobase = self.config['pobase'] @@ -180,8 +181,8 @@ class GLTestDir(object): # When computing transitive closures, don't consider $module to depend on # $module-tests. Need this because tests are implicitly GPL and may depend # on GPL modules - therefore we don't want a warning in this case. - saved_testflags = list(self.config['testflags']) - self.config.disableTestFlag(TESTS['tests']) + saved_inctests = self.config.checkInclTestCategory(TESTS['tests']) + self.config.disableInclTestCategory(TESTS['tests']) for requested_module in base_modules: requested_licence = requested_module.getLicense() if requested_licence != 'GPL': @@ -213,7 +214,7 @@ class GLTestDir(object): if incompatible: errormsg = 'module %s depends on a module with an incompatible license: %s\n' % (requested_module, module) sys.stderr.write(errormsg) - self.config.setTestFlags(saved_testflags) + self.config.setInclTestCategory(TESTS['tests'], saved_inctests) # Determine final module list. modules = self.moduletable.transitive_closure(base_modules) @@ -389,7 +390,7 @@ class GLTestDir(object): subdirs_with_configure_ac = list() testsbase_appened = False - inctests = self.config.checkTestFlag(TESTS['tests']) + inctests = self.config.checkInclTestCategory(TESTS['tests']) if inctests: directory = joinpath(self.testdir, testsbase) if not isdir(directory): @@ -863,7 +864,9 @@ class GLMegaTestDir(object): self.emiter = GLEmiter(self.config) self.filesystem = GLFileSystem(self.config) self.modulesystem = GLModuleSystem(self.config) - self.moduletable = GLModuleTable(self.config) + self.moduletable = GLModuleTable(self.config, + True, + self.config.checkInclTestCategory(TESTS['all-tests'])) self.assistant = GLFileAssistant(self.config) self.makefiletable = GLMakefileTable(self.config) diff --git a/pygnulib/constants.py b/pygnulib/constants.py index ca5e3f79aa..bf01f86f39 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -104,7 +104,7 @@ MODES['verbose-min'] = -2 MODES['verbose-default'] = 0 MODES['verbose-max'] = 2 -# Set TESTS dictionary +# Define TESTS categories TESTS = \ { 'tests': 0, |