@@ -9,6 +9,7 @@ import 'dart:convert' show JsonEncoder;
99import 'dart:io' ;
1010
1111import 'package:collection/collection.dart' ;
12+ import 'package:devtools_test/helpers.dart' ;
1213import 'package:test/test.dart' ;
1314import 'package:web_benchmarks/metrics.dart' ;
1415import 'package:web_benchmarks/server.dart' ;
@@ -44,29 +45,51 @@ void main() {
4445 },
4546 timeout: const Timeout (Duration (minutes: 15 )),
4647 retry: 0 ,
47- // TODO(elliette): Re-enable once flakiness is addressed.
48- skip: 'https://github.com/flutter/devtools/issues/9674' ,
4948 );
5049 }
5150}
5251
5352Future <void > _runBenchmarks ({bool useWasm = false }) async {
5453 stdout.writeln ('Starting web benchmark tests ...' );
5554
56- final benchmarkPort = await _findAvailablePort (startingAt: 9999 );
57- final chromePort = await _findAvailablePort (startingAt: benchmarkPort + 1 );
55+ var benchmarkPort = await _findAvailablePort (startingAt: 9999 );
56+ var chromePort = await _findAvailablePort (startingAt: benchmarkPort + 1 );
5857
59- final taskResult = await serveWebBenchmark (
60- benchmarkAppDirectory: projectRootDirectory (),
61- entryPoint: generateBenchmarkEntryPoint (useWasm: useWasm),
62- compilationOptions: useWasm
63- ? const CompilationOptions .wasm ()
64- : const CompilationOptions .js (),
65- treeShakeIcons: false ,
66- benchmarkPath: benchmarkPath (useWasm: useWasm),
67- benchmarkServerPort: benchmarkPort,
68- chromeDebugPort: chromePort,
58+ // TODO(elliette): Retry logic can likely be removed after
59+ // https://github.com/flutter/flutter/issues/183335 is resolved.
60+ final taskResult = await retryAsync <BenchmarkResults ?>(
61+ () async {
62+ try {
63+ logStatus (
64+ 'Serving benchmarks (server port: $benchmarkPort , chrome port: $chromePort )' ,
65+ );
66+ return await serveWebBenchmark (
67+ benchmarkAppDirectory: projectRootDirectory (),
68+ entryPoint: generateBenchmarkEntryPoint (useWasm: useWasm),
69+ compilationOptions: useWasm
70+ ? const CompilationOptions .wasm ()
71+ : const CompilationOptions .js (),
72+ treeShakeIcons: false ,
73+ benchmarkPath: benchmarkPath (useWasm: useWasm),
74+ benchmarkServerPort: benchmarkPort,
75+ chromeDebugPort: chromePort,
76+ );
77+ } catch (e) {
78+ logStatus ('Serving benchmarks failed with error: $e ' );
79+ return null ;
80+ }
81+ },
82+ condition: (result) => result != null ,
83+ onRetry: () async {
84+ logStatus ('Retrying with new ports...' );
85+ benchmarkPort = await _findAvailablePort (startingAt: chromePort + 1 );
86+ chromePort = await _findAvailablePort (startingAt: benchmarkPort + 1 );
87+ },
6988 );
89+ if (taskResult == null ) {
90+ throw Exception ('Failed to serve benchmarks after retries.' );
91+ }
92+
7093 stdout.writeln ('Web benchmark tests finished.' );
7194
7295 expect (
0 commit comments