Skip to content

Commit e70080d

Browse files
committed
test: add Windows CI coverage
1 parent 7514eff commit e70080d

4 files changed

Lines changed: 47 additions & 60 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
os: [ubuntu-latest, macos-latest]
14+
os: [ubuntu-latest, macos-latest, windows-latest]
1515
python-version: ["3.10", "3.12"]
1616

1717
steps:

corecoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""CoreCoder - Minimal AI coding agent inspired by Claude Code's architecture."""
22

3-
__version__ = "0.2.0"
3+
__version__ = "0.3.0"
44

55
from corecoder.agent import Agent
66
from corecoder.llm import LLM

tests/test_core.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import os
44
import pathlib
5-
import tempfile
65

76
from corecoder import Agent, LLM, Config, ALL_TOOLS, __version__
87
from corecoder.context import ContextManager, estimate_tokens
@@ -11,7 +10,7 @@
1110

1211

1312
def test_version():
14-
assert __version__ == "0.2.0"
13+
assert __version__ == "0.3.0"
1514

1615

1716
def test_public_api_exports():
@@ -122,25 +121,22 @@ def test_cost_estimation_unknown_model():
122121

123122
# --- Changed files tracking ---
124123

125-
def test_edit_tracks_changed_files():
124+
def test_edit_tracks_changed_files(tmp_path):
126125
from corecoder.tools.edit import _changed_files
127126
_changed_files.clear()
128127
edit = get_tool("edit_file")
129-
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
130-
f.write("aaa\nbbb\n")
131-
f.flush()
132-
edit.execute(file_path=f.name, old_string="aaa", new_string="zzz")
133-
assert any(f.name in p for p in _changed_files)
134-
os.unlink(f.name)
128+
path = tmp_path / "sample.py"
129+
path.write_text("aaa\nbbb\n")
130+
edit.execute(file_path=str(path), old_string="aaa", new_string="zzz")
131+
assert any(str(path) in p for p in _changed_files)
135132
_changed_files.clear()
136133

137134

138-
def test_write_tracks_changed_files():
135+
def test_write_tracks_changed_files(tmp_path):
139136
from corecoder.tools.edit import _changed_files
140137
_changed_files.clear()
141138
write = get_tool("write_file")
142-
path = tempfile.mktemp(suffix=".txt")
143-
write.execute(file_path=path, content="tracked\n")
144-
assert any("tracked" not in p and path.split("/")[-1] in p for p in _changed_files) or len(_changed_files) > 0
145-
os.unlink(path)
139+
path = tmp_path / "tracked.txt"
140+
write.execute(file_path=str(path), content="tracked\n")
141+
assert any("tracked" not in p and path.name in p for p in _changed_files) or len(_changed_files) > 0
146142
_changed_files.clear()

tests/test_tools.py

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for the tool system."""
22

33
import os
4+
import sys
45
import tempfile
56
from pathlib import Path
67

@@ -38,7 +39,7 @@ def test_bash_exit_code():
3839

3940
def test_bash_timeout():
4041
bash = get_tool("bash")
41-
r = bash.execute(command="sleep 10", timeout=1)
42+
r = bash.execute(command=f'"{sys.executable}" -c "import time; time.sleep(10)"', timeout=1)
4243
assert "timed out" in r
4344

4445

@@ -62,21 +63,19 @@ def test_bash_blocks_curl_pipe():
6263

6364
def test_bash_truncates_long_output():
6465
bash = get_tool("bash")
65-
r = bash.execute(command="python3 -c \"print('x' * 20000)\"")
66+
r = bash.execute(command=f'"{sys.executable}" -c "print(\'x\' * 20000)"')
6667
assert "truncated" in r
6768

6869

6970
# --- read_file ---
7071

71-
def test_read_file():
72+
def test_read_file(tmp_path):
7273
read = get_tool("read_file")
73-
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
74-
f.write("line1\nline2\nline3\n")
75-
f.flush()
76-
r = read.execute(file_path=f.name)
77-
assert "line1" in r
78-
assert "line2" in r
79-
os.unlink(f.name)
74+
path = tmp_path / "sample.txt"
75+
path.write_text("line1\nline2\nline3\n")
76+
r = read.execute(file_path=str(path))
77+
assert "line1" in r
78+
assert "line2" in r
8079

8180

8281
def test_read_file_not_found():
@@ -85,14 +84,12 @@ def test_read_file_not_found():
8584
assert "not found" in r.lower() or "Error" in r
8685

8786

88-
def test_read_file_offset_limit():
87+
def test_read_file_offset_limit(tmp_path):
8988
read = get_tool("read_file")
90-
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
91-
f.write("\n".join(f"line{i}" for i in range(100)))
92-
f.flush()
93-
r = read.execute(file_path=f.name, offset=10, limit=5)
94-
assert "line10" not in r or "line9" in r # offset is 1-based
95-
os.unlink(f.name)
89+
path = tmp_path / "sample.txt"
90+
path.write_text("\n".join(f"line{i}" for i in range(100)))
91+
r = read.execute(file_path=str(path), offset=10, limit=5)
92+
assert "line10" not in r or "line9" in r # offset is 1-based
9693

9794

9895
# --- write_file ---
@@ -119,38 +116,32 @@ def test_write_file_creates_dirs():
119116

120117
# --- edit_file ---
121118

122-
def test_edit_file_basic():
119+
def test_edit_file_basic(tmp_path):
123120
edit = get_tool("edit_file")
124-
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
125-
f.write("def foo():\n return 42\n")
126-
f.flush()
127-
r = edit.execute(file_path=f.name, old_string="return 42", new_string="return 99")
128-
assert "Edited" in r
129-
assert "---" in r # unified diff
130-
content = Path(f.name).read_text()
131-
assert "return 99" in content
132-
assert "return 42" not in content
133-
os.unlink(f.name)
134-
135-
136-
def test_edit_file_not_found_string():
121+
path = tmp_path / "sample.py"
122+
path.write_text("def foo():\n return 42\n")
123+
r = edit.execute(file_path=str(path), old_string="return 42", new_string="return 99")
124+
assert "Edited" in r
125+
assert "---" in r # unified diff
126+
content = path.read_text()
127+
assert "return 99" in content
128+
assert "return 42" not in content
129+
130+
131+
def test_edit_file_not_found_string(tmp_path):
137132
edit = get_tool("edit_file")
138-
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
139-
f.write("hello\n")
140-
f.flush()
141-
r = edit.execute(file_path=f.name, old_string="NONEXISTENT", new_string="x")
142-
assert "not found" in r.lower()
143-
os.unlink(f.name)
133+
path = tmp_path / "sample.py"
134+
path.write_text("hello\n")
135+
r = edit.execute(file_path=str(path), old_string="NONEXISTENT", new_string="x")
136+
assert "not found" in r.lower()
144137

145138

146-
def test_edit_file_duplicate_string():
139+
def test_edit_file_duplicate_string(tmp_path):
147140
edit = get_tool("edit_file")
148-
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
149-
f.write("dup\ndup\n")
150-
f.flush()
151-
r = edit.execute(file_path=f.name, old_string="dup", new_string="x")
152-
assert "2 times" in r
153-
os.unlink(f.name)
141+
path = tmp_path / "sample.py"
142+
path.write_text("dup\ndup\n")
143+
r = edit.execute(file_path=str(path), old_string="dup", new_string="x")
144+
assert "2 times" in r
154145

155146

156147
# --- glob ---

0 commit comments

Comments
 (0)