[null-safety] update tests and tool auto-detection for null safe dart (#69405)
Disable null safety auto-detection for the web
This commit is contained in:
parent
2562224665
commit
3e41962dff
@ -912,6 +912,7 @@ Future<void> _runGalleryE2eWebTest(String buildMode, { bool canvasKit = false })
|
|||||||
'--driver=test_driver/transitions_perf_e2e_test.dart',
|
'--driver=test_driver/transitions_perf_e2e_test.dart',
|
||||||
'--target=test_driver/transitions_perf_e2e.dart',
|
'--target=test_driver/transitions_perf_e2e.dart',
|
||||||
'--browser-name=chrome',
|
'--browser-name=chrome',
|
||||||
|
'--no-sound-null-safety',
|
||||||
'-d',
|
'-d',
|
||||||
'web-server',
|
'web-server',
|
||||||
'--$buildMode',
|
'--$buildMode',
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter_driver/driver_extension.dart';
|
import 'package:flutter_driver/driver_extension.dart';
|
||||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter_driver/flutter_driver.dart';
|
import 'package:flutter_driver/flutter_driver.dart';
|
||||||
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter_driver/driver_extension.dart';
|
import 'package:flutter_driver/driver_extension.dart';
|
||||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter_driver/flutter_driver.dart';
|
import 'package:flutter_driver/flutter_driver.dart';
|
||||||
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'dart:convert' show JsonEncoder;
|
import 'dart:convert' show JsonEncoder;
|
||||||
|
|
||||||
import 'package:flutter_driver/driver_extension.dart';
|
import 'package:flutter_driver/driver_extension.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:integration_test/integration_test_driver.dart' as driver;
|
import 'package:integration_test/integration_test_driver.dart' as driver;
|
||||||
|
|
||||||
Future<void> main() => driver.integrationDriver(
|
Future<void> main() => driver.integrationDriver(
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'transitions_perf_e2e.dart' as transitions_perf;
|
import 'transitions_perf_e2e.dart' as transitions_perf;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'transitions_perf_test.dart' as transitions_perf_test;
|
import 'transitions_perf_test.dart' as transitions_perf_test;
|
||||||
|
|
||||||
void main([List<String> args = const <String>[]]) => transitions_perf_test.main(
|
void main([List<String> args = const <String>[]]) => transitions_perf_test.main(
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'dart:convert' show JsonEncoder, json;
|
import 'dart:convert' show JsonEncoder, json;
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'transitions_perf_test.dart' as transitions_perf_test;
|
import 'transitions_perf_test.dart' as transitions_perf_test;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
|
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
// See //dev/devicelab/bin/tasks/flutter_gallery__image_cache_memory.dart
|
// See //dev/devicelab/bin/tasks/flutter_gallery__image_cache_memory.dart
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
|
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'dart:html';
|
import 'dart:html';
|
||||||
import 'dart:js_util' as js_util;
|
import 'dart:js_util' as js_util;
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// @dart = 2.9
|
||||||
import 'package:integration_test/integration_test_driver.dart' as test;
|
import 'package:integration_test/integration_test_driver.dart' as test;
|
||||||
|
|
||||||
Future<void> main() async => test.integrationDriver();
|
Future<void> main() async => test.integrationDriver();
|
||||||
|
@ -97,12 +97,17 @@ class FlutterDevice {
|
|||||||
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound) {
|
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound) {
|
||||||
platformDillArtifact = Artifact.webPlatformKernelDill;
|
platformDillArtifact = Artifact.webPlatformKernelDill;
|
||||||
extraFrontEndOptions = buildInfo.extraFrontEndOptions;
|
extraFrontEndOptions = buildInfo.extraFrontEndOptions;
|
||||||
} else {
|
} else if (buildInfo.nullSafetyMode == NullSafetyMode.sound) {
|
||||||
platformDillArtifact = Artifact.webPlatformSoundKernelDill;
|
platformDillArtifact = Artifact.webPlatformSoundKernelDill;
|
||||||
extraFrontEndOptions = <String>[
|
extraFrontEndOptions = buildInfo.extraFrontEndOptions;
|
||||||
...?buildInfo?.extraFrontEndOptions,
|
} else {
|
||||||
if (!(buildInfo?.extraFrontEndOptions?.contains('--sound-null-safety') ?? false))
|
// TODO(jonahwilliams): null-safe auto detection does not currently
|
||||||
'--sound-null-safety'
|
// work on the web. Always opt out of null safety if it was not
|
||||||
|
// specifically requested.
|
||||||
|
platformDillArtifact = Artifact.webPlatformKernelDill;
|
||||||
|
extraFrontEndOptions = <String>[
|
||||||
|
...?buildInfo.extraFrontEndOptions,
|
||||||
|
'--no-sound-null-safety',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +585,7 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
'Flutter mobile & desktop applications will attempt to run at the null safety '
|
'Flutter mobile & desktop applications will attempt to run at the null safety '
|
||||||
'level of their entrypoint library (usually lib/main.dart). Flutter web '
|
'level of their entrypoint library (usually lib/main.dart). Flutter web '
|
||||||
'applications will default to sound null-safety, unless specifically configured.',
|
'applications will default to sound null-safety, unless specifically configured.',
|
||||||
defaultsTo: null,
|
defaultsTo: true,
|
||||||
hide: hide,
|
hide: hide,
|
||||||
);
|
);
|
||||||
argParser.addFlag(FlutterOptions.kNullAssertions,
|
argParser.addFlag(FlutterOptions.kNullAssertions,
|
||||||
@ -783,18 +783,17 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
|
|
||||||
NullSafetyMode nullSafetyMode = NullSafetyMode.unsound;
|
NullSafetyMode nullSafetyMode = NullSafetyMode.unsound;
|
||||||
if (argParser.options.containsKey(FlutterOptions.kNullSafety)) {
|
if (argParser.options.containsKey(FlutterOptions.kNullSafety)) {
|
||||||
final bool nullSafety = boolArg(FlutterOptions.kNullSafety);
|
|
||||||
// Explicitly check for `true` and `false` so that `null` results in not
|
// Explicitly check for `true` and `false` so that `null` results in not
|
||||||
// passing a flag. This will use the automatically detected null-safety
|
// passing a flag. This will use the automatically detected null-safety
|
||||||
// value based on the entrypoint
|
// value based on the entrypoint
|
||||||
if (nullSafety == true) {
|
if (!argResults.wasParsed(FlutterOptions.kNullSafety)) {
|
||||||
|
nullSafetyMode = NullSafetyMode.autodetect;
|
||||||
|
} else if (boolArg(FlutterOptions.kNullSafety)) {
|
||||||
nullSafetyMode = NullSafetyMode.sound;
|
nullSafetyMode = NullSafetyMode.sound;
|
||||||
extraFrontEndOptions.add('--sound-null-safety');
|
extraFrontEndOptions.add('--sound-null-safety');
|
||||||
} else if (nullSafety == false) {
|
} else {
|
||||||
nullSafetyMode = NullSafetyMode.unsound;
|
nullSafetyMode = NullSafetyMode.unsound;
|
||||||
extraFrontEndOptions.add('--no-sound-null-safety');
|
extraFrontEndOptions.add('--no-sound-null-safety');
|
||||||
} else if (extraFrontEndOptions.contains('--enable-experiment=non-nullable')) {
|
|
||||||
nullSafetyMode = NullSafetyMode.autodetect;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2517,7 +2517,7 @@ void main() {
|
|||||||
Artifacts: () => Artifacts.test(),
|
Artifacts: () => Artifacts.test(),
|
||||||
FileSystem: () => MemoryFileSystem.test(),
|
FileSystem: () => MemoryFileSystem.test(),
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
}, skip: true); // TODO(jonahwilliams): null safe autodetection does not work on the web.
|
||||||
|
|
||||||
testUsingContext('FlutterDevice passes flutter-widget-cache flag when feature is enabled', () async {
|
testUsingContext('FlutterDevice passes flutter-widget-cache flag when feature is enabled', () async {
|
||||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
|
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user