Repository navigation
enable runtest and test_cmd customization in MesonNinja easyblock
#4111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
17ddc93
f23608d
4b35424
7e3d185
0abc2da
a2e6975
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
|
|
||
| from easybuild.tools import LooseVersion | ||
| from easybuild.framework.easyblock import EasyBlock | ||
| from easybuild.framework.easyconfig import CUSTOM | ||
| from easybuild.framework.easyconfig import CUSTOM, BUILD | ||
| from easybuild.tools.build_log import EasyBuildError | ||
| from easybuild.tools.filetools import change_dir, create_unused_dir, which | ||
| from easybuild.tools.modules import get_software_version | ||
|
|
@@ -39,6 +39,7 @@ | |
| DEFAULT_CONFIGURE_CMD = 'meson' | ||
| DEFAULT_BUILD_CMD = 'ninja' | ||
| DEFAULT_INSTALL_CMD = 'ninja' | ||
| DEFAULT_TEST_CMD = 'meson' | ||
|
boegel marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
| class MesonNinja(EasyBlock): | ||
|
|
@@ -60,6 +61,8 @@ def extra_options(extra_vars=None): | |
| 'configure_cmd': [DEFAULT_CONFIGURE_CMD, "Configure command to use", CUSTOM], | ||
| 'install_cmd': [DEFAULT_INSTALL_CMD, "Install command to use", CUSTOM], | ||
| 'separate_build_dir': [True, "Perform build in a separate directory", CUSTOM], | ||
| 'test_cmd': [DEFAULT_TEST_CMD, "Test command to use ('runtest' value is appended)", CUSTOM], | ||
| 'runtest': [None, "Meson target to test build or True to use 'meson test'", BUILD], | ||
|
boegel marked this conversation as resolved.
Resolved
|
||
| }) | ||
| return extra_vars | ||
|
|
||
|
|
@@ -149,11 +152,32 @@ def build_step(self, *args, **kwargs): | |
|
|
||
| def test_step(self): | ||
| """ | ||
| Run tests using Ninja. | ||
| Run tests using Meson. | ||
| """ | ||
| if self.cfg['runtest']: | ||
| cmd = "%s %s %s" % (self.cfg['pretestopts'], self.cfg['runtest'], self.cfg['testopts']) | ||
| test_cmd = self.cfg.get('test_cmd') or DEFAULT_TEST_CMD | ||
| runtest = self.cfg['runtest'] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Thyre We need to be a bit more careful here I think, to avoid introducing a backwards-incompatible change... For an exiting easyconfig file like runtest = 'ninja test'this (and the logic below) means trouble, because we're essentially prepending Our easyconfig files are being updated so they work nicely with this updated We should try and come up with an approach where existing easyconfigs that include
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This should keep the old behavior for existing external EasyConfigs. |
||
| if runtest or test_cmd != DEFAULT_TEST_CMD: | ||
| # Make run_test a string (empty if it is e.g. a boolean) | ||
| if not isinstance(runtest, str): | ||
| runtest = '' | ||
| # Run tests as recommended in https://mesonbuild.com/Unit-tests.html#testing-tool | ||
| if test_cmd == DEFAULT_TEST_CMD: | ||
| runtest = 'test' | ||
|
|
||
| # Make sure Meson does not use more resources than we want. | ||
| # From the documentation: | ||
| # By default Meson uses as many concurrent processes as there are cores on the test machine. | ||
| if self.cfg.parallel >= 1 and 'meson' in test_cmd: | ||
| if 'MESON_TESTTHREADS' not in self.cfg['pretestopts']: | ||
| self.cfg['pretestopts'] += f'export MESON_TESTTHREADS={self.cfg.parallel} && ' | ||
|
boegel marked this conversation as resolved.
Resolved
|
||
| # Preferred way to set parallelism since Meson v1.7.0, but does not hurt to set both. | ||
| if 'MESON_NUM_PROCESSES' not in self.cfg['pretestopts']: | ||
| self.cfg['pretestopts'] += f'export MESON_NUM_PROCESSES={self.cfg.parallel} && ' | ||
|
boegel marked this conversation as resolved.
Resolved
|
||
|
|
||
| # Compose command filtering out empty values | ||
| cmd = ' '.join([x for x in (self.cfg['pretestopts'], test_cmd, runtest, self.cfg['testopts']) if x]) | ||
| res = run_shell_cmd(cmd) | ||
|
|
||
| return res.output | ||
|
|
||
| def install_step(self): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.