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 all commits
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
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
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
16 changes: 7 additions & 9 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,15 +32,15 @@ void main() {
});

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

setUp(() async {
final systemTempDir = Directory.systemTemp;
outputDir = systemTempDir.createTempSync('foo bar');
});

tearDown(() async {
await outputDir?.delete(recursive: true);
await outputDir.delete(recursive: true);
});

test('Can validate existing configuration layout', () async {
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
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