Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for package augmentation #49

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading