-
Notifications
You must be signed in to change notification settings - Fork 87
BUG: ensure build options are preserved from an existing build directory #852
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -332,6 +332,35 @@ def test_invalid_build_dir(package_pure, tmp_path, mocker): | |
| assert '--reconfigure' not in meson.call_args_list[0].args[1] | ||
| project.build() | ||
|
|
||
| def test_reconfigure_preserves_config(package_simple, tmp_path): | ||
| # initial configuration | ||
| project = mesonpy.Project(package_simple, tmp_path, meson_args={ | ||
| 'setup': ['-Dbuildtype=debug', '-Dwarning_level=2'], | ||
| }) | ||
|
|
||
| initial_options = {opt['name']: opt['value'] for opt in project._info('intro-buildoptions')} | ||
|
|
||
| assert initial_options['buildtype'] == 'debug' | ||
| assert initial_options['debug'] is True | ||
| assert initial_options['warning_level'] == '2' | ||
|
|
||
| # reconfiguration with a new option | ||
| project = mesonpy.Project(package_simple, tmp_path, meson_args={ | ||
| 'setup': ['-Doptimization=2'], | ||
|
Contributor
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 test is correct but a little obscure, given that it doesn't directly checks default/updated values of any of the build options that meson-python actually overrides. Perhaps also assert that the buildtype is and remains While we're at it here, it looks like there is no test that checks that the default
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.
I added some assertions in the initial configuration and in the reconfiguration, but I feel like most of them were redundant, considering the last assertion
Created a new test in |
||
| }) | ||
|
|
||
| reconfigure_options = {opt['name']: opt['value'] for opt in project._info('intro-buildoptions')} | ||
|
|
||
| assert reconfigure_options['buildtype'] == 'debug' | ||
| assert reconfigure_options['debug'] is True | ||
| assert reconfigure_options['warning_level'] == '2' | ||
|
|
||
| assert initial_options != reconfigure_options | ||
|
|
||
| initial_options['optimization'] = '2' | ||
| assert initial_options == reconfigure_options | ||
|
|
||
|
|
||
|
|
||
| @pytest.mark.skipif(not os.getenv('CI') or sys.platform != 'win32', reason='requires MSVC') | ||
| def test_compiler(venv, package_detect_compiler, tmp_path): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also an imprecision in the commit message: the
reconfigureargument is passed when the specified build directory is detected to contain a Meson build dir, not when it merely exist. And, as @rgommers already pointed out (IIRC)buildtypeis not the only default argument passed. I would reword the commit message like thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Do I need to change the PR description too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updating the PR description as well may be useful - at least for me, this captured the essence of the change, and I didn't quite get it from the initial issue or PR description.