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