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

Convert test files to null-safety #1683

Merged
merged 7 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dwds/test/build/ensure_version_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

@TestOn('vm')
import 'dart:io';

Expand Down
7 changes: 3 additions & 4 deletions dwds/test/build/min_sdk_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

@TestOn('vm')
@Skip('Intended to run in analyze stage on stable SDK only, see mono_pkg.yaml')
import 'dart:io';
Expand All @@ -19,8 +17,9 @@ void main() {
sdkVersion = Version(sdkVersion.major, sdkVersion.minor, 0);

final sdkConstraint = VersionConstraint.compatibleWith(sdkVersion);
final pubspecSdkConstraint = pubspec.environment['sdk'];
expect(sdkConstraint.allowsAll(pubspecSdkConstraint), true,
final pubspecSdkConstraint = pubspec.environment?['sdk'];
expect(pubspecSdkConstraint, isNotNull);
expect(sdkConstraint.allowsAll(pubspecSdkConstraint!), true,
reason:
'Min sdk constraint is outdated. Please update SDK constraint in '
'pubspec to allow latest stable and backwards compatible versions.'
Expand Down
21 changes: 8 additions & 13 deletions dwds/test/expression_compiler_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

@TestOn('vm')
import 'dart:async';
import 'dart:convert';
Expand All @@ -22,18 +20,15 @@ import 'fixtures/logging.dart';
void main() async {
group('expression compiler service with fake asset server', () {
final logger = Logger('ExpressionCompilerServiceTest');
ExpressionCompilerService service;
HttpServer server;
StreamController<String> output;
Directory outputDir;
late ExpressionCompilerService service;
late HttpServer server;
late StreamController<String> output;
late Directory outputDir;

Future<void> stop() async {
await service?.stop();
await server?.close();
await output?.close();
service = null;
server = null;
output = null;
await service.stop();
await server.close();
await output.close();
}

setUp(() async {
Expand Down Expand Up @@ -126,7 +121,7 @@ void main() async {
test('works with no errors', () async {
expect(output.stream, neverEmits(contains('[SEVERE]')));
expect(
output.stream,
output!.stream,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this assertion needed? Output is late non-nullable...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks!

emitsThrough(contains(
'[INFO] ExpressionCompilerService: Updating dependencies...')));
expect(
Expand Down
4 changes: 1 addition & 3 deletions dwds/test/extension_backend_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. 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:async';

import 'package:async/src/stream_queue.dart';
Expand Down Expand Up @@ -31,7 +29,7 @@ class MockSocketHandler implements SocketHandler {
}

void main() {
ExtensionBackend extensionBackend;
late ExtensionBackend extensionBackend;

setUpAll(() async {
extensionBackend =
Expand Down
2 changes: 0 additions & 2 deletions dwds/test/metadata/class_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. 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:dwds/src/debugging/metadata/class.dart';
import 'package:test/test.dart';

Expand Down
2 changes: 0 additions & 2 deletions dwds/test/metadata_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. 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:dwds/asset_reader.dart';
import 'package:dwds/src/debugging/metadata/module_metadata.dart';
import 'package:dwds/src/debugging/metadata/provider.dart';
Expand Down
12 changes: 6 additions & 6 deletions dwds/test/objects_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

@TestOn('vm')
import 'package:dwds/src/utilities/objects.dart';
import 'package:test/test.dart';
Expand All @@ -18,16 +16,18 @@ void main() {
// or from a RemoteObject.
final property = Property({'name': 'prop', 'value': exampleMap});
expect(property.rawValue, exampleMap);
expect(property.value.objectId, '1234');
expect(property.value.value, 'abcd');
final value = property.value!;
expect(value.objectId, '1234');
expect(value.value, 'abcd');
expect(property.name, 'prop');
});
test('from a RemoteObject', () {
final remoteObject = RemoteObject({'objectId': '1234', 'value': 'abcd'});
final property = Property({'name': 'prop', 'value': remoteObject});
expect(property.rawValue, remoteObject);
expect(property.value.objectId, '1234');
expect(property.value.value, 'abcd');
final value = property.value!;
expect(value.objectId, '1234');
expect(value.value, 'abcd');
expect(property.name, 'prop');
});

Expand Down
10 changes: 4 additions & 6 deletions dwds/test/readers/frontend_server_asset_reader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. 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:async';
import 'dart:io';

Expand All @@ -16,10 +14,10 @@ import '../fixtures/utilities.dart';
final packagesDir = p.relative('../fixtures/_test', from: p.current);

void main() {
FrontendServerAssetReader assetReader;
Directory tempFixtures;
File jsonOriginal;
File mapOriginal;
late FrontendServerAssetReader assetReader;
late Directory tempFixtures;
late File jsonOriginal;
late File mapOriginal;

Future<void> createTempFixtures() async {
final fixtures = p.join('test', 'fixtures');
Expand Down
14 changes: 6 additions & 8 deletions dwds/test/sdk_configuration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

@TestOn('vm')
import 'dart:io';

Expand Down Expand Up @@ -34,7 +32,7 @@ void main() {
});

group('Non-standard configuration', () {
Directory outputDir;
late Directory outputDir;

setUp(() async {
final systemTempDir = Directory.systemTemp;
Expand All @@ -54,24 +52,24 @@ void main() {
final librariesPath = p.join(librariesDir, 'libraries.json');

Directory(librariesDir).createSync(recursive: true);
File(defaultSdkConfiguration.librariesPath).copySync(librariesPath);
File(defaultSdkConfiguration.librariesPath!).copySync(librariesPath);

final summariesDir = p.join(sdkDirectory, 'summaries');
final unsoundSdkSummaryPath = p.join(summariesDir, 'ddc_sdk.dill');
final soundSdkSummaryPath =
p.join(summariesDir, 'ddc_outline_sound.dill');

Directory(summariesDir).createSync(recursive: true);
File(defaultSdkConfiguration.unsoundSdkSummaryPath)
File(defaultSdkConfiguration.unsoundSdkSummaryPath!)
.copySync(unsoundSdkSummaryPath);
File(defaultSdkConfiguration.soundSdkSummaryPath)
File(defaultSdkConfiguration.soundSdkSummaryPath!)
.copySync(soundSdkSummaryPath);

final workerDir = p.join(sdkDirectory, 'snapshots');
final compilerWorkerPath = p.join(workerDir, 'dartdevc.dart.snapshot');

Directory(workerDir).createSync(recursive: true);
File(defaultSdkConfiguration.compilerWorkerPath)
File(defaultSdkConfiguration.compilerWorkerPath!)
.copySync(compilerWorkerPath);

final sdkConfiguration = SdkConfiguration(
Expand Down Expand Up @@ -118,7 +116,7 @@ void main() {
});

group('SDK configuration', () {
MemoryFileSystem fs;
late MemoryFileSystem fs;

final root = '/root';
final sdkDirectory = root;
Expand Down
4 changes: 1 addition & 3 deletions dwds/test/skip_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// for details. All rights reserved. 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:dwds/src/debugging/location.dart';
import 'package:dwds/src/debugging/skip_list.dart';
import 'package:source_maps/parser.dart';
import 'package:test/test.dart';

void main() {
SkipLists skipLists;
late SkipLists skipLists;
group('SkipLists', () {
setUp(() {
skipLists = SkipLists();
Expand Down
2 changes: 0 additions & 2 deletions dwds/test/web/batched_stream_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

@Retry(0)

import 'dart:async';
Expand Down