Skip to content

Commit

Permalink
wip - get stderr of make build
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Garcia Ordonez committed Aug 28, 2024
1 parent 0f33464 commit 165d368
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,6 +36,7 @@ def baked_project(cookies: Cookies, request) -> Result:
extra_context={
"project_slug": "DummyProject",
"project_name": "dummy-project",
"author_email": "[email protected]",
"default_docker_registry": "test.test.com",
"docker_base": request.param,
}
Expand All @@ -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")

0 comments on commit 165d368

Please sign in to comment.