Unverified Commit 83980ef2 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate event_printer and test_config to null safety (#79346)

parent b6a6ea70
...@@ -248,7 +248,6 @@ class Stdio { ...@@ -248,7 +248,6 @@ class Stdio {
Stream<List<int>> get stdin => io.stdin; Stream<List<int>> get stdin => io.stdin;
@visibleForTesting
io.Stdout get stdout { io.Stdout get stdout {
if (_stdout != null) { if (_stdout != null) {
return _stdout!; return _stdout!;
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
// 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.8
import 'package:meta/meta.dart';
import '../../base/file_system.dart'; import '../../base/file_system.dart';
import '../depfile.dart'; import '../depfile.dart';
...@@ -18,12 +14,12 @@ import '../depfile.dart'; ...@@ -18,12 +14,12 @@ import '../depfile.dart';
/// Throws an [Exception] if [artifacts] includes missing files, directories, /// Throws an [Exception] if [artifacts] includes missing files, directories,
/// or links. /// or links.
Depfile unpackDesktopArtifacts({ Depfile unpackDesktopArtifacts({
@required FileSystem fileSystem, required FileSystem fileSystem,
@required List<String> artifacts, required List<String> artifacts,
@required Directory outputDirectory, required Directory outputDirectory,
@required String engineSourcePath, required String engineSourcePath,
List<String> clientSourcePaths, List<String>? clientSourcePaths,
String icuDataPath, String? icuDataPath,
}) { }) {
final List<File> inputs = <File>[]; final List<File> inputs = <File>[];
final List<File> outputs = <File>[]; final List<File> outputs = <File>[];
......
...@@ -310,7 +310,7 @@ class TestCommand extends FlutterCommand { ...@@ -310,7 +310,7 @@ class TestCommand extends FlutterCommand {
TestWatcher watcher; TestWatcher watcher;
if (machine) { if (machine) {
watcher = EventPrinter(parent: collector); watcher = EventPrinter(parent: collector, out: globals.stdio.stdout);
} else if (collector != null) { } else if (collector != null) {
watcher = collector; watcher = collector;
} }
......
...@@ -2,25 +2,22 @@ ...@@ -2,25 +2,22 @@
// 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.8
import '../convert.dart'; import '../convert.dart';
import '../globals.dart' as globals;
import 'test_device.dart'; import 'test_device.dart';
import 'watcher.dart'; import 'watcher.dart';
/// Prints JSON events when running a test in --machine mode. /// Prints JSON events when running a test in --machine mode.
class EventPrinter extends TestWatcher { class EventPrinter extends TestWatcher {
EventPrinter({StringSink out, TestWatcher parent}) EventPrinter({required StringSink out, TestWatcher? parent})
: _out = out ?? globals.stdio.stdout, : _out = out,
_parent = parent; _parent = parent;
final StringSink _out; final StringSink _out;
final TestWatcher _parent; final TestWatcher? _parent;
@override @override
void handleStartedDevice(Uri observatoryUri) { void handleStartedDevice(Uri? observatoryUri) {
_sendEvent('test.startedProcess', _sendEvent('test.startedProcess',
<String, dynamic>{'observatoryUri': observatoryUri?.toString()}); <String, dynamic>{'observatoryUri': observatoryUri?.toString()});
_parent?.handleStartedDevice(observatoryUri); _parent?.handleStartedDevice(observatoryUri);
......
...@@ -517,7 +517,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -517,7 +517,7 @@ class FlutterPlatform extends PlatformPlugin {
); );
return generateTestBootstrap( return generateTestBootstrap(
testUrl: testUrl, testUrl: testUrl,
testConfigFile: findTestConfigFile(globals.fs.file(testUrl)), testConfigFile: findTestConfigFile(globals.fs.file(testUrl), globals.logger),
host: host, host: host,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
flutterTestDep: packageConfig['flutter_test'] != null, flutterTestDep: packageConfig['flutter_test'] != null,
......
...@@ -147,7 +147,7 @@ class TestGoldenComparatorProcess { ...@@ -147,7 +147,7 @@ class TestGoldenComparatorProcess {
} }
static String generateBootstrap(Uri testUri) { static String generateBootstrap(Uri testUri) {
final File testConfigFile = findTestConfigFile(globals.fs.file(testUri)); final File testConfigFile = findTestConfigFile(globals.fs.file(testUri), globals.logger);
// Generate comparator process for the file. // Generate comparator process for the file.
return ''' return '''
import 'dart:convert'; // flutter_ignore: dart_convert_import import 'dart:convert'; // flutter_ignore: dart_convert_import
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
// 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.8
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../globals.dart' as globals; import '../base/logger.dart';
/// The name of the test configuration file that will be discovered by the /// The name of the test configuration file that will be discovered by the
/// test harness if it exists in the project directory hierarchy. /// test harness if it exists in the project directory hierarchy.
...@@ -16,18 +14,18 @@ const String _kTestConfigFileName = 'flutter_test_config.dart'; ...@@ -16,18 +14,18 @@ const String _kTestConfigFileName = 'flutter_test_config.dart';
const String _kProjectRootSentinel = 'pubspec.yaml'; const String _kProjectRootSentinel = 'pubspec.yaml';
/// Find the `flutter_test_config.dart` file for a specific test file. /// Find the `flutter_test_config.dart` file for a specific test file.
File findTestConfigFile(File testFile) { File? findTestConfigFile(File testFile, Logger logger) {
File testConfigFile; File? testConfigFile;
Directory directory = testFile.parent; Directory directory = testFile.parent;
while (directory.path != directory.parent.path) { while (directory.path != directory.parent.path) {
final File configFile = directory.childFile(_kTestConfigFileName); final File configFile = directory.childFile(_kTestConfigFileName);
if (configFile.existsSync()) { if (configFile.existsSync()) {
globals.printTrace('Discovered $_kTestConfigFileName in ${directory.path}'); logger.printTrace('Discovered $_kTestConfigFileName in ${directory.path}');
testConfigFile = configFile; testConfigFile = configFile;
break; break;
} }
if (directory.childFile(_kProjectRootSentinel).existsSync()) { if (directory.childFile(_kProjectRootSentinel).existsSync()) {
globals.printTrace('Stopping scan for $_kTestConfigFileName; ' logger.printTrace('Stopping scan for $_kTestConfigFileName; '
'found project root at ${directory.path}'); 'found project root at ${directory.path}');
break; break;
} }
......
...@@ -10,7 +10,7 @@ abstract class TestWatcher { ...@@ -10,7 +10,7 @@ abstract class TestWatcher {
/// ///
/// If startPaused was true, the caller needs to resume in Observatory to /// If startPaused was true, the caller needs to resume in Observatory to
/// start running the tests. /// start running the tests.
void handleStartedDevice(Uri observatoryUri) { } void handleStartedDevice(Uri? observatoryUri) { }
/// Called after the tests finish but before the test device exits. /// Called after the tests finish but before the test device exits.
/// ///
......
...@@ -83,7 +83,7 @@ class WebTestCompiler { ...@@ -83,7 +83,7 @@ class WebTestCompiler {
..writeAsStringSync(generateTestEntrypoint( ..writeAsStringSync(generateTestEntrypoint(
relativeTestPath: relativeTestSegments.join('/'), relativeTestPath: relativeTestSegments.join('/'),
absolutePath: testFilePath, absolutePath: testFilePath,
testConfigPath: findTestConfigFile(_fileSystem.file(testFilePath))?.path, testConfigPath: findTestConfigFile(_fileSystem.file(testFilePath), _logger)?.path,
languageVersion: languageVersion, languageVersion: languageVersion,
)); ));
generatedFiles.add(generatedFile); generatedFiles.add(generatedFile);
......
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