-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1317 from Caylo/generic-easyblock-docs-issue636
Generate docs for generic easyblocks (REVIEW)
- Loading branch information
Showing
3 changed files
with
295 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# # | ||
# Copyright 2012-2015 Ghent University | ||
# | ||
# This file is part of EasyBuild, | ||
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
# with support of Ghent University (http://ugent.be/hpc), | ||
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en), | ||
# the Hercules foundation (http://www.herculesstichting.be/in_English) | ||
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
# | ||
# http://github.com/hpcugent/easybuild | ||
# | ||
# EasyBuild is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation v2. | ||
# | ||
# EasyBuild is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
## | ||
""" | ||
Unit tests for docs.py. | ||
""" | ||
|
||
import os | ||
import re | ||
import sys | ||
import inspect | ||
|
||
from easybuild.tools.docs import gen_easyblocks_overview_rst, mk_rst_table | ||
from easybuild.tools.utilities import import_available_modules | ||
from test.framework.utilities import EnhancedTestCase, init_config | ||
from unittest import TestLoader, main | ||
|
||
class DocsTest(EnhancedTestCase): | ||
|
||
def test_rst_table(self): | ||
""" Test mk_rst_table function """ | ||
entries = [['one', 'two', 'three']] | ||
t = 'This title is longer than the entries in the column' | ||
titles = [t] | ||
|
||
# small table | ||
table = '\n'.join(mk_rst_table(titles, entries)) | ||
check = '\n'.join([ | ||
'=' * len(t), | ||
t, | ||
'=' * len(t), | ||
'one' + ' ' * (len(t) - 3), | ||
'two' + ' ' * (len(t) -3), | ||
'three' + ' ' * (len(t) - 5), | ||
'=' * len(t), | ||
'', | ||
]) | ||
|
||
self.assertEqual(table, check) | ||
|
||
def test_gen_easyblocks(self): | ||
""" Test gen_easyblocks_overview_rst function """ | ||
module = 'easybuild.easyblocks.generic' | ||
modules = import_available_modules(module) | ||
common_params = { | ||
'ConfigureMake' : ['configopts', 'buildopts', 'installopts'], | ||
} | ||
doc_functions = ['build_step', 'configure_step', 'test_step'] | ||
|
||
eb_overview = gen_easyblocks_overview_rst(module, 'easyconfigs', common_params, doc_functions) | ||
ebdoc = '\n'.join(eb_overview) | ||
|
||
# extensive check for ConfigureMake easyblock | ||
check_configuremake = '\n'.join([ | ||
".. _ConfigureMake:", | ||
'', | ||
"``ConfigureMake``", | ||
"=================", | ||
'', | ||
"(derives from EasyBlock)", | ||
'', | ||
"Dummy support for building and installing applications with configure/make/make install.", | ||
'', | ||
"Commonly used easyconfig parameters with ``ConfigureMake`` easyblock", | ||
"--------------------------------------------------------------------", | ||
"==================== ================================================================", | ||
"easyconfig parameter description ", | ||
"==================== ================================================================", | ||
"configopts Extra options passed to configure (default already has --prefix)", | ||
"buildopts Extra options passed to make step (default already has -j X) ", | ||
"installopts Extra options for installation ", | ||
"==================== ================================================================", | ||
]) | ||
|
||
self.assertTrue(check_configuremake in ebdoc) | ||
names = [] | ||
|
||
for mod in modules: | ||
for name, obj in inspect.getmembers(mod, inspect.isclass): | ||
eb_class = getattr(mod, name) | ||
# skip imported classes that are not easyblocks | ||
if eb_class.__module__.startswith(module): | ||
self.assertTrue(name in ebdoc) | ||
names.append(name) | ||
|
||
toc = [":ref:`" + n + "`" for n in sorted(names)] | ||
pattern = " - ".join(toc) | ||
|
||
regex = re.compile(pattern) | ||
self.assertTrue(re.search(regex, ebdoc), "Pattern %s found in %s" % (regex.pattern, ebdoc)) | ||
|
||
|
||
def suite(): | ||
""" returns all test cases in this module """ | ||
return TestLoader().loadTestsFromTestCase(DocsTest) | ||
|
||
if __name__ == '__main__': | ||
# also check the setUp for debug | ||
# logToScreen(enable=True) | ||
# setLogLevelDebug() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters