re-tag PTY read-dependent tests as forkpty
Three session_test cases (echo-and-read, close, bare-command PATH) intermittently fail under the flutter test runner when other suites run in parallel — the pty master's reader-isolate output is empty even though the spawn succeeded. posix_spawn closed the fork-time deadlock but not the flutter-test-runner read stability issue. Push them back under `dart test`. Adds an untagged PATH-resolution test that asserts the spawn succeeds without reading output, so the resolution branch still contributes to coverage under `flutter test`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,12 +3,13 @@
|
|||||||
/// Exercises posix_spawn() end-to-end: spawn → child output through the
|
/// Exercises posix_spawn() end-to-end: spawn → child output through the
|
||||||
/// reader isolate. Linux + macOS only; skipped elsewhere.
|
/// reader isolate. Linux + macOS only; skipped elsewhere.
|
||||||
///
|
///
|
||||||
/// Per-test `tags: ['forkpty']` marks the tests that need `dart test`
|
/// Per-test `tags: ['forkpty']` marks the tests that depend on the
|
||||||
/// rather than the flutter test runner — currently just the
|
/// reader isolate delivering output from the master fd — reads from a
|
||||||
/// write/read-back bidirectional test (writes to the master fd never
|
/// pty master under the flutter test runner are unstable when other
|
||||||
/// reach the child under the flutter test runner; reads work fine).
|
/// suites run in parallel (intermittently empty). Only the
|
||||||
/// Everything else runs under `flutter test` and contributes to
|
/// synchronous-throw and resize tests stay untagged so they
|
||||||
/// coverage.
|
/// contribute to coverage under `flutter test`. The output-dependent
|
||||||
|
/// tests run via `dart test` per `ci/test.sh`.
|
||||||
library;
|
library;
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
@@ -23,7 +24,7 @@ void main() {
|
|||||||
if (!Platform.isLinux && !Platform.isMacOS) return;
|
if (!Platform.isLinux && !Platform.isMacOS) return;
|
||||||
|
|
||||||
group('NativePty', () {
|
group('NativePty', () {
|
||||||
test('spawns shell -c echo and reads output', () async {
|
test('spawns shell -c echo and reads output', tags: ['forkpty'], () async {
|
||||||
final s = NativePty.start(
|
final s = NativePty.start(
|
||||||
executable: '/bin/sh',
|
executable: '/bin/sh',
|
||||||
arguments: ['-c', 'echo hello-pty'],
|
arguments: ['-c', 'echo hello-pty'],
|
||||||
@@ -77,7 +78,7 @@ void main() {
|
|||||||
expect(buf.toString(), contains('write-test-ok'));
|
expect(buf.toString(), contains('write-test-ok'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('close kills child and closes output', () async {
|
test('close kills child and closes output', tags: ['forkpty'], () async {
|
||||||
final s = NativePty.start(
|
final s = NativePty.start(
|
||||||
executable: '/bin/sh',
|
executable: '/bin/sh',
|
||||||
arguments: [],
|
arguments: [],
|
||||||
@@ -98,7 +99,7 @@ void main() {
|
|||||||
expect(s.isClosed, isTrue);
|
expect(s.isClosed, isTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('bare command name resolves via the PATH env var', () async {
|
test('bare command name resolves via the PATH env var', tags: ['forkpty'], () async {
|
||||||
// 'sh' is a bare command; without resolution, execve would fail.
|
// 'sh' is a bare command; without resolution, execve would fail.
|
||||||
final s = NativePty.start(
|
final s = NativePty.start(
|
||||||
executable: 'sh',
|
executable: 'sh',
|
||||||
@@ -164,6 +165,25 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('start with a bare command name resolves it via PATH (no read)', () async {
|
||||||
|
// Resolves "cat" to /bin/cat (or wherever it lives on PATH).
|
||||||
|
// Doesn't read the master fd — that path is exercised by the
|
||||||
|
// forkpty-tagged version of this test under `dart test`.
|
||||||
|
final s = NativePty.start(
|
||||||
|
executable: 'cat',
|
||||||
|
arguments: const [],
|
||||||
|
columns: 80,
|
||||||
|
rows: 24,
|
||||||
|
workingDirectory: '/',
|
||||||
|
environment: {
|
||||||
|
...Platform.environment,
|
||||||
|
'TERM': 'xterm-256color',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
addTearDown(s.close);
|
||||||
|
expect(s.pid, greaterThan(0));
|
||||||
|
});
|
||||||
|
|
||||||
test('resize on a live PTY does not throw', () async {
|
test('resize on a live PTY does not throw', () async {
|
||||||
final s = NativePty.start(
|
final s = NativePty.start(
|
||||||
executable: '/bin/sh',
|
executable: '/bin/sh',
|
||||||
|
|||||||
Reference in New Issue
Block a user