[O] Remove many timeouts. (#23531)

* Remove many timeouts.

These are essentially self-inflicted race conditions. Instead of timeouts we're going to try a more verbose logging mechanism that points out when things are taking a long time.

* Get the attach tests to pass.

* Apply review comments from Todd

* More review comment fixes

* Put back the extended timeouts here now that I know why we have them...
This commit is contained in:
Ian Hickson
2018-12-20 17:10:40 -08:00
committed by GitHub
parent b3b764c9d3
commit 76f70810e4
59 changed files with 1832 additions and 1200 deletions

View File

@@ -19,15 +19,22 @@ class BasicProject extends Project {
@override
final String main = r'''
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
Future<void> main() async {
while (true) {
runApp(new MyApp());
await Future.delayed(const Duration(milliseconds: 50));
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
topLevelFunction();
return new MaterialApp( // BREAKPOINT
return new MaterialApp( // BUILD BREAKPOINT
title: 'Flutter Demo',
home: new Container(),
);
@@ -39,9 +46,9 @@ class BasicProject extends Project {
}
''';
Uri get buildMethodBreakpointUri => breakpointUri;
int get buildMethodBreakpointLine => breakpointLine;
Uri get buildMethodBreakpointUri => mainDart;
int get buildMethodBreakpointLine => lineContaining(main, '// BUILD BREAKPOINT');
Uri get topLevelFunctionBreakpointUri => breakpointUri;
Uri get topLevelFunctionBreakpointUri => mainDart;
int get topLevelFunctionBreakpointLine => lineContaining(main, '// TOP LEVEL BREAKPOINT');
}

View File

@@ -22,33 +22,63 @@ class HotReloadProject extends Project {
@override
final String main = r'''
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(new MyApp());
int count = 1;
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Do not remove this line, it's uncommented by a test to verify that hot
// reloading worked.
// This method gets called each time we hot reload, during reassemble.
// Do not remove the next line, it's uncommented by a test to verify that
// hot reloading worked:
// printHotReloadWorked();
return new MaterialApp( // BREAKPOINT
print('((((TICK $count))))');
// tick 1 = startup warmup frame
// tick 2 = hot reload warmup reassemble frame
// after that there's a post-hot-reload frame scheduled by the tool that
// doesn't trigger this to rebuild, but does trigger the first callback
// below, then that callback schedules another frame on which we do the
// breakpoint.
// tick 3 = second hot reload warmup reassemble frame (pre breakpoint)
if (count == 2) {
SchedulerBinding.instance.scheduleFrameCallback((Duration timestamp) {
SchedulerBinding.instance.scheduleFrameCallback((Duration timestamp) {
print('breakpoint line'); // SCHEDULED BREAKPOINT
});
});
}
count += 1;
return MaterialApp( // BUILD BREAKPOINT
title: 'Flutter Demo',
home: new Container(),
home: Container(),
);
}
}
printHotReloadWorked() {
void printHotReloadWorked() {
// The call to this function is uncommented by a test to verify that hot
// reloading worked.
print('(((((RELOAD WORKED)))))');
}
''';
Uri get scheduledBreakpointUri => mainDart;
int get scheduledBreakpointLine => lineContaining(main, '// SCHEDULED BREAKPOINT');
Uri get buildBreakpointUri => mainDart;
int get buildBreakpointLine => lineContaining(main, '// BUILD BREAKPOINT');
void uncommentHotReloadPrint() {
final String newMainContents = main.replaceAll(
'// printHotReloadWorked();', 'printHotReloadWorked();');
'// printHotReloadWorked();',
'printHotReloadWorked();'
);
writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
}
}

View File

@@ -15,9 +15,7 @@ abstract class Project {
String get pubspec;
String get main;
// Valid locations for a breakpoint for tests that just need to break somewhere.
Uri get breakpointUri => Uri.parse('package:test/main.dart');
int get breakpointLine => lineContaining(main, '// BREAKPOINT');
Uri get mainDart => Uri.parse('package:test/main.dart');
Future<void> setUpIn(Directory dir) async {
this.dir = dir;
@@ -32,6 +30,6 @@ abstract class Project {
final int index = contents.split('\n').indexWhere((String l) => l.contains(search));
if (index == -1)
throw Exception("Did not find '$search' inside the file");
return index;
return index + 1; // first line is line 1, not line 0
}
}

View File

@@ -35,11 +35,11 @@ class SteppingProject extends Project {
Future<void> doAsyncStuff() async {
print("test"); // BREAKPOINT
await new Future.value(true); // STEP 1
await new Future.microtask(() => true); // STEP 2 // STEP 3
await new Future.delayed(const Duration(milliseconds: 1)); // STEP 4 // STEP 5
print("done!"); // STEP 6
}
await new Future.value(true); // STEP 1 // STEP 2
await new Future.microtask(() => true); // STEP 3 // STEP 4
await new Future.delayed(const Duration(milliseconds: 1)); // STEP 5 // STEP 6
print("done!"); // STEP 7
} // STEP 8
@override
Widget build(BuildContext context) {
@@ -51,7 +51,9 @@ class SteppingProject extends Project {
}
''';
Uri get breakpointUri => mainDart;
int get breakpointLine => lineContaining(main, '// BREAKPOINT');
int lineForStep(int i) => lineContaining(main, '// STEP $i');
final int numberOfSteps = 6;
final int numberOfSteps = 8;
}