Raise the declared minimums in pubspec.yaml to what our deps already require: Flutter >=3.35.0 / Dart >=3.9.0 (was 3.19.0 / 3.5.0). alchemist 0.12 needs Flutter 3.32; Dart 3.9 first ships in Flutter 3.35, so 3.35 is the binding floor. Pin the exact build toolchain in .fvmrc (Flutter 3.44.1). Moving to the Dart 3.9 language level switches `dart format` to the new "tall" style and enables two new lints. This commit is the resulting mechanical churn, isolated from any behaviour change: - whole-tree `dart format` reformat (tall style) - `dart fix` for unnecessary_underscores + use_null_aware_elements No runtime behaviour change; `make test` green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
79 lines
2.7 KiB
Dart
79 lines
2.7 KiB
Dart
import 'package:clide/kernel/kernel.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('Logger', () {
|
|
test('respects minLevel — lower-level messages drop silently', () {
|
|
final out = <LogRecord>[];
|
|
final log = Logger(minLevel: LogLevel.warn, sinks: [out.add]);
|
|
log.debug('s', 'dropped');
|
|
log.info('s', 'dropped');
|
|
log.warn('s', 'kept');
|
|
log.error('s', 'kept');
|
|
expect(out.map((r) => r.message), ['kept', 'kept']);
|
|
});
|
|
|
|
test('minLevel is mutable post-construction', () {
|
|
final out = <LogRecord>[];
|
|
final log = Logger(minLevel: LogLevel.error, sinks: [out.add]);
|
|
log.info('s', 'dropped');
|
|
log.minLevel = LogLevel.info;
|
|
log.info('s', 'kept');
|
|
expect(out.map((r) => r.message), ['kept']);
|
|
});
|
|
|
|
test('error + stack trace propagate to sinks', () {
|
|
final out = <LogRecord>[];
|
|
final log = Logger(minLevel: LogLevel.debug, sinks: [out.add]);
|
|
final st = StackTrace.current;
|
|
log.error('s', 'boom', error: 'e', stackTrace: st);
|
|
expect(out, hasLength(1));
|
|
expect(out.first.level, LogLevel.error);
|
|
expect(out.first.error, 'e');
|
|
expect(out.first.stackTrace, st);
|
|
});
|
|
|
|
test('broken sink does not kill the logger', () {
|
|
final good = <LogRecord>[];
|
|
final log = Logger(minLevel: LogLevel.info, sinks: [(_) => throw StateError('bad sink'), good.add]);
|
|
log.info('s', 'still delivered');
|
|
expect(good, hasLength(1));
|
|
});
|
|
|
|
test('records stream for subscribers', () async {
|
|
final log = Logger(minLevel: LogLevel.info);
|
|
final out = <LogRecord>[];
|
|
final sub = log.records.listen(out.add);
|
|
log.info('s', 'm1');
|
|
log.info('s', 'm2');
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(out.map((r) => r.message), ['m1', 'm2']);
|
|
await sub.cancel();
|
|
await log.dispose();
|
|
});
|
|
|
|
test('addSink appends without replacing', () {
|
|
final a = <LogRecord>[];
|
|
final b = <LogRecord>[];
|
|
final log = Logger(minLevel: LogLevel.info, sinks: [a.add]);
|
|
log.addSink(b.add);
|
|
log.info('s', 'hello');
|
|
expect(a, hasLength(1));
|
|
expect(b, hasLength(1));
|
|
});
|
|
|
|
test('trace records emit at minLevel.trace + are filtered above it', () {
|
|
final got = <LogRecord>[];
|
|
final log = Logger(minLevel: LogLevel.trace, sinks: [got.add]);
|
|
log.trace('s', 'low-level detail');
|
|
expect(got, hasLength(1));
|
|
expect(got.first.level, LogLevel.trace);
|
|
// Same call at info-level is filtered.
|
|
got.clear();
|
|
final filtered = Logger(minLevel: LogLevel.info, sinks: [got.add]);
|
|
filtered.trace('s', 'still detail');
|
|
expect(got, isEmpty);
|
|
});
|
|
});
|
|
}
|