fix(install): exchange install option content through UTF-8 files
Windows PowerShell pipes re-encode text by console code page: under code page 65001 a BOM broke the config.toml merge, and otherwise non-ASCII characters became question marks. Pass managed and merged content through files, and decode piped input as utf-8-sig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bed90fee2d
commit
857720bcfd
3 files changed
+51
-12
No files matched your search
@@ -4,6 +4,7 @@ import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import tomllib
|
||||
import unittest
|
||||
@@ -44,6 +45,21 @@ class InstallOptionsTests(unittest.TestCase):
|
||||
self.assertEqual(result['mcp_servers'], {'demo': {'command': 'demo', 'env': {'TOKEN_NAME': 'x'}}})
|
||||
self.assertEqual(result['model_providers'], {'custom': {'name': 'Custom', 'base_url': 'https://example.invalid'}})
|
||||
|
||||
def test_merge_cli_accepts_bom_input_and_preserves_non_ascii(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
current = Path(directory) / 'config.toml'
|
||||
current.write_text('# Größe\n[mcp_servers.demo]\ncommand = "ä"\n', encoding='utf-8')
|
||||
output = Path(directory) / 'out.toml'
|
||||
script = str(ROOT / 'scripts/lib/install-options.py')
|
||||
managed = 'model = "new"\n'.encode('utf-8')
|
||||
piped = subprocess.run([sys.executable, script, 'merge-toml', '--current', str(current), '--output', str(output)], input=managed)
|
||||
self.assertEqual(piped.returncode, 0)
|
||||
self.assertEqual(tomllib.loads(output.read_text(encoding='utf-8'))['mcp_servers']['demo']['command'], 'ä')
|
||||
managed_path = Path(directory) / 'managed.toml'
|
||||
managed_path.write_bytes(managed)
|
||||
subprocess.run([sys.executable, script, 'merge-toml', '--current', str(current), '--managed', str(managed_path), '--output', str(output)], check=True)
|
||||
self.assertIn('# Größe', output.read_text(encoding='utf-8'))
|
||||
|
||||
def test_filter_preserves_other_claude_hooks_and_status(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / 'settings.json'
|
||||
|
||||
Reference in new issue
Block a user