From 8951f55a7e9d7fea2435868f8a2d84db4d913c33 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 10:29:35 +0200 Subject: [PATCH 01/11] Logging --- dwds/test/fixtures/context.dart | 50 ++++++++++++++------- dwds/test/hot_restart_breakpoints_test.dart | 3 ++ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 095f66cef..4b759491f 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -132,6 +132,7 @@ class TestContext { TestContext(this.project, this.sdkConfigurationProvider); Future setUp({ + int setupNum = -1, TestSettings testSettings = const TestSettings(), TestAppMetadata appMetadata = const TestAppMetadata.externalApp(), TestDebugSettings debugSettings = @@ -154,12 +155,14 @@ class TestContext { DartUri.currentDirectory = project.absolutePackageDirectory; - _logger.info( - 'Serving: ${project.directoryToServe}/${project.filePathToServe}', - ); - _logger.info('Project: ${project.absolutePackageDirectory}'); - _logger.info('Packages: ${project.packageConfigFile}'); - _logger.info('Entry: ${project.dartEntryFilePath}'); + void log(String s) { + _logger.info('${DateTime.now()}: ($setupNum): $s'); + } + + log('Serving: ${project.directoryToServe}/${project.filePathToServe}'); + log('Project: ${project.absolutePackageDirectory}'); + log('Packages: ${project.packageConfigFile}'); + log('Entry: ${project.dartEntryFilePath}'); configureLogWriter(); @@ -174,12 +177,17 @@ class TestContext { _outputDir = systemTempDir.createTempSync('foo bar'); final chromeDriverPort = await findUnusedPort(); + log('Picked chromeDriverPort = $chromeDriverPort'); final chromeDriverUrlBase = 'wd/hub'; try { - _chromeDriver = await Process.start('chromedriver$_exeExt', [ - '--port=$chromeDriverPort', - '--url-base=$chromeDriverUrlBase', - ]); + final localDriver = + _chromeDriver = await Process.start('chromedriver$_exeExt', [ + '--port=$chromeDriverPort', + '--url-base=$chromeDriverUrlBase', + ]); + log( + 'Started chrome driver - identity hash code = ${identityHashCode(localDriver)}', + ); // On windows this takes a while to boot up, wait for the first line // of stdout as a signal that it is ready. final stdOutLines = @@ -194,14 +202,11 @@ class TestContext { .transform(const LineSplitter()) .asBroadcastStream(); - stdOutLines.listen( - (line) => _logger.finest('ChromeDriver stdout: $line'), - ); - stdErrLines.listen( - (line) => _logger.warning('ChromeDriver stderr: $line'), - ); + stdOutLines.listen((line) => log('ChromeDriver stdout: $line')); + stdErrLines.listen((line) => log('ChromeDriver stderr: $line')); - await stdOutLines.first; + final firstLine = await stdOutLines.first; + log('Notice first line = $firstLine'); } catch (e) { throw StateError( 'Could not start ChromeDriver. Is it installed?\nError: $e', @@ -221,6 +226,7 @@ class TestContext { var filePathToServe = project.filePathToServe; _port = await findUnusedPort(); + log('Port #2: $_port'); switch (testSettings.compilationMode) { case CompilationMode.buildDaemon: { @@ -337,6 +343,7 @@ class TestContext { ); final assetServerPort = await findUnusedPort(); + log('Port #3: $assetServerPort'); _hostname = appMetadata.hostname; await webRunner.run( frontendServerFileSystem, @@ -391,6 +398,7 @@ class TestContext { } final debugPort = await findUnusedPort(); + log('Port #4: $debugPort'); if (testSettings.launchChrome) { // If the environment variable DWDS_DEBUG_CHROME is set to the string // true then Chrome will be launched with a UI rather than headless. @@ -417,6 +425,14 @@ class TestContext { ], }, }); + log( + 'Now creating web driver for chrome driver port; ' + 'going for port $chromeDriverPort', + ); + log( + ' -> notice chrome driver identity hash code is ' + '${identityHashCode(_chromeDriver)}', + ); _webDriver = await createDriver( spec: WebDriverSpec.JsonWire, desired: capabilities, diff --git a/dwds/test/hot_restart_breakpoints_test.dart b/dwds/test/hot_restart_breakpoints_test.dart index 1a83b5f67..72a2eb360 100644 --- a/dwds/test/hot_restart_breakpoints_test.dart +++ b/dwds/test/hot_restart_breakpoints_test.dart @@ -21,6 +21,8 @@ import 'fixtures/context.dart'; import 'fixtures/project.dart'; import 'fixtures/utilities.dart'; +int setupNum = 0; + void main() { // Enable verbose logging for debugging. const debug = false; @@ -52,6 +54,7 @@ void main() { setUp(() async { setCurrentLogWriter(debug: debug); await context.setUp( + setupNum: ++setupNum, testSettings: TestSettings( enableExpressionEvaluation: true, compilationMode: CompilationMode.frontendServer, From 6f8b7ebe57b623b0feca591890c75f284817222d Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 11:00:16 +0200 Subject: [PATCH 02/11] Print environment too --- dwds/test/fixtures/context.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 4b759491f..ac0ab5f53 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -433,6 +433,10 @@ class TestContext { ' -> notice chrome driver identity hash code is ' '${identityHashCode(_chromeDriver)}', ); + log('Also notice Platform.environment:'); + for(var entry in Platform.environment.entries) { + log(' ${entry.key}: ${entry.value}'); + } _webDriver = await createDriver( spec: WebDriverSpec.JsonWire, desired: capabilities, From 0f1d386ad1433cc643631f4ab30105d06051afc5 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 11:01:41 +0200 Subject: [PATCH 03/11] formatting --- dwds/test/fixtures/context.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index ac0ab5f53..3139311d0 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -434,7 +434,7 @@ class TestContext { '${identityHashCode(_chromeDriver)}', ); log('Also notice Platform.environment:'); - for(var entry in Platform.environment.entries) { + for (var entry in Platform.environment.entries) { log(' ${entry.key}: ${entry.value}'); } _webDriver = await createDriver( From 5e5e2bbeed613acf95c3a4a50326f9de81240d7e Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 11:05:32 +0200 Subject: [PATCH 04/11] final --- dwds/test/fixtures/context.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 3139311d0..e7cb9fa39 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -434,7 +434,7 @@ class TestContext { '${identityHashCode(_chromeDriver)}', ); log('Also notice Platform.environment:'); - for (var entry in Platform.environment.entries) { + for (final entry in Platform.environment.entries) { log(' ${entry.key}: ${entry.value}'); } _webDriver = await createDriver( From 5e882f48f6ad31f1b1265c2cdd35dbadf7217228 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 12:11:43 +0200 Subject: [PATCH 05/11] attempt to get faster feedback --- .github/workflows/dart.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 8e09fd06b..47c0d4c45 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -267,8 +267,12 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds + - name: "dwds; dart test specific" + run: "dart test/hot_restart_breakpoints_test.dart" + if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" + working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -303,7 +307,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -338,7 +342,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -525,7 +529,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -560,7 +564,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -595,7 +599,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -758,7 +762,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -783,7 +787,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -808,7 +812,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -933,7 +937,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -958,7 +962,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -983,7 +987,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: From 7eed2c42a6f51401e58508fa5a4bc7030afa18b1 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 12:13:52 +0200 Subject: [PATCH 06/11] ... --- .github/workflows/dart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 47c0d4c45..9b21c01f2 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -39,7 +39,7 @@ jobs: - name: mono_repo self validate run: dart pub global activate mono_repo 6.6.2 - name: mono_repo self validate - run: dart pub global run mono_repo generate --validate + run: true job_002: name: "analyzer_and_format; linux; Dart dev; PKG: dwds; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`, `dart test test/build/ensure_version_test.dart`" runs-on: ubuntu-latest From 5d7390ca5750339d2cad789d56131309bb65bf18 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 12:18:34 +0200 Subject: [PATCH 07/11] Add some retry?!? --- dwds/test/fixtures/context.dart | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index e7cb9fa39..353d892e2 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -433,17 +433,30 @@ class TestContext { ' -> notice chrome driver identity hash code is ' '${identityHashCode(_chromeDriver)}', ); - log('Also notice Platform.environment:'); - for (final entry in Platform.environment.entries) { - log(' ${entry.key}: ${entry.value}'); + try { + _webDriver = await createDriver( + spec: WebDriverSpec.JsonWire, + desired: capabilities, + uri: Uri.parse( + 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', + ), + ); + } on SocketException catch (e) { + log('Got "$e". Will wait a bit and try again.'); + await Future.delayed(const Duration(seconds: 2)); + try { + _webDriver = await createDriver( + spec: WebDriverSpec.JsonWire, + desired: capabilities, + uri: Uri.parse( + 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', + ), + ); + } on SocketException catch (e) { + log('Got exception again: "$e"'); + rethrow; + } } - _webDriver = await createDriver( - spec: WebDriverSpec.JsonWire, - desired: capabilities, - uri: Uri.parse( - 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', - ), - ); } // The debugger tab must be enabled and connected before certain From 3d0cee21bcb69056d0b15fe810dd3134343bbd19 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 12:57:58 +0200 Subject: [PATCH 08/11] More output --- dwds/test/fixtures/context.dart | 37 ++++++++++++++------- dwds/test/hot_restart_breakpoints_test.dart | 4 +-- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 353d892e2..9df0bfacf 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -434,23 +434,34 @@ class TestContext { '${identityHashCode(_chromeDriver)}', ); try { - _webDriver = await createDriver( - spec: WebDriverSpec.JsonWire, - desired: capabilities, - uri: Uri.parse( - 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', - ), + final localWebDriver = + _webDriver = await createDriver( + spec: WebDriverSpec.JsonWire, + desired: capabilities, + uri: Uri.parse( + 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', + ), + ); + log( + 'After first try: _webDriver = $_webDriver; ' + 'localWebDriver = $localWebDriver', ); } on SocketException catch (e) { log('Got "$e". Will wait a bit and try again.'); await Future.delayed(const Duration(seconds: 2)); + log('Back after the wait. Will now try again.'); try { - _webDriver = await createDriver( - spec: WebDriverSpec.JsonWire, - desired: capabilities, - uri: Uri.parse( - 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', - ), + final localWebDriver = + _webDriver = await createDriver( + spec: WebDriverSpec.JsonWire, + desired: capabilities, + uri: Uri.parse( + 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', + ), + ); + log( + 'After second try: _webDriver = $_webDriver; ' + 'localWebDriver = $localWebDriver', ); } on SocketException catch (e) { log('Got exception again: "$e"'); @@ -459,6 +470,8 @@ class TestContext { } } + log('Is now after the testSettings.launchChrome stuff.'); + // The debugger tab must be enabled and connected before certain // listeners in DWDS or `main` is run. final tabConnectionCompleter = Completer(); diff --git a/dwds/test/hot_restart_breakpoints_test.dart b/dwds/test/hot_restart_breakpoints_test.dart index 72a2eb360..1708846bb 100644 --- a/dwds/test/hot_restart_breakpoints_test.dart +++ b/dwds/test/hot_restart_breakpoints_test.dart @@ -49,7 +49,7 @@ void main() { late Stream stream; // Fetch the log statements that are sent to console. final consoleLogs = []; - late StreamSubscription consoleSubscription; + StreamSubscription? consoleSubscription; setUp(() async { setCurrentLogWriter(debug: debug); @@ -74,7 +74,7 @@ void main() { }); tearDown(() async { - await consoleSubscription.cancel(); + await consoleSubscription?.cancel(); consoleLogs.clear(); await context.tearDown(); }); From 2b89d414cbbc47167353271e4df1532222a7b2a7 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 13:21:35 +0200 Subject: [PATCH 09/11] Set debug = true --- dwds/test/hot_restart_breakpoints_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwds/test/hot_restart_breakpoints_test.dart b/dwds/test/hot_restart_breakpoints_test.dart index 1708846bb..d43158393 100644 --- a/dwds/test/hot_restart_breakpoints_test.dart +++ b/dwds/test/hot_restart_breakpoints_test.dart @@ -25,7 +25,7 @@ int setupNum = 0; void main() { // Enable verbose logging for debugging. - const debug = false; + const debug = true; final provider = TestSdkConfigurationProvider( verbose: debug, canaryFeatures: true, From 4528931d7e969752269ad2afbdee01909751a8fd Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 13:40:08 +0200 Subject: [PATCH 10/11] fix; a little cleanup --- dwds/test/fixtures/context.dart | 47 ++++++++++++--------- dwds/test/hot_restart_breakpoints_test.dart | 3 -- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 9df0bfacf..9c149c5c3 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -132,7 +132,6 @@ class TestContext { TestContext(this.project, this.sdkConfigurationProvider); Future setUp({ - int setupNum = -1, TestSettings testSettings = const TestSettings(), TestAppMetadata appMetadata = const TestAppMetadata.externalApp(), TestDebugSettings debugSettings = @@ -156,7 +155,7 @@ class TestContext { DartUri.currentDirectory = project.absolutePackageDirectory; void log(String s) { - _logger.info('${DateTime.now()}: ($setupNum): $s'); + _logger.info('${DateTime.now()}: $s'); } log('Serving: ${project.directoryToServe}/${project.filePathToServe}'); @@ -177,19 +176,12 @@ class TestContext { _outputDir = systemTempDir.createTempSync('foo bar'); final chromeDriverPort = await findUnusedPort(); - log('Picked chromeDriverPort = $chromeDriverPort'); final chromeDriverUrlBase = 'wd/hub'; try { - final localDriver = - _chromeDriver = await Process.start('chromedriver$_exeExt', [ - '--port=$chromeDriverPort', - '--url-base=$chromeDriverUrlBase', - ]); - log( - 'Started chrome driver - identity hash code = ${identityHashCode(localDriver)}', - ); - // On windows this takes a while to boot up, wait for the first line - // of stdout as a signal that it is ready. + _chromeDriver = await Process.start('chromedriver$_exeExt', [ + '--port=$chromeDriverPort', + '--url-base=$chromeDriverUrlBase', + ]); final stdOutLines = chromeDriver.stdout .transform(utf8.decoder) @@ -202,11 +194,31 @@ class TestContext { .transform(const LineSplitter()) .asBroadcastStream(); - stdOutLines.listen((line) => log('ChromeDriver stdout: $line')); + // Sometimes ChromeDriver can be slow to startup. + // This was seen on a github actions run: + // > 11:22:59.924700: ChromeDriver stdout: Starting ChromeDriver + // > 139.0.7258.154 ([...]) on port 38107 + // > [...] + // > 11:23:00.237350: ChromeDriver stdout: ChromeDriver was started + // > successfully on port 38107. + // Where in the 300+ ms it took before it was actually ready to accept + // a connection we had tried - and failed - to connect. + // We therefore wait until ChromeDriver reports that it has started + // successfully. + + final chromeDriverStartup = Completer(); + stdOutLines.listen((line) { + if (!chromeDriverStartup.isCompleted && + line.contains('was started successfully')) { + chromeDriverStartup.complete(); + } + log('ChromeDriver stdout: $line'); + }); stdErrLines.listen((line) => log('ChromeDriver stderr: $line')); - final firstLine = await stdOutLines.first; - log('Notice first line = $firstLine'); + await stdOutLines.first; + await chromeDriverStartup.future; + log('ChromeDriver has now started'); } catch (e) { throw StateError( 'Could not start ChromeDriver. Is it installed?\nError: $e', @@ -226,7 +238,6 @@ class TestContext { var filePathToServe = project.filePathToServe; _port = await findUnusedPort(); - log('Port #2: $_port'); switch (testSettings.compilationMode) { case CompilationMode.buildDaemon: { @@ -343,7 +354,6 @@ class TestContext { ); final assetServerPort = await findUnusedPort(); - log('Port #3: $assetServerPort'); _hostname = appMetadata.hostname; await webRunner.run( frontendServerFileSystem, @@ -398,7 +408,6 @@ class TestContext { } final debugPort = await findUnusedPort(); - log('Port #4: $debugPort'); if (testSettings.launchChrome) { // If the environment variable DWDS_DEBUG_CHROME is set to the string // true then Chrome will be launched with a UI rather than headless. diff --git a/dwds/test/hot_restart_breakpoints_test.dart b/dwds/test/hot_restart_breakpoints_test.dart index d43158393..ca99f267c 100644 --- a/dwds/test/hot_restart_breakpoints_test.dart +++ b/dwds/test/hot_restart_breakpoints_test.dart @@ -21,8 +21,6 @@ import 'fixtures/context.dart'; import 'fixtures/project.dart'; import 'fixtures/utilities.dart'; -int setupNum = 0; - void main() { // Enable verbose logging for debugging. const debug = true; @@ -54,7 +52,6 @@ void main() { setUp(() async { setCurrentLogWriter(debug: debug); await context.setUp( - setupNum: ++setupNum, testSettings: TestSettings( enableExpressionEvaluation: true, compilationMode: CompilationMode.frontendServer, From a27771fa27f07e043ed41fd3452051b62adc5572 Mon Sep 17 00:00:00 2001 From: Jens Johansen Date: Wed, 3 Sep 2025 13:55:38 +0200 Subject: [PATCH 11/11] Cleanup all the debug stuff --- .github/workflows/dart.yml | 30 ++++----- dwds/test/fixtures/context.dart | 72 +++++---------------- dwds/test/hot_restart_breakpoints_test.dart | 2 +- 3 files changed, 30 insertions(+), 74 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 9b21c01f2..8e09fd06b 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -39,7 +39,7 @@ jobs: - name: mono_repo self validate run: dart pub global activate mono_repo 6.6.2 - name: mono_repo self validate - run: true + run: dart pub global run mono_repo generate --validate job_002: name: "analyzer_and_format; linux; Dart dev; PKG: dwds; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`, `dart test test/build/ensure_version_test.dart`" runs-on: ubuntu-latest @@ -267,12 +267,8 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - - name: "dwds; dart test specific" - run: "dart test/hot_restart_breakpoints_test.dart" - if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" - working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -307,7 +303,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -342,7 +338,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -529,7 +525,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -564,7 +560,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -599,7 +595,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -762,7 +758,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -787,7 +783,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -812,7 +808,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -937,7 +933,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 0 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -962,7 +958,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 1 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: @@ -987,7 +983,7 @@ jobs: if: "always() && steps.checkout.conclusion == 'success'" working-directory: dwds - name: "dwds; dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" - run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension --no-retry --fail-fast" + run: "dart test --total-shards 3 --shard-index 2 --exclude-tags=extension" if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'" working-directory: dwds needs: diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index 9c149c5c3..accf8df2c 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -154,14 +154,12 @@ class TestContext { DartUri.currentDirectory = project.absolutePackageDirectory; - void log(String s) { - _logger.info('${DateTime.now()}: $s'); - } - - log('Serving: ${project.directoryToServe}/${project.filePathToServe}'); - log('Project: ${project.absolutePackageDirectory}'); - log('Packages: ${project.packageConfigFile}'); - log('Entry: ${project.dartEntryFilePath}'); + _logger.info( + 'Serving: ${project.directoryToServe}/${project.filePathToServe}', + ); + _logger.info('Project: ${project.absolutePackageDirectory}'); + _logger.info('Packages: ${project.packageConfigFile}'); + _logger.info('Entry: ${project.dartEntryFilePath}'); configureLogWriter(); @@ -212,13 +210,13 @@ class TestContext { line.contains('was started successfully')) { chromeDriverStartup.complete(); } - log('ChromeDriver stdout: $line'); + _logger.finest('ChromeDriver stdout: $line'); }); - stdErrLines.listen((line) => log('ChromeDriver stderr: $line')); + stdErrLines.listen( + (line) => _logger.warning('ChromeDriver stderr: $line'), + ); - await stdOutLines.first; await chromeDriverStartup.future; - log('ChromeDriver has now started'); } catch (e) { throw StateError( 'Could not start ChromeDriver. Is it installed?\nError: $e', @@ -434,53 +432,15 @@ class TestContext { ], }, }); - log( - 'Now creating web driver for chrome driver port; ' - 'going for port $chromeDriverPort', - ); - log( - ' -> notice chrome driver identity hash code is ' - '${identityHashCode(_chromeDriver)}', + _webDriver = await createDriver( + spec: WebDriverSpec.JsonWire, + desired: capabilities, + uri: Uri.parse( + 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', + ), ); - try { - final localWebDriver = - _webDriver = await createDriver( - spec: WebDriverSpec.JsonWire, - desired: capabilities, - uri: Uri.parse( - 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', - ), - ); - log( - 'After first try: _webDriver = $_webDriver; ' - 'localWebDriver = $localWebDriver', - ); - } on SocketException catch (e) { - log('Got "$e". Will wait a bit and try again.'); - await Future.delayed(const Duration(seconds: 2)); - log('Back after the wait. Will now try again.'); - try { - final localWebDriver = - _webDriver = await createDriver( - spec: WebDriverSpec.JsonWire, - desired: capabilities, - uri: Uri.parse( - 'http://127.0.0.1:$chromeDriverPort/$chromeDriverUrlBase/', - ), - ); - log( - 'After second try: _webDriver = $_webDriver; ' - 'localWebDriver = $localWebDriver', - ); - } on SocketException catch (e) { - log('Got exception again: "$e"'); - rethrow; - } - } } - log('Is now after the testSettings.launchChrome stuff.'); - // The debugger tab must be enabled and connected before certain // listeners in DWDS or `main` is run. final tabConnectionCompleter = Completer(); diff --git a/dwds/test/hot_restart_breakpoints_test.dart b/dwds/test/hot_restart_breakpoints_test.dart index ca99f267c..bca0d3c2f 100644 --- a/dwds/test/hot_restart_breakpoints_test.dart +++ b/dwds/test/hot_restart_breakpoints_test.dart @@ -23,7 +23,7 @@ import 'fixtures/utilities.dart'; void main() { // Enable verbose logging for debugging. - const debug = true; + const debug = false; final provider = TestSdkConfigurationProvider( verbose: debug, canaryFeatures: true,