summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-08-19 19:41:31 +0200
committerXavier Claessens <xclaesse@gmail.com>2025-10-23 16:20:22 +0100
commitb695f2d617fb965e364e8b05bd3f03490567782a (patch)
tree8954eaf7ee9ff2091f12e123a681c8cc7fb786a1 /unittests
parent1e8ae5811d56662f701ef03013c2da0607e8f491 (diff)
downloadmeson-b695f2d617fb965e364e8b05bd3f03490567782a.tar.gz
cargo: convert proc_macro to crate_type in Library dataclass.
Do not look anymore at proc_macro after init, keeping crate_type as the sole source of truth about the desired crate types.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/cargotests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/cargotests.py b/unittests/cargotests.py
index 22d77b35f..e9e779c1e 100644
--- a/unittests/cargotests.py
+++ b/unittests/cargotests.py
@@ -280,6 +280,18 @@ class CargoTomlTest(unittest.TestCase):
]
''')
+ CARGO_TOML_3 = textwrap.dedent('''\
+ [package]
+ name = "bits"
+ edition = "2021"
+ rust-version = "1.70"
+ version = "0.1.0"
+
+ [lib]
+ proc-macro = true
+ crate-type = ["lib"] # ignored
+ ''')
+
CARGO_TOML_WS = textwrap.dedent('''\
[workspace]
resolver = "2"
@@ -406,6 +418,19 @@ class CargoTomlTest(unittest.TestCase):
self.assertEqual(manifest.dev_dependencies['gir-format-check'].meson_version, ['>= 0.1', '< 0.2'])
self.assertEqual(manifest.dev_dependencies['gir-format-check'].api, '0.1')
+ def test_cargo_toml_proc_macro(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_3)
+ manifest_toml = load_toml(fname)
+ manifest = Manifest.from_raw(manifest_toml, 'Cargo.toml')
+
+ self.assertEqual(manifest.lib.name, 'bits')
+ self.assertEqual(manifest.lib.crate_type, ['proc-macro'])
+ self.assertEqual(manifest.lib.path, 'src/lib.rs')
+ self.assertEqual(manifest.lib.proc_macro, True)
+
def test_cargo_toml_targets(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
fname = os.path.join(tmpdir, 'Cargo.toml')