Skip to content

Commit

Permalink
rust: avoid warnings from rust.test
Browse files Browse the repository at this point in the history
Any argument from the base target is copied to the test target, but some
keyword arguments for libraries are not available in executable.
Remove them.

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Nov 19, 2024
1 parent 731dcdf commit b8cf67e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mesonbuild/modules/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def test(self, state: ModuleState, args: T.Tuple[str, BuildTarget], kwargs: Func
new_target_kwargs['dependencies'] = new_target_kwargs.get('dependencies', []) + kwargs['dependencies']
new_target_kwargs['link_with'] = new_target_kwargs.get('link_with', []) + kwargs['link_with']
del new_target_kwargs['rust_crate_type']
for kw in ['pic', 'prelink', 'rust_abi', 'version', 'soversion', 'darwin_versions']:
if kw in new_target_kwargs:
del new_target_kwargs[kw]

lang_args = base_target.extra_args.copy()
lang_args['rust'] = base_target.extra_args['rust'] + kwargs['rust_args'] + ['--test']
Expand Down
4 changes: 2 additions & 2 deletions test cases/rust/9 unit tests/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('rust unit tests', 'rust')
project('rust unit tests', 'rust', meson_version: '>=1.2.0')

t = executable(
'rust_test',
Expand Down Expand Up @@ -33,7 +33,7 @@ test(

exe = executable('rust_exe', ['test2.rs', 'test.rs'], build_by_default : false)

rust = import('unstable-rust')
rust = import('rust')
rust.test('rust_test_from_exe', exe, should_fail : true)

lib = static_library('rust_static', ['test.rs'], build_by_default : false, rust_crate_type : 'lib')
Expand Down
7 changes: 7 additions & 0 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4890,6 +4890,13 @@ def test_rust_clippy(self) -> None:
self.assertTrue('error: use of a blacklisted/placeholder name `foo`' in cm.exception.stdout or
'error: use of a disallowed/placeholder name `foo`' in cm.exception.stdout)

@skip_if_not_language('rust')
def test_rust_test_warnings(self) -> None:
if self.backend is not Backend.ninja:
raise unittest.SkipTest('Rust is only supported with ninja currently')
testdir = os.path.join(self.rust_test_dir, '9 unit tests')
self.init(testdir, extra_args=['--fatal-meson-warnings'])

@skip_if_not_language('rust')
def test_rust_rlib_linkage(self) -> None:
if self.backend is not Backend.ninja:
Expand Down

0 comments on commit b8cf67e

Please sign in to comment.