import 'dart:async';
import 'dart:convert';
import 'package:mam_pty/mam_pty.dart';
import 'package:test/test.dart';

void main() {
  test('PtySession runtime execution resolves process output', () async {
    final pty = await PtySession.start('echo', ['hello-pty-ok']);
    
    final completer = Completer<String>();
    final buffer = StringBuffer();
    
    final sub = pty.stdout.listen((data) {
      buffer.write(utf8.decode(data));
    }, onDone: () {
      completer.complete(buffer.toString());
    });
    
    final result = await completer.future.timeout(const Duration(seconds: 3));
    sub.cancel();
    pty.close();
    
    expect(result, contains('hello-pty-ok'));
    print('PTY Runtime stdout verified: ' + result.trim());
  });
}
