generated from canonical/starbase
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow for multi-base builds (#598)
Signed-off-by: Callahan Kovacs <[email protected]>
- Loading branch information
Showing
4 changed files
with
46 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ | |
Project, | ||
constraints, | ||
) | ||
from craft_application.util import platforms | ||
|
||
PROJECTS_DIR = pathlib.Path(__file__).parent / "project_models" | ||
PARTS_DICT = {"my-part": {"plugin": "nil"}} | ||
|
@@ -170,15 +169,15 @@ def test_build_info_from_platforms(incoming, expected): | |
Platform(build_on=[arch], build_for=[arch]), | ||
id=arch, | ||
) | ||
for arch in platforms._ARCH_TRANSLATIONS_DEB_TO_PLATFORM | ||
for arch in craft_platforms.DebianArchitecture | ||
), | ||
*( | ||
pytest.param( | ||
{"build-on": arch}, | ||
Platform(build_on=[arch]), | ||
id=f"build-on-only-{arch}", | ||
) | ||
for arch in platforms._ARCH_TRANSLATIONS_DEB_TO_PLATFORM | ||
for arch in craft_platforms.DebianArchitecture | ||
), | ||
pytest.param( | ||
{"build-on": "amd64", "build-for": "riscv64"}, | ||
|
@@ -562,30 +561,39 @@ def test_unmarshal_invalid_repositories( | |
|
||
|
||
@pytest.mark.parametrize("model", [Project, BuildPlanner]) | ||
def test_platform_invalid_arch(model, basic_project_dict): | ||
basic_project_dict["platforms"] = {"unknown": None} | ||
@pytest.mark.parametrize("platform_label", ["unknown", "[email protected]:unknown"]) | ||
def test_platform_invalid_arch(model, platform_label, basic_project_dict): | ||
basic_project_dict["platforms"] = {platform_label: None} | ||
project_path = pathlib.Path("myproject.yaml") | ||
|
||
with pytest.raises(CraftValidationError) as error: | ||
model.from_yaml_data(basic_project_dict, project_path) | ||
|
||
assert error.value.args[0] == ( | ||
"Invalid architecture: 'unknown' must be a valid debian architecture." | ||
"Bad myproject.yaml content:\n" | ||
f"- 'unknown' is not a valid DebianArchitecture (in field 'platforms.{platform_label}.build-on')\n" | ||
f"- 'unknown' is not a valid DebianArchitecture (in field 'platforms.{platform_label}.build-for')" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("model", [Project, BuildPlanner]) | ||
@pytest.mark.parametrize("arch", ["unknown", "[email protected]:unknown"]) | ||
@pytest.mark.parametrize("field_name", ["build-on", "build-for"]) | ||
def test_platform_invalid_build_arch(model, field_name, basic_project_dict): | ||
basic_project_dict["platforms"] = {"amd64": {field_name: ["unknown"]}} | ||
def test_platform_invalid_build_arch(model, arch, field_name, basic_project_dict): | ||
basic_project_dict["platforms"] = {"amd64": {field_name: [arch]}} | ||
project_path = pathlib.Path("myproject.yaml") | ||
|
||
with pytest.raises(CraftValidationError) as error: | ||
model.from_yaml_data(basic_project_dict, project_path) | ||
|
||
assert error.value.args[0] == ( | ||
"Invalid architecture: 'unknown' must be a valid debian architecture." | ||
) | ||
error_lines = [ | ||
"Bad myproject.yaml content:", | ||
"- field 'build-on' required in 'platforms.amd64' configuration", | ||
f"- 'unknown' is not a valid DebianArchitecture (in field 'platforms.amd64.{field_name}')", | ||
] | ||
if field_name == "build-on": | ||
error_lines.pop(1) | ||
assert error.value.args[0] == "\n".join(error_lines) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|