Skip to content

Commit

Permalink
Add tests for package augmentation
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
  • Loading branch information
luca-della-vedova authored Dec 9, 2024
1 parent c67bab0 commit eac2819
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/rust-pure-library/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "rust-pure-library"
version = "0.1.0"
authors = ["Luca Della Vedova<lucadv@intrinsic.ai>"]
authors = ["Test<test@test.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
either = "1.13.0"
1 change: 1 addition & 0 deletions test/rust-sample-package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
either = "1.13.0"
16 changes: 16 additions & 0 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from types import SimpleNamespace
import xml.etree.ElementTree as eTree

from colcon_cargo.package_augmentation.cargo import CargoPackageAugmentation
from colcon_cargo.package_identification.cargo import CargoPackageIdentification # noqa: E501
from colcon_cargo.task.cargo.build import CargoBuildTask
from colcon_cargo.task.cargo.test import CargoTestTask
Expand Down Expand Up @@ -43,6 +44,21 @@ def test_package_identification():
assert desc.name == TEST_PACKAGE_NAME


def test_package_augmentation():
cpi = CargoPackageIdentification()
aug = CargoPackageAugmentation()
desc = PackageDescriptor(pure_library_path)
cpi.identify(desc)
aug.augment_package(desc)
print(desc)
assert desc.metadata['version'] == '0.1.0'
assert len(desc.metadata['maintainers']) == 1
assert desc.metadata['maintainers'][0] == 'Test<test@test.com>'
assert len(desc.dependencies['build']) == 1
assert 'either' in desc.dependencies['build']
assert desc.dependencies['run'] == desc.dependencies['build']


@pytest.mark.skipif(
not shutil.which('cargo'),
reason='Rust must be installed to run this test')
Expand Down

0 comments on commit eac2819

Please sign in to comment.