Skip to content

Commit

Permalink
Use jinja in extra page example
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoesters committed Nov 26, 2024
1 parent f088d7c commit 881305e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
14 changes: 13 additions & 1 deletion examples/exe_extra_pages/construct.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
name: extraPages
{% if os.environ.get("POST_INSTALL_PAGES_LIST") %}
{% set name = "extraPages" %}
{% else %}
{% set name = "extraPageSingle" %}
{% endif %}
name: {{ name }}
version: X
installer_type: all
channels:
- http://repo.anaconda.com/pkgs/main/
specs:
- python
{% if os.environ.get("POST_INSTALL_PAGES_LIST") %}
post_install_pages:
- extra_page_1.nsi
- extra_page_2.nsi
{% else %}
post_install_pages: extra_page_1.nsi
{% endif %}
26 changes: 5 additions & 21 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,28 +378,12 @@ def test_example_customized_welcome_conclusion(tmp_path, request):
_run_installer(input_path, installer, install_dir, request=request)


@pytest.mark.parametrize(
"extra_pages",
(
pytest.param(["extra_page_1.nsi", "extra_page_2.nsi"], id="two pages"),
pytest.param("extra_page_1.nsi", id="single page"),
)
)
@pytest.mark.parametrize("extra_pages", ("str", "list"))
@pytest.mark.skipif(sys.platform != "win32", reason="Windows only")
def test_example_extra_pages_win(tmp_path, request, extra_pages):
recipe_path = _example_path("exe_extra_pages")
input_path = tmp_path / "input"
shutil.copytree(str(recipe_path), str(input_path))
construct_yaml = input_path / "construct.yaml"
content = construct_yaml.read_text()
if isinstance(extra_pages, str):
content += f"post_install_pages: {extra_pages}\n"
content = content.replace("extraPages", "extraPage")
else:
content += "post_install_pages:\n"
for page in extra_pages:
content += f" - {page}\n"
construct_yaml.write_text(content)
def test_example_extra_pages_win(tmp_path, request, extra_pages, monkeypatch):
if extra_pages == "list":
monkeypatch.setenv("POST_INSTALL_PAGES_LIST", "1")
input_path = _example_path("exe_extra_pages")
for installer, install_dir in create_installer(input_path, tmp_path):
_run_installer(input_path, installer, install_dir, request=request)

Expand Down

0 comments on commit 881305e

Please sign in to comment.