- CMakeLists.txt: builds turboquant as static library - TURBOQUANT_BUILD_TESTS option enables ctest roundtrip tests - tests/roundtrip_test.cpp: validates zero-vector roundtrip and gaussian cosine similarity (>=0.99) - Makefile wrapper for convenience (build/test/clean targets) - Addresses contributor feedback on spec-to-code gap and CI from #17
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import pathlib
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
REPO_ROOT = pathlib.Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class StandaloneBuildTest(unittest.TestCase):
|
|
def test_cmake_builds_and_runs_ctest(self) -> None:
|
|
build_dir = pathlib.Path(tempfile.mkdtemp(prefix="turboquant-cmake-"))
|
|
self.addCleanup(lambda: shutil.rmtree(build_dir, ignore_errors=True))
|
|
|
|
configure = subprocess.run(
|
|
[
|
|
"cmake",
|
|
"-S",
|
|
str(REPO_ROOT),
|
|
"-B",
|
|
str(build_dir),
|
|
"-DTURBOQUANT_BUILD_TESTS=ON",
|
|
],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
if configure.returncode != 0:
|
|
self.fail(
|
|
"cmake configure failed\n"
|
|
f"stdout:\n{configure.stdout}\n"
|
|
f"stderr:\n{configure.stderr}"
|
|
)
|
|
|
|
build = subprocess.run(
|
|
["cmake", "--build", str(build_dir)],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
if build.returncode != 0:
|
|
self.fail(
|
|
"cmake build failed\n"
|
|
f"stdout:\n{build.stdout}\n"
|
|
f"stderr:\n{build.stderr}"
|
|
)
|
|
|
|
ctest = subprocess.run(
|
|
["ctest", "--test-dir", str(build_dir), "--output-on-failure"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
if ctest.returncode != 0:
|
|
self.fail(
|
|
"ctest failed\n"
|
|
f"stdout:\n{ctest.stdout}\n"
|
|
f"stderr:\n{ctest.stderr}"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|