From 66605d9c332a506b4e06d3c2a5eaa89c29caea5d Mon Sep 17 00:00:00 2001 From: Ward Poelmans Date: Wed, 27 Jan 2016 17:57:20 +0100 Subject: [PATCH 1/3] Do pep8 style checks on the easyconfigs --- test/easyconfigs/styletests.py | 124 +++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 test/easyconfigs/styletests.py diff --git a/test/easyconfigs/styletests.py b/test/easyconfigs/styletests.py new file mode 100644 index 00000000000..4eb6f4cbf43 --- /dev/null +++ b/test/easyconfigs/styletests.py @@ -0,0 +1,124 @@ +## +# Copyright 2016 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 . +## +""" +Style tests for easyconfig files. Uses pep8. + +@author: Ward Poelmans (Ghent University) +""" + +from unittest import TestCase, TestLoader, main +import glob +import re +import sys +from vsc.utils import fancylogger + +from easybuild.framework.easyconfig.tools import get_paths_for + +try: + import pep8 +except ImportError: + pass + + +# any function starting with eb_check_ will be added to the tests +# if the test number is added to the select list. The test number is +# definied as AXXX where XXX is a 3 digit number. It should be mentioned +# in the docstring as a single word. +def eb_check_trailing_whitespace(physical_line, lines, line_number, total_lines): + """ + W299 + Warn about trailing whitespace, expect for the description and comments. + This differs from the standard trailing whitespace check as that + will will warn for any trailing whitespace. + """ + comment_re = re.compile('^\s*#') + if comment_re.match(physical_line): + return None + + result = pep8.trailing_whitespace(physical_line) + if result: + result = (result[0], result[1].replace("W291", "W299")) + + # if the warning is about the multiline string of description + # we will not issue a warning + keys_re = re.compile("^(?P[a-z_]+)\s*=\s*") + + for line in reversed(lines[0:line_number]): + res = keys_re.match(line) + if res: + if res.group("key") == "description": + return None + else: + break + + return result + + +class StyleTest(TestCase): + log = fancylogger.getLogger("StyleTest", fname=False) + + def test_style_conformance(self): + """Check the easyconfigs for style""" + if 'pep8' not in sys.modules: + print "Skipping style checks (no pep8 available)" + return + + # all available easyconfig files + easyconfigs_path = get_paths_for("easyconfigs")[0] + specs = glob.glob('%s/*/*/*.eb' % easyconfigs_path) + + # register the extra checks before using pep8 + cands = globals() + for check_function in sorted([cands[f] for f in cands if callable(cands[f]) and f.startswith('eb_check_')]): + pep8.register_check(check_function) + + pep8style = pep8.StyleGuide(quiet=False, config_file=None) + options = pep8style.options + options.max_line_length = 120 + # currently, we only check a selected set of tests + options.ignore = ('',) + options.select = ('E101', # indentation contains mixed spaces and tabs + 'E111', # indentation is not a multiple of four + 'W191', # indentation contains tabs + # 'E303', # too many blank lines (3) + # 'E501', # line too long + # 'W291', # trailing whitespace + 'W293', # blank line contains whitespace + 'W299', # trailing whitespace, EB style + ) + + result = pep8style.check_files(specs) + result.print_statistics() + self.assertEqual(result.total_errors, 0, + "Found code style errors (and/or warnings).") + + +def suite(): + """Return all style tests for easyconfigs.""" + return TestLoader().loadTestsFromTestCase(StyleTest) + + +if __name__ == '__main__': + main() From 3ac5569de3ef28e84a6b6677876bcfd29a710245 Mon Sep 17 00:00:00 2001 From: Ward Poelmans Date: Wed, 27 Jan 2016 17:59:15 +0100 Subject: [PATCH 2/3] Add style checks to the suite --- test/easyconfigs/suite.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/easyconfigs/suite.py b/test/easyconfigs/suite.py index 6afbd6ffb15..ada585eaa62 100644 --- a/test/easyconfigs/suite.py +++ b/test/easyconfigs/suite.py @@ -30,7 +30,6 @@ @author: Toon Willems (Ghent University) @author: Kenneth Hoste (Ghent University) """ -import glob import os import shutil import sys @@ -41,6 +40,7 @@ import easybuild.tools.build_log # initialize EasyBuild logging, so we disable it import test.easyconfigs.easyconfigs as e +import test.easyconfigs.styletests as s # disable all logging to significantly speed up tests fancylogger.disableDefaultHandlers() @@ -52,7 +52,7 @@ os.environ['EASYBUILD_TMP_LOGDIR'] = tempfile.mkdtemp(prefix='easyconfigs_test_') # call suite() for each module and then run them all -SUITE = unittest.TestSuite([x.suite() for x in [e]]) +SUITE = unittest.TestSuite([x.suite() for x in [e, s]]) # uses XMLTestRunner if possible, so we can output an XML file that can be supplied to Jenkins xml_msg = "" From 4581f089a5e0db1e1424d265cd19f5e64dc76144 Mon Sep 17 00:00:00 2001 From: Ward Poelmans Date: Wed, 27 Jan 2016 18:04:22 +0100 Subject: [PATCH 3/3] Fix all trailing whitespaces --- easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-ictce-4.1.13.eb | 2 +- easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-iqacml-3.7.3.eb | 2 +- .../g/GPAW/GPAW-0.9.0.8965-ictce-4.0.6-Python-2.7.3.eb | 2 +- easybuild/easyconfigs/h/hwloc/hwloc-1.11.2-GCC-4.9.3-2.25.eb | 2 +- easybuild/easyconfigs/m/MotEvo/MotEvo-1.02-goolf-1.4.10.eb | 2 +- .../t/Tornado/Tornado-2012.09.06-goalf-1.1.0-no-OFED.eb | 2 +- .../x/Xmipp/Xmipp-3.1-goolf-1.4.10-with-incl-deps.eb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-ictce-4.1.13.eb b/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-ictce-4.1.13.eb index 94cef6458dd..4eded30be6a 100644 --- a/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-ictce-4.1.13.eb +++ b/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-ictce-4.1.13.eb @@ -8,7 +8,7 @@ description = """GDAL is a translator library for raster geospatial data formats Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single abstract data model to the calling application for all supported formats. It also comes with a variety of useful commandline utilities for data translation and processing.""" - + toolchain = {'name': 'ictce', 'version': '4.1.13'} source_urls = ['http://download.osgeo.org/gdal/'] diff --git a/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-iqacml-3.7.3.eb b/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-iqacml-3.7.3.eb index 83b2c99400a..670cd7dbd40 100644 --- a/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-iqacml-3.7.3.eb +++ b/easybuild/easyconfigs/g/GDAL/GDAL-1.9.2-iqacml-3.7.3.eb @@ -8,7 +8,7 @@ description = """GDAL is a translator library for raster geospatial data formats Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single abstract data model to the calling application for all supported formats. It also comes with a variety of useful commandline utilities for data translation and processing.""" - + toolchain = {'name': 'iqacml', 'version': '3.7.3'} source_urls = ['http://download.osgeo.org/gdal/'] diff --git a/easybuild/easyconfigs/g/GPAW/GPAW-0.9.0.8965-ictce-4.0.6-Python-2.7.3.eb b/easybuild/easyconfigs/g/GPAW/GPAW-0.9.0.8965-ictce-4.0.6-Python-2.7.3.eb index b784121754a..b4c7f9caae1 100644 --- a/easybuild/easyconfigs/g/GPAW/GPAW-0.9.0.8965-ictce-4.0.6-Python-2.7.3.eb +++ b/easybuild/easyconfigs/g/GPAW/GPAW-0.9.0.8965-ictce-4.0.6-Python-2.7.3.eb @@ -7,7 +7,7 @@ homepage = 'https://wiki.fysik.dtu.dk/gpaw/' description = """GPAW is a density-functional theory (DFT) Python code based on the projector-augmented wave (PAW) method and the atomic simulation environment (ASE). It uses real-space uniform grids and multigrid methods or atom-centered basis-functions.""" - + toolchain = {'name': 'ictce', 'version': '4.0.6'} source_urls = ['https://wiki.fysik.dtu.dk/gpaw-files/'] diff --git a/easybuild/easyconfigs/h/hwloc/hwloc-1.11.2-GCC-4.9.3-2.25.eb b/easybuild/easyconfigs/h/hwloc/hwloc-1.11.2-GCC-4.9.3-2.25.eb index dd384c19f88..0af84a15f7c 100644 --- a/easybuild/easyconfigs/h/hwloc/hwloc-1.11.2-GCC-4.9.3-2.25.eb +++ b/easybuild/easyconfigs/h/hwloc/hwloc-1.11.2-GCC-4.9.3-2.25.eb @@ -12,7 +12,7 @@ description = """The Portable Hardware Locality (hwloc) software package provide information about modern computing hardware so as to exploit it accordingly and efficiently.""" toolchain = {'name': 'GCC', 'version': '4.9.3-2.25'} - + source_urls = ['http://www.open-mpi.org/software/hwloc/v%(version_major_minor)s/downloads/'] sources = [SOURCE_TAR_GZ] diff --git a/easybuild/easyconfigs/m/MotEvo/MotEvo-1.02-goolf-1.4.10.eb b/easybuild/easyconfigs/m/MotEvo/MotEvo-1.02-goolf-1.4.10.eb index ce172894c99..aa2cc82aa99 100644 --- a/easybuild/easyconfigs/m/MotEvo/MotEvo-1.02-goolf-1.4.10.eb +++ b/easybuild/easyconfigs/m/MotEvo/MotEvo-1.02-goolf-1.4.10.eb @@ -22,7 +22,7 @@ start_dir = "source" parallel = 1 -files_to_copy = ["../*"] +files_to_copy = ["../*"] sanity_check_paths = { 'files': ["bin/motevo", "bin/runUFE"], diff --git a/easybuild/easyconfigs/t/Tornado/Tornado-2012.09.06-goalf-1.1.0-no-OFED.eb b/easybuild/easyconfigs/t/Tornado/Tornado-2012.09.06-goalf-1.1.0-no-OFED.eb index 3ad1ac0bbd7..7e0e189b7c0 100644 --- a/easybuild/easyconfigs/t/Tornado/Tornado-2012.09.06-goalf-1.1.0-no-OFED.eb +++ b/easybuild/easyconfigs/t/Tornado/Tornado-2012.09.06-goalf-1.1.0-no-OFED.eb @@ -4,7 +4,7 @@ version = '2012.09.06' homepage = 'http://www.dhigroup.com/' description = """Tornado is a new kernel for modelling and virtual experimentation (i.e. any evaluation of a model) in the domain of water quality management""" - + toolchain = {'name': 'goalf', 'version': '1.1.0-no-OFED'} toolchainopts = {'pic': True, 'opt': True, 'optarch': True} diff --git a/easybuild/easyconfigs/x/Xmipp/Xmipp-3.1-goolf-1.4.10-with-incl-deps.eb b/easybuild/easyconfigs/x/Xmipp/Xmipp-3.1-goolf-1.4.10-with-incl-deps.eb index d9881b2ef71..ec08bd48fa2 100644 --- a/easybuild/easyconfigs/x/Xmipp/Xmipp-3.1-goolf-1.4.10-with-incl-deps.eb +++ b/easybuild/easyconfigs/x/Xmipp/Xmipp-3.1-goolf-1.4.10-with-incl-deps.eb @@ -4,7 +4,7 @@ versionsuffix = '-with-incl-deps' homepage = 'http://xmipp.cnb.csic.es/' description = "Xmipp is a suite of image processing programs, primarily aimed at single-particle 3D electron microscopy." - + source_urls = ['http://xmipp.cnb.csic.es/Downloads/'] sources = ['Xmipp-%(version)s-src.tar.gz']