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

tests: add tests for advanced grammar in root keywords #4753

Merged
merged 4 commits into from
Apr 24, 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
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
attrs==23.1.0
catkin-pkg==0.5.2
click==8.1.7
craft-application==2.5.0
craft-application==2.6.0
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ click==8.1.7
codespell==2.2.6
colorama==0.4.6
coverage==7.4.4
craft-application==2.5.0
craft-application==2.6.0
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
craft-application==2.5.0
craft-application==2.6.0
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.2.0
Expand Down
6 changes: 6 additions & 0 deletions tests/spread/core24/grammar/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ platforms:
build-on: amd64
build-for: arm64

build-packages:
- on amd64 to amd64:
- libogg-dev
- on amd64 to arm64:
- libpci-dev

parts:
hello-world:
plugin: dump
Expand Down
14 changes: 11 additions & 3 deletions tests/unit/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ def test_application_expand_extensions(emitter, monkeypatch, extension_source, n


@pytest.mark.usefixtures("fake_extension")
def test_application_build_with_extensions(monkeypatch, extension_source, new_dir):
"""Test that extensions are correctly applied in regular builds."""
def test_application_extra_yaml_transforms(
monkeypatch, extension_source, new_dir, emitter
):
"""Test that extra_yaml_transforms applies root keywords and expands extensions."""
monkeypatch.setenv("CRAFT_DEBUG", "1")
extension_source["build-packages"] = [{"to s390x": "test-package"}]
extension_source["build-snaps"] = [{"to s390x": "test-snap"}]

project_path = new_dir / "snap/snapcraft.yaml"
(new_dir / "snap").mkdir()
Expand All @@ -172,12 +176,16 @@ def test_application_build_with_extensions(monkeypatch, extension_source, new_di
# Calling a lifecycle command will create a Project. Creating a Project
# without applying the extensions will fail because the "extensions" field
# will still be present on the yaml data, so it's enough to run "pull".
monkeypatch.setattr("sys.argv", ["snapcraft", "pull", "--destructive-mode"])
monkeypatch.setattr(
"sys.argv", ["snapcraft", "pull", "--destructive-mode", "--build-for", "s390x"]
)
app = application.create_app()
app.run()

project = app.get_project()
assert "fake-extension/fake-part" in project.parts
assert project.parts["snapcraft/core"]["build-packages"] == ["test-package"]
assert project.parts["snapcraft/core"]["build-snaps"] == ["test-snap"]


def test_application_managed_core20_fallback(monkeypatch, new_dir, mocker):
Expand Down
Loading