Unverified Commit aac836c6 authored by Anna Gringauze's avatar Anna Gringauze Committed by GitHub

Enabled expression evaluation by default (#59826)

parent fbdc79e4
...@@ -209,7 +209,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -209,7 +209,7 @@ abstract class FlutterCommand extends Command<void> {
hide: true, hide: true,
); );
argParser.addFlag('web-enable-expression-evaluation', argParser.addFlag('web-enable-expression-evaluation',
defaultsTo: false, defaultsTo: true,
help: 'Enables expression evaluation in the debugger.', help: 'Enables expression evaluation in the debugger.',
hide: hide, hide: hide,
); );
......
...@@ -33,6 +33,14 @@ void batch1() { ...@@ -33,6 +33,14 @@ void batch1() {
tryToDelete(tempDir); tryToDelete(tempDir);
} }
Future<void> start({bool expressionEvaluation}) {
// The non-test project has a loop around its breakpoints.
// No need to start paused as all breakpoint would be eventually reached.
return _flutter.run(
withDebugger: true, chrome: true,
expressionEvaluation: expressionEvaluation);
}
Future<void> breakInBuildMethod(FlutterTestDriver flutter) async { Future<void> breakInBuildMethod(FlutterTestDriver flutter) async {
await _flutter.breakAt( await _flutter.breakAt(
_project.buildMethodBreakpointUri, _project.buildMethodBreakpointUri,
...@@ -47,9 +55,17 @@ void batch1() { ...@@ -47,9 +55,17 @@ void batch1() {
); );
} }
test('flutter run expression evaluation - error if expression evaluation disabled', () async {
await initProject();
await start(expressionEvaluation: false);
await breakInTopLevelFunction(_flutter);
await failToEvaluateExpression(_flutter);
await cleanProject();
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
test('flutter run expression evaluation - no native javascript objects in static scope', () async { test('flutter run expression evaluation - no native javascript objects in static scope', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true); await start(expressionEvaluation: true);
await breakInTopLevelFunction(_flutter); await breakInTopLevelFunction(_flutter);
await checkStaticScope(_flutter); await checkStaticScope(_flutter);
await cleanProject(); await cleanProject();
...@@ -57,7 +73,7 @@ void batch1() { ...@@ -57,7 +73,7 @@ void batch1() {
test('flutter run expression evaluation - can handle compilation errors', () async { test('flutter run expression evaluation - can handle compilation errors', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true); await start(expressionEvaluation: true);
await breakInTopLevelFunction(_flutter); await breakInTopLevelFunction(_flutter);
await evaluateErrorExpressions(_flutter); await evaluateErrorExpressions(_flutter);
await cleanProject(); await cleanProject();
...@@ -65,7 +81,7 @@ void batch1() { ...@@ -65,7 +81,7 @@ void batch1() {
test('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async { test('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true); await start(expressionEvaluation: true);
await breakInTopLevelFunction(_flutter); await breakInTopLevelFunction(_flutter);
await evaluateTrivialExpressions(_flutter); await evaluateTrivialExpressions(_flutter);
await cleanProject(); await cleanProject();
...@@ -73,7 +89,7 @@ void batch1() { ...@@ -73,7 +89,7 @@ void batch1() {
test('flutter run expression evaluation - can evaluate trivial expressions in build method', () async { test('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true); await start(expressionEvaluation: true);
await breakInBuildMethod(_flutter); await breakInBuildMethod(_flutter);
await evaluateTrivialExpressions(_flutter); await evaluateTrivialExpressions(_flutter);
await cleanProject(); await cleanProject();
...@@ -81,7 +97,7 @@ void batch1() { ...@@ -81,7 +97,7 @@ void batch1() {
test('flutter run expression evaluation - can evaluate complex expressions in top level function', () async { test('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true); await start(expressionEvaluation: true);
await breakInTopLevelFunction(_flutter); await breakInTopLevelFunction(_flutter);
await evaluateComplexExpressions(_flutter); await evaluateComplexExpressions(_flutter);
await cleanProject(); await cleanProject();
...@@ -113,15 +129,35 @@ void batch2() { ...@@ -113,15 +129,35 @@ void batch2() {
} }
Future<void> breakInMethod(FlutterTestDriver flutter) async { Future<void> breakInMethod(FlutterTestDriver flutter) async {
await _flutter.breakAt( await _flutter.addBreakpoint(
_project.breakpointAppUri, _project.breakpointAppUri,
_project.breakpointLine, _project.breakpointLine,
); );
await _flutter.resume();
await _flutter.waitForPause();
}
Future<void> startPaused({bool expressionEvaluation}) {
// The test project does not have a loop around its breakpoints.
// Start paused so we can set a breakpoint before passing it
// in the execution.
return _flutter.run(
withDebugger: true, chrome: true,
expressionEvaluation: expressionEvaluation,
startPaused: true, script: _project.testFilePath);
} }
test('flutter test expression evaluation - error if expression evaluation disabled', () async {
await initProject();
await startPaused(expressionEvaluation: false);
await breakInMethod(_flutter);
await failToEvaluateExpression(_flutter);
await cleanProject();
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
test('flutter test expression evaluation - can evaluate trivial expressions in a test', () async { test('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true, script: _project.testFilePath); await startPaused(expressionEvaluation: true);
await breakInMethod(_flutter); await breakInMethod(_flutter);
await evaluateTrivialExpressions(_flutter); await evaluateTrivialExpressions(_flutter);
await cleanProject(); await cleanProject();
...@@ -129,13 +165,25 @@ void batch2() { ...@@ -129,13 +165,25 @@ void batch2() {
test('flutter test expression evaluation - can evaluate complex expressions in a test', () async { test('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
await initProject(); await initProject();
await _flutter.run(withDebugger: true, chrome: true, script: _project.testFilePath); await startPaused(expressionEvaluation: true);
await breakInMethod(_flutter); await breakInMethod(_flutter);
await evaluateComplexExpressions(_flutter); await evaluateComplexExpressions(_flutter);
await cleanProject(); await cleanProject();
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779 }, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
} }
Future<void> failToEvaluateExpression(FlutterTestDriver flutter) async {
ObjRef res;
try {
res = await flutter.evaluateInFrame('"test"');
} on RPCError catch (e) {
expect(e.message, contains(
'UnimplementedError: '
'Expression evaluation is not supported for this configuration'));
}
expect(res, null);
}
Future<void> checkStaticScope(FlutterTestDriver flutter) async { Future<void> checkStaticScope(FlutterTestDriver flutter) async {
final Frame res = await flutter.getTopStackFrame(); final Frame res = await flutter.getTopStackFrame();
expect(res.vars, equals(<BoundVariable>[])); expect(res.vars, equals(<BoundVariable>[]));
......
...@@ -437,6 +437,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { ...@@ -437,6 +437,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
bool startPaused = false, bool startPaused = false,
bool pauseOnExceptions = false, bool pauseOnExceptions = false,
bool chrome = false, bool chrome = false,
bool expressionEvaluation = true,
bool structuredErrors = false, bool structuredErrors = false,
File pidFile, File pidFile,
String script, String script,
...@@ -449,7 +450,11 @@ class FlutterRunTestDriver extends FlutterTestDriver { ...@@ -449,7 +450,11 @@ class FlutterRunTestDriver extends FlutterTestDriver {
'--machine', '--machine',
'-d', '-d',
if (chrome) if (chrome)
...<String>['chrome', '--web-run-headless', '--web-enable-expression-evaluation'] ...<String>[
'chrome',
'--web-run-headless',
if (!expressionEvaluation) '--no-web-enable-expression-evaluation'
]
else else
'flutter-tester', 'flutter-tester',
if (structuredErrors) if (structuredErrors)
......
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