Unverified Commit f87a2a32 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Switch to URIs for breakpoints and unskip tests on Windows (#22510)

* Switch to URIs for breakpoints and unskip tests on Windows

addBreakpointWithScriptUri expects Uris. By coincidence, FS paths work on Mac/Linux but they fail on Windows. One of the issues in the skip comment is fixed, the other one seems not relevant here.

* Apply symlink resolution to all integration tests

The default temp folders we get include symlinks which breaks breakpoints.

* Save 🙄

* Fix typo
parent bb0290a4
...@@ -6,13 +6,13 @@ import 'dart:async'; ...@@ -6,13 +6,13 @@ import 'dart:async';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:vm_service_client/vm_service_client.dart'; import 'package:vm_service_client/vm_service_client.dart';
import '../src/common.dart'; import '../src/common.dart';
import 'test_data/basic_project.dart'; import 'test_data/basic_project.dart';
import 'test_driver.dart'; import 'test_driver.dart';
import 'test_utils.dart';
void main() { void main() {
group('expression evaluation', () { group('expression evaluation', () {
...@@ -21,7 +21,7 @@ void main() { ...@@ -21,7 +21,7 @@ void main() {
FlutterTestDriver _flutter; FlutterTestDriver _flutter;
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_expression_test.'); tempDir = createResolvedTempDirectorySync();
await _project.setUpIn(tempDir); await _project.setUpIn(tempDir);
_flutter = FlutterTestDriver(tempDir); _flutter = FlutterTestDriver(tempDir);
}); });
...@@ -33,13 +33,13 @@ void main() { ...@@ -33,13 +33,13 @@ void main() {
Future<VMIsolate> breakInBuildMethod(FlutterTestDriver flutter) async { Future<VMIsolate> breakInBuildMethod(FlutterTestDriver flutter) async {
return _flutter.breakAt( return _flutter.breakAt(
_project.buildMethodBreakpointFile, Uri.file(_project.buildMethodBreakpointFile),
_project.buildMethodBreakpointLine); _project.buildMethodBreakpointLine);
} }
Future<VMIsolate> breakInTopLevelFunction(FlutterTestDriver flutter) async { Future<VMIsolate> breakInTopLevelFunction(FlutterTestDriver flutter) async {
return _flutter.breakAt( return _flutter.breakAt(
_project.topLevelFunctionBreakpointFile, Uri.file(_project.topLevelFunctionBreakpointFile),
_project.topLevelFunctionBreakpointLine); _project.topLevelFunctionBreakpointLine);
} }
...@@ -108,8 +108,5 @@ void main() { ...@@ -108,8 +108,5 @@ void main() {
await breakInBuildMethod(_flutter); await breakInBuildMethod(_flutter);
await evaluateComplexReturningExpressions(); await evaluateComplexReturningExpressions();
}); });
// TODO(dantup): Unskip after flutter-tester is fixed on Windows: }, timeout: const Timeout.factor(6));
// https://github.com/flutter/flutter/issues/17833.
// https://github.com/flutter/flutter/issues/21348.
}, timeout: const Timeout.factor(6), skip: platform.isWindows);
} }
...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import '../src/common.dart'; import '../src/common.dart';
import 'test_data/basic_project.dart'; import 'test_data/basic_project.dart';
import 'test_driver.dart'; import 'test_driver.dart';
import 'test_utils.dart';
void main() { void main() {
FlutterTestDriver _flutterRun, _flutterAttach; FlutterTestDriver _flutterRun, _flutterAttach;
...@@ -15,7 +16,7 @@ void main() { ...@@ -15,7 +16,7 @@ void main() {
Directory tempDir; Directory tempDir;
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_attach_test.'); tempDir = createResolvedTempDirectorySync();
await _project.setUpIn(tempDir); await _project.setUpIn(tempDir);
_flutterRun = FlutterTestDriver(tempDir, logPrefix: 'RUN'); _flutterRun = FlutterTestDriver(tempDir, logPrefix: 'RUN');
_flutterAttach = FlutterTestDriver(tempDir, logPrefix: 'ATTACH'); _flutterAttach = FlutterTestDriver(tempDir, logPrefix: 'ATTACH');
......
...@@ -9,6 +9,7 @@ import 'package:process/process.dart'; ...@@ -9,6 +9,7 @@ import 'package:process/process.dart';
import '../src/common.dart'; import '../src/common.dart';
import 'test_data/basic_project.dart'; import 'test_data/basic_project.dart';
import 'test_utils.dart';
void main() { void main() {
group('flutter_run', () { group('flutter_run', () {
...@@ -16,7 +17,7 @@ void main() { ...@@ -16,7 +17,7 @@ void main() {
final BasicProject _project = BasicProject(); final BasicProject _project = BasicProject();
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_run_integration_test.'); tempDir = createResolvedTempDirectorySync();
await _project.setUpIn(tempDir); await _project.setUpIn(tempDir);
}); });
......
...@@ -9,6 +9,7 @@ import 'package:vm_service_client/vm_service_client.dart'; ...@@ -9,6 +9,7 @@ import 'package:vm_service_client/vm_service_client.dart';
import '../src/common.dart'; import '../src/common.dart';
import 'test_data/basic_project.dart'; import 'test_data/basic_project.dart';
import 'test_driver.dart'; import 'test_driver.dart';
import 'test_utils.dart';
void main() { void main() {
group('hot', () { group('hot', () {
...@@ -17,7 +18,7 @@ void main() { ...@@ -17,7 +18,7 @@ void main() {
FlutterTestDriver _flutter; FlutterTestDriver _flutter;
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_hot_reload_test_app.'); tempDir = createResolvedTempDirectorySync();
await _project.setUpIn(tempDir); await _project.setUpIn(tempDir);
_flutter = FlutterTestDriver(tempDir); _flutter = FlutterTestDriver(tempDir);
}); });
...@@ -37,12 +38,10 @@ void main() { ...@@ -37,12 +38,10 @@ void main() {
await _flutter.hotRestart(); await _flutter.hotRestart();
}); });
test('reload hits breakpoints with file:// prefixes after reload', () async { test('reload hits breakpoints after reload', () async {
await _flutter.run(withDebugger: true); await _flutter.run(withDebugger: true);
// Hit breakpoint using a file:// URI.
final VMIsolate isolate = await _flutter.breakAt( final VMIsolate isolate = await _flutter.breakAt(
Uri.file(_project.breakpointFile).toString(), Uri.file(_project.breakpointFile),
_project.breakpointLine); _project.breakpointLine);
expect(isolate.pauseEvent, isInstanceOf<VMPauseBreakpointEvent>()); expect(isolate.pauseEvent, isInstanceOf<VMPauseBreakpointEvent>());
}); });
......
...@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; ...@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import '../src/common.dart'; import '../src/common.dart';
import 'test_data/basic_project.dart'; import 'test_data/basic_project.dart';
import 'test_driver.dart'; import 'test_driver.dart';
import 'test_utils.dart';
/// This duration is arbitrary but is ideally: /// This duration is arbitrary but is ideally:
/// a) long enough to ensure that if the app is crashing at startup, we notice /// a) long enough to ensure that if the app is crashing at startup, we notice
...@@ -23,7 +24,7 @@ void main() { ...@@ -23,7 +24,7 @@ void main() {
Directory tempDir; Directory tempDir;
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_lifetime_test.'); tempDir = createResolvedTempDirectorySync();
await _project.setUpIn(tempDir); await _project.setUpIn(tempDir);
_flutter = FlutterTestDriver(tempDir); _flutter = FlutterTestDriver(tempDir);
}); });
......
...@@ -16,8 +16,8 @@ abstract class TestProject { ...@@ -16,8 +16,8 @@ abstract class TestProject {
String get main; String get main;
// Valid locations for a breakpoint for tests that just need to break somewhere. // Valid locations for a breakpoint for tests that just need to break somewhere.
String get breakpointFile => fs.file(fs.path.join( String get breakpointFile => fs.path.join(
dir.path, 'lib', 'main.dart')).resolveSymbolicLinksSync(); dir.path, 'lib', 'main.dart');
int get breakpointLine => lineContaining(main, '// BREAKPOINT'); int get breakpointLine => lineContaining(main, '// BREAKPOINT');
Future<void> setUpIn(Directory dir) async { Future<void> setUpIn(Directory dir) async {
......
...@@ -237,10 +237,10 @@ class FlutterTestDriver { ...@@ -237,10 +237,10 @@ class FlutterTestDriver {
return await vm.isolates.single.load(); return await vm.isolates.single.load();
} }
Future<void> addBreakpoint(String path, int line) async { Future<void> addBreakpoint(Uri uri, int line) async {
final VMIsolate isolate = await getFlutterIsolate(); final VMIsolate isolate = await getFlutterIsolate();
_debugPrint('Sending breakpoint for $path:$line'); _debugPrint('Sending breakpoint for $uri:$line');
await isolate.addBreakpoint(path, line); await isolate.addBreakpoint(uri, line);
} }
Future<VMIsolate> waitForPause() async { Future<VMIsolate> waitForPause() async {
...@@ -266,15 +266,15 @@ class FlutterTestDriver { ...@@ -266,15 +266,15 @@ class FlutterTestDriver {
return wait ? waitForPause() : null; return wait ? waitForPause() : null;
} }
Future<VMIsolate> breakAt(String path, int line, { bool restart = false }) async { Future<VMIsolate> breakAt(Uri uri, int line, { bool restart = false }) async {
if (restart) { if (restart) {
// For a hot restart, we need to send the breakpoints after the restart // For a hot restart, we need to send the breakpoints after the restart
// so we need to pause during the restart to avoid races. // so we need to pause during the restart to avoid races.
await hotRestart(pause: true); await hotRestart(pause: true);
await addBreakpoint(path, line); await addBreakpoint(uri, line);
return resume(); return resume();
} else { } else {
await addBreakpoint(path, line); await addBreakpoint(uri, line);
await hotReload(); await hotReload();
return waitForPause(); return waitForPause();
} }
......
...@@ -11,6 +11,14 @@ import 'package:flutter_tools/src/base/process_manager.dart'; ...@@ -11,6 +11,14 @@ import 'package:flutter_tools/src/base/process_manager.dart';
import '../src/common.dart'; import '../src/common.dart';
/// Creates a temporary directory but resolves any symlinks to return the real
/// underlying path to avoid issues with breakpoints/hot reload.
/// https://github.com/flutter/flutter/pull/21741
Directory createResolvedTempDirectorySync() {
final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_expression_test.');
return fs.directory(tempDir.resolveSymbolicLinksSync());
}
void writeFile(String path, String content) { void writeFile(String path, String content) {
fs.file(path) fs.file(path)
..createSync(recursive: true) ..createSync(recursive: true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment