feat: Introduce executable build for Onyx CLI, add its source, and implement new tests.

This commit is contained in:
olivier committed 2025-11-20 20:18:38 -05:00
1 parent e498031f10
commit af43694c98
33 files changed
+862 -22978

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
import subprocess
from pathlib import Path
import os
import shutil
# Setup test vault
vault_path = Path("test_vault_exe").resolve()
if vault_path.exists():
shutil.rmtree(vault_path)
vault_path.mkdir(exist_ok=True)
# Path to executable
exe_path = Path("dist/onyx.exe").resolve()
print(f"Testing executable at: {exe_path}")
# Create config for the test
# We need to set the config file location for the exe.
# The exe looks at Path.home() / '.onyx-cli' / 'config.yaml'
# We can't easily change Path.home() for a subprocess without changing env vars that python respects?
# On Windows, Path.home() usually uses USERPROFILE.
# Let's try setting USERPROFILE to a temp dir.
env = os.environ.copy()
temp_home = Path("temp_home").resolve()
temp_home.mkdir(exist_ok=True)
env["USERPROFILE"] = str(temp_home)
# Create config in temp home
config_dir = temp_home / ".onyx-cli"
config_dir.mkdir(parents=True, exist_ok=True)
(config_dir / "config.yaml").write_text(f"default_vault: test\nvaults:\n test: {str(vault_path).replace(os.sep, '/')}", encoding="utf-8")
# Run the command
cmd = [str(exe_path), "create", "exe_newline_test", "--content", "Line1\\nLine2", "--vault", "test"]
print(f"Running: {cmd}")
try:
result = subprocess.run(cmd, env=env, capture_output=True, text=True)
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)
if result.returncode != 0:
print("Command failed")
else:
note_path = vault_path / "exe_newline_test.md"
if note_path.exists():
content = note_path.read_text(encoding='utf-8-sig')
print(f"Content repr: {repr(content)}")
if '\n' in content and '\\n' not in content:
print("SUCCESS: Real newline found")
else:
print("FAILURE: Unexpected content")
else:
print("Note not created")
except Exception as e:
print(f"Error running exe: {e}")