Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound null safety for framework and flutter_test #68642

Merged
merged 15 commits into from Oct 21, 2020

Conversation

@goderbauer
Copy link
Member

@goderbauer goderbauer commented Oct 20, 2020

This fixes all issues expect the test failures from test/widgets/widget_inspector_test.dart, which are resolved by @jacob314 in #68661.

Fixes #68562

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Besides layer example LGTM

@goderbauer goderbauer force-pushed the goderbauer:soundmode2 branch from ec243ce to 1e64a2b Oct 20, 2020
@goderbauer goderbauer changed the title Null safety sound mode fixes - part 1 Null safety sound mode fixes Oct 20, 2020
@goderbauer goderbauer dismissed jonahwilliams’s stale review Oct 20, 2020

Added massive changes.

@shihaohong shihaohong self-requested a review Oct 20, 2020
Copy link
Member

@jonahwilliams jonahwilliams left a comment

LGTM if LG to CI

@shihaohong
Copy link
Contributor

@shihaohong shihaohong commented Oct 20, 2020

CI is still sad: https://cirrus-ci.com/task/5469809754243072

Cirrus CI Remove

00:26 clone
00:05 pub
00:01 flutter_pkg
00:04 artifacts
02:33 setup
✔️ 00:00 failure
04:42 main

03:48 +2974 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/render_object_element_test.dart: RenderObjectElement *ChildRenderObject methods fail with deprecation message                       
03:48 +2975 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/render_object_element_test.dart: RenderObjectElement *ChildRenderObject methods fail with deprecation message                       
03:48 +2976 ~7 -23: loading /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart                                                                                                            
03:48 +2976 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: Simple router can handle pop route                                                                                
03:48 +2977 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: A Banner with a location of topStart paints in the top left (LTR)                                                 
03:48 +2978 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: A Banner with a location of topStart paints in the top left (LTR)                                                 
03:48 +2979 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: A Banner with a location of topStart paints in the top left (LTR)                                                 
03:48 +2980 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2981 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2982 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2983 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2984 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2985 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2986 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:48 +2987 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:49 +2987 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:49 +2988 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PopNavigatorRouterDelegateMixin works                                                                             
03:49 +2989 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2990 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2991 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2992 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2993 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2994 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2995 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2996 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/banner_test.dart: Banner widget in MaterialApp                                                                                      
03:49 +2997 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: router can be forced to recognize or ignore navigating events                                                     
03:49 +2998 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: router can be forced to recognize or ignore navigating events                                                     
03:49 +2999 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: router can be forced to recognize or ignore navigating events                                                     
03:49 +3000 ~7 -23: loading /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart                                                                                                       
03:49 +3000 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/column_test.dart: Column with MainAxisAlignment.spaceEvenly                                                                         
03:49 +3001 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: router does not report when route information is up to date with route information provider                       
03:49 +3002 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/column_test.dart: Column and MainAxisSize.min                                                                                       
03:49 +3003 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PlatformRouteInformationProvider works                                                                            
03:49 +3004 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PlatformRouteInformationProvider works                                                                            
03:49 +3005 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: PlatformRouteInformationProvider works                                                                            
03:49 +3006 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/column_test.dart: Column with default main axis parameters                                                                          
03:49 +3007 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/router_test.dart: RootBackButtonDispatcher works                                                                                    
03:49 +3008 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/column_test.dart: Column with MainAxisAlignment.center                                                                              
03:49 +3009 ~7 -23: loading /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart                                                                                                       
03:49 +3009 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/column_test.dart: Column with MainAxisAlignment.end                                                                                 
03:49 +3010 ~7 -23: loading /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart                                                                                                       
03:49 +3010 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/column_test.dart: Column with MainAxisAlignment.spaceBetween                                                                        
03:49 +3011 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:49 +3012 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:49 +3013 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:49 +3014 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:49 +3015 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:50 +3015 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:50 +3016 ~7 -23: /tmp/flutter sdk/packages/flutter/test/widgets/semantics_2_test.dart: Semantics 2                                                                                                  
03:50 +3016 ~7 -23: Some tests failed.                                                                                                                                                                 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ERROR: Last command exited with 1 (expected: zero).
Command: ../../bin/flutter test --track-widget-creation --enable-experiment=non-nullable --null-assertions --sound-null-safety test/widgets/
Relative working directory: packages/flutter
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

@goderbauer
Copy link
Member Author

@goderbauer goderbauer commented Oct 21, 2020

The failing widget_inspector_test.dart are blocked on #68661.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

LGTM

goderbauer added 13 commits Oct 20, 2020
++
++
++
++
++
++
++
++
++
++
@goderbauer goderbauer force-pushed the goderbauer:soundmode2 branch from 4513adf to 133a5c3 Oct 21, 2020
@jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Oct 21, 2020

The last few widget inspector failures need:

diff --git a/packages/flutter_test/lib/src/_matchers_io.dart b/packages/flutter_test/lib/src/_matchers_io.dart
index 9c1f02244d..23c7a2b1a2 100644
--- a/packages/flutter_test/lib/src/_matchers_io.dart
+++ b/packages/flutter_test/lib/src/_matchers_io.dart
@@ -52,6 +52,8 @@ class MatchesGoldenFile extends AsyncMatcher {
     Future<ui.Image> imageFuture;
     if (item is Future<ui.Image>) {
       imageFuture = item;
+    } else if (item is Future<ui.Image?>) {
+      imageFuture = item.then((ui.Image? image) => image!);
     } else if (item is ui.Image) {
       imageFuture = Future<ui.Image>.value(item);
     } else {

Additionally you should only pass --sound-null-safety to the framework and flutter_test tests.

++
@jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Oct 21, 2020

That works too :)

++
@goderbauer goderbauer changed the title Null safety sound mode fixes Sound null safety for framework and flutter_test Oct 21, 2020
@shihaohong
Copy link
Contributor

@shihaohong shihaohong commented Oct 21, 2020

The failing internal tests are legit, but we can fix the code there there after merging this PR -- Some user code expects the returned value to be a non-nullable type for the result of Navigator.of(context)!.push().

Copy link
Contributor

@shihaohong shihaohong left a comment

The null-safety code changes themselves LGTM, just some questions about example/layers since I'm less familiar and might've missed some context.

@@ -613,14 +614,14 @@ Future<void> _runFrameworkTests() async {
await _runFlutterTest(path.join(flutterRoot, 'dev', 'manual_tests'), tableData: bigqueryApi?.tabledata);
await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'vitool'), tableData: bigqueryApi?.tabledata);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'), tableData: bigqueryApi?.tabledata);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), tableData: bigqueryApi?.tabledata);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), tableData: bigqueryApi?.tabledata, options: mixedModeNullSafetyOptions);

This comment has been minimized.

@shihaohong

shihaohong Oct 21, 2020
Contributor

I might've missed the context, but what about the layer example that's giving it mixedModeNullSafetyOptions vs the rest of the tests?

This comment has been minimized.

@goderbauer

goderbauer Oct 21, 2020
Author Member

Some files from this example are imported from the framework tests, so I've only migrated those files. The remaining files are still unmigrated, so the tests for the examples themselves need to run in mixed mode.

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8
// @dart = 2.10

This comment has been minimized.

@shihaohong

shihaohong Oct 21, 2020
Contributor

Does this turn on null-safety, but in mixed mode for examples/layers?

This comment has been minimized.

@goderbauer

goderbauer Oct 21, 2020
Author Member

This allows us to use null safety syntax in this file (i.e. the ! and ?).

@@ -249,7 +249,7 @@ void main() {
});

testWidgets('Return value from pop is correct', (WidgetTester tester) async {
late Future<Object> result;
late Future<Object?> result;

This comment has been minimized.

@shihaohong

shihaohong Oct 21, 2020
Contributor

The internal test failure is similar to what caused this test to fail

This comment has been minimized.

@goderbauer

goderbauer Oct 21, 2020
Author Member

It's slightly different, fix is in cl/338282385.

@goderbauer
Copy link
Member Author

@goderbauer goderbauer commented Oct 21, 2020

Submitting, google3 is fixed with cl/338282385.

@goderbauer goderbauer merged commit 42f3709 into flutter:master Oct 21, 2020
68 of 69 checks passed
68 of 69 checks passed
Google testing Google testing failed. Please contact a Google developer to investigate.
Details
Linux analyze
Details
Linux build_aar_module_test
Details
Linux build_gallery
Details
Linux build_tests
Details
Linux customer_testing
Details
Linux docs
Details
Linux firebase_abstract_method_smoke_test
Details
Linux firebase_android_embedding_v2_smoke_test
Details
Linux firebase_release_smoke_test
Details
Linux framework_tests
Details
Linux fuchsia_precache
Details
Linux gradle_non_android_plugin_test
Details
Linux gradle_plugin_bundle_test
Details
Linux gradle_plugin_fat_apk_test
Details
Linux gradle_plugin_light_apk_test
Details
Linux module_custom_host_app_name_test
Details
Linux module_host_with_custom_build_test
Details
Linux module_test
Details
Linux plugin_test
Details
Linux tool_tests
Details
Linux web_benchmarks_html
Details
Linux web_e2e_test
Details
Linux web_integration_tests
Details
Linux web_smoke_test
Details
Linux web_tests
Details
Mac build_aar_module_test
Details
Mac build_gallery
Details
Mac build_ios_framework_module_test
Details
Mac build_tests
Details
Mac customer_testing
Details
Mac framework_tests
Details
Mac gradle_non_android_plugin_test
Details
Mac gradle_plugin_bundle_test
Details
Mac gradle_plugin_fat_apk_test
Details
Mac gradle_plugin_light_apk_test
Details
Mac module_custom_host_app_name_test
Details
Mac module_host_with_custom_build_test
Details
Mac module_test
Details
Mac module_test_ios
Details
Mac plugin_lint_mac
Details
Mac plugin_test
Details
Mac tool_tests
Details
WIP Ready for review
Details
Windows build_aar_module_test
Details
Windows build_tests
Details
Windows customer_testing
Details
Windows framework_tests
Details
Windows gradle_non_android_plugin_test
Details
Windows gradle_plugin_bundle_test
Details
Windows gradle_plugin_light_apk_test
Details
Windows module_custom_host_app_name_test
Details
Windows module_host_with_custom_build_test
Details
Windows module_test
Details
Windows plugin_test
Details
Windows tool_tests
Details
analyze-linux Task Summary
Details
cla/google All necessary CLAs are signed
customer_testing-linux Task Summary
Details
docs-linux Task Summary
Details
flutter-build
Details
flutter-gold All golden file tests have passed.
Details
framework_tests-libraries-linux Task Summary
Details
framework_tests-misc-linux Task Summary
Details
framework_tests-widgets-linux Task Summary
Details
tool_tests-commands-linux Task Summary
Details
tool_tests-general-linux Task Summary
Details
web_integration_tests Task Summary
Details
web_smoke_test Task Summary
Details
@goderbauer goderbauer deleted the goderbauer:soundmode2 branch Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.