-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"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") |