The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
desktop tests: cap a hung test at 2 minutes
0xken1563530bfbeb99
diff --git a/desktop/test/flutter_test_config.dart b/desktop/test/flutter_test_config.dartnew file mode 100644index 000000000..47221cdd5--- /dev/null+++ b/desktop/test/flutter_test_config.dart@@ -0,0 +1,53 @@+import 'dart:async';+import 'dart:io';++import 'package:flutter_test/flutter_test.dart';++/// Runs before every test file under `test/`.+///+/// A `testWidgets` that never finishes waits the binding's own default — ten minutes — and ignores+/// `flutter test --timeout` (measured): a handful of hung tests turned a five-minute suite into+/// forty to sixty. Two minutes is far above anything that passes here; a test that really needs+/// longer (the e2e suites) says so with its own `timeout:`, which still wins.+///+/// ⚠️ Setting it means creating the test binding for EVERY file, and the binding installs+/// flutter_test's `HttpClient` mock — every request answers 400 — process-wide. Files that are not+/// widget tests never used to get it, and theirs talk to real loopback servers (the daemon's status,+/// the updater's manifest, the API client): over a hundred of them failed. [_LoopbackOnly] replaces+/// the mock with what it was for: no request leaves the machine, and loopback works as it did.+Future<void> testExecutable(FutureOr<void> Function() testMain) async {+ final binding = TestWidgetsFlutterBinding.ensureInitialized();+ if (binding is AutomatedTestWidgetsFlutterBinding) {+ binding.defaultTestTimeout = const Timeout(Duration(minutes: 2));+ }+ HttpOverrides.global = _LoopbackOnly();+ await testMain();+}++class _LoopbackOnly extends HttpOverrides {+ @override+ HttpClient createHttpClient(SecurityContext? context) {+ final client = super.createHttpClient(context);+ // A test that needs its own connection (the daemon's Unix socket) sets its own factory, which+ // replaces this one — so only plain host connections are checked here.+ client.connectionFactory = (uri, proxyHost, proxyPort) {+ final host = proxyHost ?? uri.host;+ final port = proxyPort ?? uri.port;+ if (!_isLoopback(host)) {+ throw SocketException(+ 'Network is disabled in tests ($host). Use a loopback server or inject a transport.',+ );+ }+ return uri.isScheme('https') || uri.isScheme('wss')+ ? SecureSocket.startConnect(host, port, context: context)+ : Socket.startConnect(host, port);+ };+ return client;+ }+}++bool _isLoopback(String host) {+ if (host == 'localhost') return true;+ final address = InternetAddress.tryParse(host);+ return address != null && address.isLoopback;+}diff --git a/desktop/test/connected_semantics_test.dart b/desktop/test/own_binding/connected_semantics_test.dartsimilarity index 97%rename from desktop/test/connected_semantics_test.dartrename to desktop/test/own_binding/connected_semantics_test.dartindex a8327f4db..924af3216 100644--- a/desktop/test/connected_semantics_test.dart+++ b/desktop/test/own_binding/connected_semantics_test.dart@@ -105,7 +105,9 @@ void axTest(String name, WidgetTesterCallback body) => testWidgets();void main() {- final binding = _Binding();+ final binding = _Binding()+ // The suite's two-minute cap (test/flutter_test_config.dart), which this directory opts out of.+ ..defaultTestTimeout = const Timeout(Duration(minutes: 2));setUp(() {binding.guarded = true;binding.batches.clear();diff --git a/desktop/test/own_binding/flutter_test_config.dart b/desktop/test/own_binding/flutter_test_config.dartnew file mode 100644index 000000000..eeaa54237--- /dev/null+++ b/desktop/test/own_binding/flutter_test_config.dart@@ -0,0 +1,7 @@+import 'dart:async';++/// Tests here construct their own test binding in `main` (a subclass with production mixins and+/// recording hooks), so they cannot run under `test/flutter_test_config.dart`, which creates the+/// standard binding first. Only the nearest config applies, so this one opts out of that. Each+/// file sets the two-minute `defaultTestTimeout` on its own binding instead.+Future<void> testExecutable(FutureOr<void> Function() testMain) => Future.sync(testMain);diff --git a/desktop/test/support/experimental_settings.dart b/desktop/test/support/experimental_settings.dartindex 98a316460..b5dc506bc 100644--- a/desktop/test/support/experimental_settings.dart+++ b/desktop/test/support/experimental_settings.dart@@ -34,6 +34,10 @@ class MemoryExperimentalTransport implements ExperimentalSettingsTransport {}}+/// ⚠️ Built in a `setUp`, `await refresh()` there too. The constructor starts the first read from+/// the real zone; a `testWidgets` body that awaits it (any [set] before it lands does) waits in the+/// fake-async zone, whose microtasks nothing flushes without a pump — the test hangs until the+/// binding's timeout instead of failing. Built inside the test body, everything stays in one zone.class MemoryExperimentalFeaturesStore extends ExperimentalFeaturesStore {MemoryExperimentalFeaturesStore({required LocalKeyValueStore storage}): super(pollInterval: Duration.zero) {