Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.project
LICENSE_HEADER
*.pyc
*.pyo
*.nja
build/
dist/
Expand Down
26 changes: 25 additions & 1 deletion easybuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from easybuild.framework.easyconfig.tools import alt_easyconfig_paths, dep_graph, det_easyconfig_paths
from easybuild.framework.easyconfig.tools import get_paths_for, parse_easyconfigs, review_pr, skip_available
from easybuild.framework.easyconfig.tweak import obtain_ec_for, tweak
from easybuild.tools.config import get_repository, get_repositorypath
from easybuild.tools.config import DEFAULT_TEST_REPO, KNOWN_TEST_REPOS, get_repository, get_repositorypath
from easybuild.tools.filetools import adjust_permissions, cleanup, write_file
from easybuild.tools.options import process_software_build_specs
from easybuild.tools.robot import det_robot_path, dry_run, resolve_dependencies, search_easyconfigs
Expand Down Expand Up @@ -151,6 +151,27 @@ def build_and_install_software(ecs, init_session_state, exit_on_failure=True):
return res


def run_test_suite(repo):
"""Run test suite for specified repo, and exit."""
if repo not in KNOWN_TEST_REPOS:
repo = DEFAULT_TEST_REPO

print_msg("Running %s unit tests..." % repo)
try:
testpkg = 'test.%s' % repo
suite = __import__('%s.suite' % testpkg, fromlist=[testpkg])

except SystemExit as exit_code:
raise EasyBuildError("One or more tests failed!")

except ImportError as err:
raise EasyBuildError("Failed to import test suite for %s repo: %s", repo, err)

# tests must have been successful if we reach here
print_msg("All %s tests successful!" % repo)
sys.exit(0)


def main(args=None, logfile=None, do_build=None, testing=False):
"""
Main function: parse command line options, and act accordingly.
Expand All @@ -167,6 +188,9 @@ def main(args=None, logfile=None, do_build=None, testing=False):
options = eb_go.options
orig_paths = eb_go.args

if options.test:
run_test_suite(options.test)

# set umask (as early as possible)
if options.umask is not None:
new_umask = int(options.umask, 8)
Expand Down
3 changes: 3 additions & 0 deletions easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
DEFAULT_REPOSITORY = 'FileRepository'
DEFAULT_STRICT = run.WARN

KNOWN_TEST_REPOS = ['framework', 'easyblocks', 'easyconfigs']
DEFAULT_TEST_REPO = KNOWN_TEST_REPOS[0]


# utility function for obtaining default paths
def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
Expand Down
4 changes: 3 additions & 1 deletion easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from easybuild.tools.config import DEFAULT_JOB_BACKEND, DEFAULT_LOGFILE_FORMAT, DEFAULT_MNS, DEFAULT_MODULE_SYNTAX
from easybuild.tools.config import DEFAULT_MODULES_TOOL, DEFAULT_MODULECLASSES, DEFAULT_PATH_SUBDIRS
from easybuild.tools.config import DEFAULT_PKG_RELEASE, DEFAULT_PKG_TOOL, DEFAULT_PKG_TYPE, DEFAULT_PNS, DEFAULT_PREFIX
from easybuild.tools.config import DEFAULT_REPOSITORY, DEFAULT_STRICT
from easybuild.tools.config import DEFAULT_REPOSITORY, DEFAULT_STRICT, DEFAULT_TEST_REPO, KNOWN_TEST_REPOS
from easybuild.tools.config import get_pretend_installpath, mk_full_default_path, set_tmpdir
from easybuild.tools.configobj import ConfigObj, ConfigObjError
from easybuild.tools.docs import FORMAT_RST, FORMAT_TXT, avail_easyconfig_params
Expand Down Expand Up @@ -143,6 +143,8 @@ def basic_options(self):
'stop': ("Stop the installation after certain step",
'choice', 'store_or_None', SOURCE_STEP, 's', all_stops),
'strict': ("Set strictness level", 'choice', 'store', DEFAULT_STRICT, strictness_options),
'test': ("Run unit tests for specified EasyBuild repository",
'choice', 'store_or_None', DEFAULT_TEST_REPO, KNOWN_TEST_REPOS)
})

self.log.debug("basic_options: descr %s opts %s" % (descr, opts))
Expand Down
2 changes: 1 addition & 1 deletion eb
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ then
echo "Make sure you PYTHONPATH setting is correct."
exit 1
else
python $easybuild_main $@
python -O $easybuild_main $@
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supporting a way to turn off the use of -O might make sense...

maybe the wrapper should check whether -d or --debug was passed on the command line (may be tricky for -d...) + check whether $EASYBUILD_DEBUG is set? this doesn't catch the case where debug is enabled via a config file though...

fi
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ def find_rel_test():
provides=["eb"] + easybuild_packages,
test_suite="test.framework.suite",
zip_safe=False,
install_requires=["vsc-base >= 2.2.4"],
install_requires=["vsc-base >= 2.2.5"],
)
2 changes: 1 addition & 1 deletion test/framework/build_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_easybuilderror(self):
self.assertErrorRegex(EasyBuildError, 'BOOM', raise_easybuilderror, 'BOOM')
logToFile(tmplog, enable=False)

log_re = re.compile("^%s :: BOOM \(at .*:[0-9]+ in [a-z_]+\)$" % getRootLoggerName(), re.M)
log_re = re.compile("^%s :: BOOM( \(at .*:[0-9]+ in [a-z_]+\))?$" % getRootLoggerName(), re.M)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how happy I am with this, since this basically indicates that the location where errors occur are no longer available...

@JensTimmerman: maybe you've been a little bit too eager with putting the if __debug__s in place?

I'll try and see if this can be restored by rolling back one of the if __debug__s without big impact on performance...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I have not been to eager, the location is only visible in debug mode.
if you're not debugging then the location is of no interest to you.

logtxt = open(tmplog, 'r').read()
self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

Expand Down