Skip to content

Commit

Permalink
Merge pull request #24 from boegel/deprecated_future_option
Browse files Browse the repository at this point in the history
use log.experimental for format v2 usage, and enable use of experimental is relevant unit tests
  • Loading branch information
stdweird committed Feb 6, 2014
2 parents 1d5336d + aa854bb commit 2850d7b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 18 deletions.
2 changes: 2 additions & 0 deletions easybuild/framework/easyconfig/format/two.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def _check_docstring(self):

def get_config_dict(self):
"""Return the best matching easyconfig dict"""
self.log.experimental(self.__class__.__name__)

# the toolchain name/version should not be specified in the pyheader,
# but other toolchain options are allowed

Expand Down
8 changes: 8 additions & 0 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from unittest import TestCase, TestLoader, main
from vsc import fancylogger

import easybuild.tools.build_log
import easybuild.tools.options as eboptions
import easybuild.framework.easyconfig as easyconfig
from easybuild.framework.easyblock import EasyBlock
Expand Down Expand Up @@ -790,6 +791,10 @@ def test_buildininstalldir(self):

def test_format_equivalence_basic(self):
"""Test whether easyconfigs in different formats are equivalent."""
# hard enable experimental
orig_experimental = easybuild.tools.build_log.EXPERIMENTAL
easybuild.tools.build_log.EXPERIMENTAL = True

easyconfigs_path = os.path.join(os.path.dirname(__file__), 'easyconfigs')

# set max diff high enough to make sure the difference is shown in case of problems
Expand All @@ -811,6 +816,9 @@ def test_format_equivalence_basic(self):
ec2 = EasyConfig(os.path.join(easyconfigs_path, 'v2.0', eb_file2), build_options=build_options, build_specs=specs)
self.assertEqual(ec1.asdict(), ec2.asdict())

# restore
easybuild.tools.build_log.EXPERIMENTAL = orig_experimental

def suite():
""" returns all the testcases in this module """
return TestLoader().loadTestsFromTestCase(EasyConfigTest)
Expand Down
29 changes: 26 additions & 3 deletions test/framework/easyconfigparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
@author: Stijn De Weirdt (Ghent University)
"""
import os

from unittest import TestCase, TestLoader, main
from vsc.utils.fancylogger import setLogLevelDebug, logToScreen

import easybuild.tools.build_log
from easybuild.framework.easyconfig.format.version import EasyVersion
from easybuild.framework.easyconfig.parser import EasyConfigParser

from vsc.utils.fancylogger import setLogLevelDebug, logToScreen


TESTDIRBASE = os.path.join(os.path.dirname(__file__), 'easyconfigs')

Expand All @@ -31,6 +30,11 @@ def test_v10(self):
self.assertEqual(ec['version'], '4.6.3')

def test_v20(self):
"""Test parsing of easyconfig in format v2."""
# hard enable experimental
orig_experimental = easybuild.tools.build_log.EXPERIMENTAL
easybuild.tools.build_log.EXPERIMENTAL = True

fn = os.path.join(TESTDIRBASE, 'v2.0', 'GCC.eb')
ecp = EasyConfigParser(fn)

Expand All @@ -47,7 +51,15 @@ def test_v20(self):
self.assertEqual(ec['name'], 'GCC')
self.assertEqual(ec['version'], '4.6.2')

# restore
easybuild.tools.build_log.EXPERIMENTAL = orig_experimental

def test_v20_extra(self):
"""Test parsing of easyconfig in format v2."""
# hard enable experimental
orig_experimental = easybuild.tools.build_log.EXPERIMENTAL
easybuild.tools.build_log.EXPERIMENTAL = True

fn = os.path.join(TESTDIRBASE, 'v2.0', 'doesnotexist.eb')
ecp = EasyConfigParser(fn)

Expand All @@ -58,7 +70,15 @@ def test_v20_extra(self):
self.assertFalse('version' in formatter.pyheader_localvars)
self.assertFalse('toolchain' in formatter.pyheader_localvars)

# restore
easybuild.tools.build_log.EXPERIMENTAL = orig_experimental

def test_v20_deps(self):
"""Test parsing of easyconfig in format v2 that includes dependencies."""
# hard enable experimental
orig_experimental = easybuild.tools.build_log.EXPERIMENTAL
easybuild.tools.build_log.EXPERIMENTAL = True

fn = os.path.join(TESTDIRBASE, 'v2.0', 'libpng.eb')
ecp = EasyConfigParser(fn)

Expand All @@ -71,6 +91,9 @@ def test_v20_deps(self):
# dependencies should be parsed correctly
self.assertEqual(ec['dependencies'], [('zlib', '1.2.5')])

# restore
easybuild.tools.build_log.EXPERIMENTAL = orig_experimental

def suite():
""" returns all the testcases in this module """
return TestLoader().loadTestsFromTestCase(EasyConfigParserTest)
Expand Down
37 changes: 22 additions & 15 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,34 @@ def test_toy_build(self):
]
try:
main((args, self.dummylogfn, True))
except (SystemExit, Exception), err:
except SystemExit:
pass
except Exception, err:
print "err: %s" % err
outtxt = read_file(self.logfile)

self.check_toy(self.installpath, outtxt)

def test_toy_build_formatv2(self):
"""Perform a toy build."""
"""Perform a toy build (format v2)."""
args = [
os.path.join(os.path.dirname(__file__), 'easyconfigs', 'v2.0', 'toy.eb'),
'--sourcepath=%s' % self.sourcepath,
'--buildpath=%s' % self.buildpath,
'--installpath=%s' % self.installpath,
'--debug',
'--unittest-file=%s' % self.logfile,
'--force',
'--robot=%s' % os.pathsep.join([self.buildpath, os.path.dirname(__file__)]),
'--software-version=0.0',
'--toolchain=dummy,dummy',
]
os.path.join(os.path.dirname(__file__), 'easyconfigs', 'v2.0', 'toy.eb'),
'--sourcepath=%s' % self.sourcepath,
'--buildpath=%s' % self.buildpath,
'--installpath=%s' % self.installpath,
'--debug',
'--unittest-file=%s' % self.logfile,
'--force',
'--robot=%s' % os.pathsep.join([self.buildpath, os.path.dirname(__file__)]),
'--software-version=0.0',
'--toolchain=dummy,dummy',
'--experimental',
]
try:
main((args, self.dummylogfn, True))
except (SystemExit, Exception), err:
except SystemExit:
pass
except Exception, err:
print "err: %s" % err
outtxt = read_file(self.logfile)

Expand Down Expand Up @@ -188,7 +193,9 @@ def test_toy_build_with_blocks(self):
]
try:
main((args, self.dummylogfn, True))
except (SystemExit, Exception), err:
except SystemExit:
pass
except Exception, err:
print "err: %s" % err
outtxt = read_file(self.logfile)

Expand Down

0 comments on commit 2850d7b

Please sign in to comment.