Skip to content

Commit

Permalink
ci: fix run
Browse files Browse the repository at this point in the history
  • Loading branch information
mkundu1 committed Nov 26, 2024
1 parent 4971300 commit 88c0713
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
35 changes: 19 additions & 16 deletions .ci/fluent_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,25 @@ def run_fluent_test(
stderr=True,
auto_remove=True,
)
while True:
container.reload()
if container.status == "exited":
break
stderr = container.logs(stdout=False, stderr=True)
if stderr:
stderr = stderr.decode()
for line in stderr.split("\n"):
if line.strip().startswith("Error:"):
if "Expected exception" in line: # for check_assert.py
container.stop()
else:
raise FluentRuntimeError(line)
sleep(1)
logging.debug(container.logs(stderr=True).decode())
container.remove()
try:
while True:
container.reload()
if container.status == "exited":
break
stderr = container.logs(stdout=False, stderr=True)
if stderr:
stderr = stderr.decode()
for line in stderr.split("\n"):
if line.strip().startswith("Error:"):
if "Expected exception" in line: # for check_assert.py
container.stop()
else:
raise FluentRuntimeError(line)
sleep(1)
logging.debug(container.logs(stderr=True).decode())
container.remove()
except docker.errors.NotFound:
pass


MAX_TEST_PATH_LENGTH = 100
Expand Down
11 changes: 8 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def pytest_collection_finish(session):
if skip:
continue
fluent_test_dir = fluent_test_root / item.module.__name__ / item.name
fluent_test_dir.mkdir(parents=True, exist_ok=True)
fluent_test_config = fluent_test_dir / "test.yaml"
fluent_test_file = fluent_test_dir / "test.py"
launcher_args = ""
Expand All @@ -122,18 +121,24 @@ def pytest_collection_finish(session):
if param in launcher_args_by_fixture:
launcher_args = launcher_args_by_fixture[param]
break
fluent_test_dir.mkdir(parents=True, exist_ok=True)
with open(fluent_test_config, "w") as f:
f.write(f"launcher_args: {launcher_args}\n")
with open(fluent_test_file, "w") as f:
f.write(f"from ....{item.module.__name__} import {item.name}\n")
f.write("from ....fluent_fixtures import (\n")
f.write("import sys\n")
f.write('sys.path.append("/testing")\n')
f.write(
f"from {item.module.__name__} import {item.name} # noqa: E402\n"
)
f.write("from fluent_fixtures import ( # noqa: E402\n")
for param in parameters:
f.write(f" {param},\n")
f.write(")\n")
f.write("\n")
f.write(f"{item.name}(")
f.write(", ".join([f"{p}(globals())" for p in parameters]))
f.write(")\n")
f.write("exit()\n")
print(f"Written {fluent_test_file}")
session.items = []
session.testscollected = 0
Expand Down

0 comments on commit 88c0713

Please sign in to comment.