From c9039ec3563285cd69178e3c810b883faf02356f Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Mon, 26 Oct 2026 00:01:40 +0300 Subject: [PATCH] fix(ext-tester): the harness no longer imports logIgnored, so the standalone tester builds again; a test keeps its imports pure Dart --- .../extensions/harness/extension_harness.dart | 13 +++++-- .../harness/ext_tester_pure_dart_test.dart | 37 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 test/core/extensions/harness/ext_tester_pure_dart_test.dart diff --git a/lib/core/extensions/harness/extension_harness.dart b/lib/core/extensions/harness/extension_harness.dart index 03bafca4..59998240 100644 --- a/lib/core/extensions/harness/extension_harness.dart +++ b/lib/core/extensions/harness/extension_harness.dart @@ -9,7 +9,6 @@ import 'package:querya_desktop/core/extensions/harness/extension_protocol_profil import 'package:querya_desktop/core/extensions/rpc/json_rpc_stdio_client.dart'; import 'package:querya_desktop/core/extensions/sandbox/sandbox_launch_command.dart'; import 'package:querya_desktop/core/extensions/sandbox/sandbox_scratch_directory.dart'; -import 'package:querya_desktop/core/util/log_ignored.dart'; /// How to start the plugin process. final class HarnessLaunchRequest { @@ -135,7 +134,7 @@ final class _OsPluginProcess implements HarnessPluginProcess { try { await _process.exitCode.timeout(const Duration(seconds: 2)); } catch (e) { - logIgnored('extension_harness', e); + _ignored('extension_harness', e); } } @@ -541,7 +540,15 @@ Future _rssKb(int pid) async { return r.exitCode == 0 ? int.tryParse('${r.stdout}'.trim()) : null; } } catch (e) { - logIgnored('extension_harness', e); + _ignored('extension_harness', e); } return null; } + +/// A failure the harness goes on from (killing a process that already exited, +/// reading `ps`). This file is compiled into the standalone `querya-ext-tester` +/// from `lib/core/extensions` alone, so it cannot use `logIgnored` (Flutter and +/// the app's log): the line goes to stderr. +void _ignored(String where, Object error) { + stderr.writeln('[$where] ignored: $error'); +} diff --git a/test/core/extensions/harness/ext_tester_pure_dart_test.dart b/test/core/extensions/harness/ext_tester_pure_dart_test.dart new file mode 100644 index 00000000..645f24d5 --- /dev/null +++ b/test/core/extensions/harness/ext_tester_pure_dart_test.dart @@ -0,0 +1,37 @@ +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +/// `querya-ext-tester` is built by `scripts/ci/build_ext_tester.sh` from +/// `lib/core/extensions` and `package:path` alone, in a throwaway package. An +/// import of Flutter or of anything outside that folder breaks the release +/// build, and no other job builds the tester: beta.2 stopped on `logIgnored`. +void main() { + test('the tester imports only dart:, package:path and core/extensions', () { + final importRe = RegExp(r'''^import\s+'([^']+)';''', multiLine: true); + final seen = {}; + final queue = ['bin/querya_ext_tester.dart']; + final bad = []; + + while (queue.isNotEmpty) { + final file = queue.removeLast(); + if (!seen.add(file)) continue; + final text = File(file).readAsStringSync(); + for (final m in importRe.allMatches(text)) { + final uri = m.group(1)!; + if (uri.startsWith('dart:') || uri.startsWith('package:path/')) { + continue; + } + const own = 'package:querya_desktop/'; + if (uri.startsWith('${own}core/extensions/')) { + queue.add('lib/${uri.substring(own.length)}'); + } else { + bad.add('$file imports $uri'); + } + } + } + + expect(bad, isEmpty, reason: bad.join('\n')); + expect(seen.length, greaterThan(3)); + }); +}