diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 97c7c1f7..686a1cc5 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -6,7 +6,9 @@ import subprocess import sys +import os from pathlib import Path +import datetime, time from pytest_cookies.plugin import Cookies, Result import pytest @@ -34,6 +36,7 @@ def baked_project(cookies: Cookies, request) -> Result: extra_context={ "project_slug": "DummyProject", "project_name": "dummy-project", + "author_email": "you@example.com", "default_docker_registry": "test.test.com", "docker_base": request.param, } @@ -43,17 +46,27 @@ def baked_project(cookies: Cookies, request) -> Result: assert result.exit_code == 0 return result - @pytest.mark.parametrize( "commands_on_baked_project", ( - "ls -la .; make help", + # "ls -la .; make help", # TODO: cannot use `source` to activate venvs ... not sure how to proceed here. Suggestions? - ## "make devenv; source .venv/bin/activate && make build info-build test", + # No need whatsoever, venv only needed for cookiecutter - once it is build, can use "make build" directly + "make build", ), ) def test_make_workflows(baked_project: Result, commands_on_baked_project: str): working_dir = baked_project.project_path - subprocess.run( - ["/bin/bash", "-c", commands_on_baked_project], cwd=working_dir, check=True + results = subprocess.run( + ["/bin/bash", "-c", commands_on_baked_project], cwd=working_dir, + # check=True, + capture_output=True, ) + + if results.returncode != 0: + current_time = datetime.datetime.now().strftime("%Y%m%d.%H%M%S%d"); time.sleep(1) # make sure not two test w same name + output_std_dir = current_dir.parent / "tmp" / "stderr" + os.makedirs(output_std_dir, exist_ok=True) + with open(output_std_dir / f"stderr_{current_time}.txt", "w+") as f: + print(results.stderr.decode(), file=f) + raise RuntimeError("Subprocess did not run correctly")