Skip to content

Commit 95c4923

Browse files
author
SentienceDEV
committed
fix windows
1 parent 65d95ac commit 95c4923

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,20 @@ jobs:
4444
python << 'PYEOF'
4545
import re
4646
import os
47+
import sys
48+
49+
# Set UTF-8 encoding for Windows compatibility
50+
if sys.platform == 'win32':
51+
import io
52+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
53+
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
54+
4755
file_path = 'sentience/agent_runtime.py'
4856
print(f'=== Auto-fix check for {file_path} ===')
4957
try:
5058
if not os.path.exists(file_path):
5159
print(f'ERROR: {file_path} not found!')
52-
exit(1)
60+
sys.exit(1)
5361
5462
with open(file_path, 'r', encoding='utf-8') as f:
5563
content = f.read()
@@ -71,22 +79,22 @@ jobs:
7179
with open(file_path, 'r', encoding='utf-8') as f:
7280
verify_content = f.read()
7381
if 'self.assertTrue(' in verify_content:
74-
print('ERROR: Auto-fix failed! File still contains self.assertTrue(')
75-
exit(1)
82+
print('ERROR: Auto-fix failed! File still contains self.assertTrue(')
83+
sys.exit(1)
7684
else:
77-
print(' Auto-fixed: Replaced self.assertTrue( with self.assert_(')
78-
print(' Verified: File no longer contains self.assertTrue(')
85+
print('OK: Auto-fixed: Replaced self.assertTrue( with self.assert_(')
86+
print('OK: Verified: File no longer contains self.assertTrue(')
7987
else:
80-
print(' Source file is correct (uses self.assert_())')
88+
print('OK: Source file is correct (uses self.assert_())')
8189
except Exception as e:
8290
print(f'ERROR in auto-fix: {e}')
8391
import traceback
8492
traceback.print_exc()
85-
exit(1)
93+
sys.exit(1)
8694
PYEOF
8795
# Verify source file is fixed before installation
8896
echo "=== Verifying source file after auto-fix ==="
89-
python -c "with open('sentience/agent_runtime.py', 'r') as f: content = f.read(); assert 'self.assertTrue(' not in content, 'Source file still has self.assertTrue( after auto-fix!'; print(' Source file verified: uses self.assert_()')"
97+
python -c "import sys; import io; sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace') if sys.platform == 'win32' else sys.stdout; content = open('sentience/agent_runtime.py', 'r', encoding='utf-8').read(); assert 'self.assertTrue(' not in content, 'Source file still has self.assertTrue( after auto-fix!'; print('OK: Source file verified: uses self.assert_()')"
9098
9199
# Force reinstall to ensure latest code
92100
pip install --no-cache-dir --force-reinstall -e ".[dev]"
@@ -121,14 +129,14 @@ jobs:
121129
print(f' Current dir: {cwd}')
122130
print(f' This might be using PyPI package instead of local source!')
123131
else:
124-
print(f' Package is from local source: {pkg_path}')
132+
print(f'OK: Package is from local source: {pkg_path}')
125133
126134
source = inspect.getsource(AgentRuntime.assert_done)
127135
print('\nassert_done method source:')
128136
print(source)
129137
print('\n=== Analysis ===')
130138
if 'self.assertTrue(' in source:
131-
print('ERROR: Found self.assertTrue( in installed package!')
139+
print('ERROR: Found self.assertTrue( in installed package!')
132140
print('This means the source code on this branch still has the bug.')
133141
print('\nProblematic lines:')
134142
for i, line in enumerate(source.split('\n'), 1):
@@ -137,10 +145,10 @@ jobs:
137145
print('\nThe source file in the repo should be checked and fixed.')
138146
exit(1)
139147
elif 'self.assert_(' in source:
140-
print('OK: assert_done uses self.assert_( correctly')
148+
print('OK: assert_done uses self.assert_( correctly')
141149
else:
142-
print('? WARNING: Could not find assert_ method call')
143-
exit(1)
150+
print('WARNING: Could not find assert_ method call')
151+
sys.exit(1)
144152
PYEOF
145153
146154
- name: Verify source code

0 commit comments

Comments
 (0)