Phase 6: Plattformprüfungen und absolute RGB-Farben, Change 05 archivieren

This commit is contained in:
2026-09-07 21:12:25 +02:00
parent 5aa920b768
commit 796564795a
55 changed files with 3772 additions and 200 deletions

View File

@@ -2,6 +2,7 @@
"""Headless Unix PTY smoke: real terminal handoff, child Ctrl+C and IDE resume.
Run after cargo build -p tb-ide: python3 tests/support/ide-execution-pty.py
"""
import argparse
import fcntl
import os
from pathlib import Path
@@ -13,10 +14,10 @@ import tempfile
import termios
import time
binary = Path(__file__).resolve().parents[2] / 'target/debug/tb'
def exercise(abort=False, file_shell=False):
def exercise(binary, transcript_dir=None, abort=False, file_shell=False):
with tempfile.TemporaryDirectory(prefix='tb-pty-') as directory:
source = Path(directory) / 'main.bas'
command = "printf '\\nWAITING_CHILD\\n'; exec sleep 30" if abort else "printf '\\nSHELL_PROOF\\n'; exit 7"
@@ -32,7 +33,7 @@ def exercise(abort=False, file_shell=False):
os.dup2(slave, fd)
os.close(master)
os.close(slave)
os.environ['TERM'] = 'xterm-256color'
os.environ.setdefault('TERM', 'xterm-256color')
os.environ['XDG_CONFIG_HOME'] = directory
# Keep the controlling terminal alive while checking restoration.
signal.signal(signal.SIGINT, lambda *_: None)
@@ -83,7 +84,17 @@ def exercise(abort=False, file_shell=False):
transcript.extend(os.read(master, 65536))
assert transcript.count(b'?1049h') >= 2
assert transcript.count(b'?1049l') >= 2
# Tatsächliche Ausgabe muss auch bei NO_COLOR/fehlender Erkennung
# dieselben absoluten IDE-Farben enthalten, ohne Palettenänderung.
assert b'38;2;170;170;170' in transcript
assert b'48;2;0;0;170' in transcript
assert b'48;2;170;0;170' in transcript
assert b'38;5;' not in transcript and b'48;5;' not in transcript
assert b'\x1b]' not in transcript
finally:
if transcript_dir:
name = 'file-shell' if file_shell else 'shell-abort' if abort else 'shell-exit'
(transcript_dir / (name + '.ansi')).write_bytes(transcript)
if not reaped:
os.killpg(pid, signal.SIGKILL)
os.waitpid(pid, 0)
@@ -91,6 +102,18 @@ def exercise(abort=False, file_shell=False):
os.close(slave)
for kwargs in ({}, {'abort': True}, {'file_shell': True}):
exercise(**kwargs)
print('PASS', kwargs or {'shell_exit': 7})
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--binary', type=Path, default=Path(__file__).resolve().parents[2] / 'target/debug/tb')
parser.add_argument('--transcript-dir', type=Path)
args = parser.parse_args()
binary = args.binary.resolve(strict=True)
if args.transcript_dir:
args.transcript_dir.mkdir(parents=True, exist_ok=True)
for kwargs in ({}, {'abort': True}, {'file_shell': True}):
exercise(binary, args.transcript_dir, **kwargs)
print('PASS', kwargs or {'shell_exit': 7})
if __name__ == '__main__':
main()