summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'unittests')
-rw-r--r--unittests/cargotests.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/unittests/cargotests.py b/unittests/cargotests.py
index 96a7b81ee..01d326130 100644
--- a/unittests/cargotests.py
+++ b/unittests/cargotests.py
@@ -8,8 +8,9 @@ import tempfile
import textwrap
import typing as T
-from mesonbuild.cargo import cfg, load_wraps
+from mesonbuild.cargo import cfg
from mesonbuild.cargo.cfg import TokenType
+from mesonbuild.cargo.interpreter import load_cargo_lock
from mesonbuild.cargo.manifest import Dependency, Manifest, Package, Workspace
from mesonbuild.cargo.toml import load_toml
from mesonbuild.cargo.version import convert
@@ -179,9 +180,10 @@ class CargoCfgTest(unittest.TestCase):
self.assertEqual(value, expected)
class CargoLockTest(unittest.TestCase):
- def test_cargo_lock(self) -> None:
+ def test_wraps(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
- with open(os.path.join(tmpdir, 'Cargo.lock'), 'w', encoding='utf-8') as f:
+ filename = os.path.join(tmpdir, 'Cargo.lock')
+ with open(filename, 'w', encoding='utf-8') as f:
f.write(textwrap.dedent('''\
version = 3
[[package]]
@@ -198,21 +200,22 @@ class CargoLockTest(unittest.TestCase):
version = "0.1"
source = "git+https://github.com/gtk-rs/gtk-rs-core?branch=0.19#23c5599424cc75ec66618891c915d9f490f6e4c2"
'''))
- wraps = load_wraps(tmpdir, 'subprojects')
+ cargolock = load_cargo_lock(filename, 'subprojects')
+ wraps = cargolock.wraps
self.assertEqual(len(wraps), 2)
- self.assertEqual(wraps[0].name, 'foo-0.1-rs')
- self.assertEqual(wraps[0].directory, 'foo-0.1')
- self.assertEqual(wraps[0].type, 'file')
- self.assertEqual(wraps[0].get('method'), 'cargo')
- self.assertEqual(wraps[0].get('source_url'), 'https://crates.io/api/v1/crates/foo/0.1/download')
- self.assertEqual(wraps[0].get('source_hash'), '8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb')
- self.assertEqual(wraps[1].name, 'gtk-rs-core-0.19')
- self.assertEqual(wraps[1].directory, 'gtk-rs-core-0.19')
- self.assertEqual(wraps[1].type, 'git')
- self.assertEqual(wraps[1].get('method'), 'cargo')
- self.assertEqual(wraps[1].get('url'), 'https://github.com/gtk-rs/gtk-rs-core')
- self.assertEqual(wraps[1].get('revision'), '23c5599424cc75ec66618891c915d9f490f6e4c2')
- self.assertEqual(list(wraps[1].provided_deps), ['gtk-rs-core-0.19', 'bar-0.1-rs', 'member-0.1-rs'])
+ self.assertEqual(wraps['foo-0.1-rs'].name, 'foo-0.1-rs')
+ self.assertEqual(wraps['foo-0.1-rs'].directory, 'foo-0.1')
+ self.assertEqual(wraps['foo-0.1-rs'].type, 'file')
+ self.assertEqual(wraps['foo-0.1-rs'].get('method'), 'cargo')
+ self.assertEqual(wraps['foo-0.1-rs'].get('source_url'), 'https://crates.io/api/v1/crates/foo/0.1/download')
+ self.assertEqual(wraps['foo-0.1-rs'].get('source_hash'), '8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb')
+ self.assertEqual(wraps['gtk-rs-core-0.19'].name, 'gtk-rs-core-0.19')
+ self.assertEqual(wraps['gtk-rs-core-0.19'].directory, 'gtk-rs-core-0.19')
+ self.assertEqual(wraps['gtk-rs-core-0.19'].type, 'git')
+ self.assertEqual(wraps['gtk-rs-core-0.19'].get('method'), 'cargo')
+ self.assertEqual(wraps['gtk-rs-core-0.19'].get('url'), 'https://github.com/gtk-rs/gtk-rs-core')
+ self.assertEqual(wraps['gtk-rs-core-0.19'].get('revision'), '23c5599424cc75ec66618891c915d9f490f6e4c2')
+ self.assertEqual(list(wraps['gtk-rs-core-0.19'].provided_deps), ['gtk-rs-core-0.19', 'bar-0.1-rs', 'member-0.1-rs'])
class CargoTomlTest(unittest.TestCase):
CARGO_TOML_1 = textwrap.dedent('''\