Skip to content

Commit

Permalink
tests: add tests for advanced grammar in root keywords
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <[email protected]>
  • Loading branch information
mr-cal committed Apr 23, 2024
1 parent 3107512 commit 101c8e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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:
- libogg-dev
- on 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

0 comments on commit 101c8e0

Please sign in to comment.