summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-10-14 18:46:49 +0200
committerXavier Claessens <xclaesse@gmail.com>2025-10-23 17:02:13 +0100
commit81cf25fc0b6615f20b777cca4099b854c4cf2c3b (patch)
treeb962000dbea3360ca678f1d18449abd3ac44f31f /unittests
parent0fcc18171b88ca5f9fa471fd204d6ee0129bd58c (diff)
downloadmeson-81cf25fc0b6615f20b777cca4099b854c4cf2c3b.tar.gz
cargo: generate lint arguments from table
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'unittests')
-rw-r--r--unittests/cargotests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/cargotests.py b/unittests/cargotests.py
index 0c2b645f5..16bc4cfee 100644
--- a/unittests/cargotests.py
+++ b/unittests/cargotests.py
@@ -430,6 +430,23 @@ class CargoTomlTest(unittest.TestCase):
self.assertEqual(manifest.lints[2].priority, 0)
self.assertEqual(manifest.lints[2].check_cfg, ['cfg(test)', 'cfg(MESON)'])
+ def test_cargo_toml_lints_to_args(self) -> None:
+ with tempfile.TemporaryDirectory() as tmpdir:
+ fname = os.path.join(tmpdir, 'Cargo.toml')
+ with open(fname, 'w', encoding='utf-8') as f:
+ f.write(self.CARGO_TOML_1)
+ manifest_toml = load_toml(fname)
+ manifest = Manifest.from_raw(manifest_toml, 'Cargo.toml')
+
+ self.assertEqual(manifest.lints[0].to_arguments(False), ['-W', 'clippy::pedantic'])
+ self.assertEqual(manifest.lints[0].to_arguments(True), ['-W', 'clippy::pedantic'])
+ self.assertEqual(manifest.lints[1].to_arguments(False), ['-A', 'unknown_lints'])
+ self.assertEqual(manifest.lints[1].to_arguments(True), ['-A', 'unknown_lints'])
+ self.assertEqual(manifest.lints[2].to_arguments(False), ['-D', 'unexpected_cfgs'])
+ self.assertEqual(manifest.lints[2].to_arguments(True),
+ ['-D', 'unexpected_cfgs', '--check-cfg', 'cfg(test)',
+ '--check-cfg', 'cfg(MESON)'])
+
def test_cargo_toml_dependencies(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
fname = os.path.join(tmpdir, 'Cargo.toml')