Skip to content

Commit 358d751

Browse files
committed
feat: add pytest for e2e testing
1 parent 8c5fe88 commit 358d751

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

engine/e2e-test/main.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
3+
from test_cli_engine_list import TestCliEngineList
4+
from test_cli_engine_get import TestCliEngineGet
5+
6+
if __name__ == "__main__":
7+
pytest.main([__file__, "-v"])
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import platform
2+
3+
import pytest
4+
from test_runner import run
5+
6+
7+
class TestCliEngineGet:
8+
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows-specific test")
9+
def test_engines_list_run_successfully_on_windows(self):
10+
# TODO: implement
11+
assert 0 == 0
12+
13+
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
14+
def test_engines_get_run_successfully_on_macos(self):
15+
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.llamacpp"])
16+
assert exit_code == 0, f"Get engine failed with error: {error}"
17+
18+
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
19+
def test_engines_get_llamacpp_on_macos(self):
20+
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.llamacpp"])
21+
assert exit_code == 0, f"Get engine failed with error: {error}"
22+
assert "Incompatible" not in output, f"cortex.llamacpp can only be Ready or Not Installed"
23+
24+
@pytest.mark.skipif(platform.system() != "Linux", reason="Linux-specific test")
25+
def test_engines_list_run_successfully_on_linux(self):
26+
# TODO: implement
27+
assert 0 == 0
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import platform
2+
3+
import pytest
4+
from test_runner import run
5+
6+
7+
class TestCliEngineList:
8+
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows-specific test")
9+
def test_engines_list_run_successfully_on_windows(self):
10+
exit_code, output, error = run("List engines", ["engines", "list"])
11+
assert exit_code == 0, f"List engines failed with error: {error}"
12+
assert "llama.cpp" in output
13+
14+
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
15+
def test_engines_list_run_successfully_on_macos(self):
16+
exit_code, output, error = run("List engines", ["engines", "list"])
17+
assert exit_code == 0, f"List engines failed with error: {error}"
18+
assert "llama.cpp" in output
19+
20+
@pytest.mark.skipif(platform.system() != "Linux", reason="Linux-specific test")
21+
def test_engines_list_run_successfully_on_linux(self):
22+
exit_code, output, error = run("List engines", ["engines", "list"])
23+
assert exit_code == 0, f"List engines failed with error: {error}"
24+
assert "llama.cpp" in output

engine/e2e-test/test_runner.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import platform
2+
import subprocess
3+
import os
4+
from typing import List, Tuple
5+
6+
7+
def run(name: str, arguments: List[str]):
8+
if platform.system() == "Windows":
9+
executable = "build\\cortex-cpp.exe"
10+
else:
11+
executable = "build/cortex-cpp"
12+
result = subprocess.run([executable] + arguments, capture_output=True, text=True)
13+
return result.returncode, result.stdout, result.stderr

0 commit comments

Comments
 (0)