Files
clide/test/ipc/errno_mapping_test.dart
jpmschweitzerandClaude Opus 4.7 72a3dce4a3
test / unit + widget + golden + a11y (push) Failing after 32s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m2s
test sweep: foundational systems — files / ipc errno / panes (T-91)
Three small foundational test additions:

- test/files/watcher_test.dart (new, 8 tests): FileChangeKind
  fromEvent across every FileSystemEvent.type + wire getter,
  FileChange.toJson, FileWatcher end-to-end (created event,
  ignored-path filtering, idempotent start, stop teardown).
- ignore_test: trailing /**, bare **, ? glob-pattern branches in
  the regex compiler.
- path_safety_test: PathOutsideRoot.toString embeds the three
  fields.
- ipc/errno_mapping_test: ENOTDIR / ENOMEM / EAGAIN branches in
  errnoToIpcError that weren't previously hit.
- panes/registry_test: RecordingEventSink.ofSubsystem filter.

Coverage: src/files/watcher.dart 10/36 -> ~ all; ignore.dart +
path_safety.dart residuals closed; ipc/errno_mapping.dart 3 added
branches; panes/event_sink.dart 100%.

Total coverage 90.53% -> 90.99%.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 10:19:07 +02:00

75 lines
2.9 KiB
Dart

import 'package:clide/src/ipc/errno_mapping.dart';
import 'package:clide/src/ipc/schema_v1.dart';
import 'package:test/test.dart';
void main() {
group('errnoToIpcError', () {
test('ENOENT → notFound with target', () {
final err = errnoToIpcError(errno: PosixErrno.enoent, op: 'pane.spawn', target: 'claude');
expect(err.kind, IpcErrorKind.notFound);
expect(err.code, IpcExitCode.notFound);
expect(err.message, contains('claude'));
expect(err.message, contains('not found'));
});
test('EACCES → userError with hint', () {
final err = errnoToIpcError(errno: PosixErrno.eacces, op: 'editor.open', target: '/etc/shadow');
expect(err.kind, IpcErrorKind.userError);
expect(err.code, IpcExitCode.userError);
expect(err.message, contains('permission denied'));
expect(err.hint, isNotNull);
});
test('EISDIR → userError', () {
final err = errnoToIpcError(errno: PosixErrno.eisdir, op: 'editor.open', target: 'src/');
expect(err.kind, IpcErrorKind.userError);
expect(err.message, contains('is a directory'));
});
test('EEXIST → conflict', () {
final err = errnoToIpcError(errno: PosixErrno.eexist, op: 'files.create', target: 'README.md');
expect(err.kind, IpcErrorKind.conflict);
expect(err.code, IpcExitCode.conflict);
});
test('EMFILE → toolError with hint', () {
final err = errnoToIpcError(errno: PosixErrno.emfile, op: 'pane.spawn');
expect(err.kind, IpcErrorKind.toolError);
expect(err.message, contains('too many open files'));
expect(err.hint, isNotNull);
});
test('unknown errno falls through to toolError', () {
final err = errnoToIpcError(errno: 999, op: 'pane.spawn');
expect(err.kind, IpcErrorKind.toolError);
expect(err.code, IpcExitCode.toolError);
expect(err.message, contains('errno=999'));
});
test('raw message overrides errno suffix in fallback', () {
final err = errnoToIpcError(errno: 999, op: 'pane.spawn', raw: 'kernel exploded');
expect(err.message, contains('kernel exploded'));
expect(err.message, isNot(contains('errno=999')));
});
test('ENOTDIR → user_error', () {
final e = errnoToIpcError(errno: PosixErrno.enotdir, op: 'files.ls', target: '/x');
expect(e.kind, IpcErrorKind.userError);
expect(e.message, contains('not a directory'));
});
test('ENOMEM → tool_error', () {
final e = errnoToIpcError(errno: PosixErrno.enomem, op: 'pty.spawn');
expect(e.kind, IpcErrorKind.toolError);
expect(e.message, contains('out of memory'));
});
test('EAGAIN → tool_error with retry hint', () {
final e = errnoToIpcError(errno: PosixErrno.eagain, op: 'pty.read');
expect(e.kind, IpcErrorKind.toolError);
expect(e.message, contains('temporarily unavailable'));
expect(e.hint, contains('retry'));
});
});
}