Skip to content

Migrate several test files to null safety #2871

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

Merged
merged 4 commits into from
Jan 1, 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 test/markdown_processor_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

library dartdoc.markdown_processor_test;

import 'package:dartdoc/src/markdown_processor.dart';
Expand Down
2 changes: 0 additions & 2 deletions test/model_utils_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

library dartdoc.model_utils_test;

import 'package:dartdoc/src/model_utils.dart';
Expand Down
16 changes: 0 additions & 16 deletions test/quiver_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:dartdoc/src/quiver.dart';
import 'package:test/test.dart';

Expand All @@ -30,20 +28,6 @@ void main() {
[1, 2, 3, -1, -2, -3]);
});

test('should throw for null input', () {
expect(() => concat(null), throwsNoSuchMethodError);
});

test('should throw if any input is null', () {
expect(
() => concat([
[1, 2],
null,
[3, 4]
]).toList(),
throwsNoSuchMethodError);
});

test('should reflectchanges in the inputs', () {
var a = [1, 2];
var b = [4, 5];
Expand Down
9 changes: 1 addition & 8 deletions test/resource_loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@
// 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

library dartdoc.resource_loader_test;

import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:dartdoc/src/generator/resource_loader.dart';
import 'package:test/test.dart';

void main() {
group('Resource Loader', () {
ResourceProvider resourceProvider;

setUp(() {
resourceProvider = PhysicalResourceProvider();
});
var resourceProvider = PhysicalResourceProvider();

test('load from packages', () async {
var contents = await resourceProvider
Expand Down
2 changes: 0 additions & 2 deletions test/source_linker_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

library dartdoc.source_linker_test;

import 'package:dartdoc/src/dartdoc_options.dart';
Expand Down
24 changes: 10 additions & 14 deletions test/tool_runner_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

library dartdoc.model_test;

import 'dart:io';
Expand All @@ -21,18 +19,17 @@ final Directory _toolExecutableDir = Directory('testing/tool_executables');

void main() {
ToolConfiguration toolMap;
Directory tempDir;
File setupFile;
Directory? tempDir;
late File setupFile;

ToolRunner runner;
ToolTempFileTracker tracker;
ToolErrorCallback errorCallback;
late ToolRunner runner;
late ToolErrorCallback errorCallback;
final errors = <String>[];

setUpAll(() async {
ProcessResult result;
ProcessResult? result;
tempDir = Directory.systemTemp.createTempSync('tool_runner_test_');
var snapshotFile = path.join(tempDir.path, 'drill.snapshot');
var snapshotFile = path.join(tempDir!.path, 'drill.snapshot');
try {
result = Process.runSync(
Platform.resolvedExecutable,
Expand All @@ -52,7 +49,7 @@ void main() {
stderr.writeln(result.stderr);
}
expect(result?.exitCode, equals(0));
setupFile = File(path.join(tempDir.path, 'setup.stamp'));
setupFile = File(path.join(tempDir!.path, 'setup.stamp'));
var nonDartName = Platform.isWindows ? 'non_dart.bat' : 'non_dart.sh';
var nonDartExecutable =
path.join(_toolExecutableDir.absolute.path, nonDartName);
Expand Down Expand Up @@ -94,13 +91,11 @@ echo:
runner = ToolRunner(toolMap);
errorCallback = (String message) => errors.add(message);
});

tearDownAll(() {
tempDir?.deleteSync(recursive: true);
tracker?.dispose();
SnapshotCache.instanceFor(pubPackageMetaProvider.resourceProvider)
.dispose();
setupFile = null;
tempDir = null;
});

group('ToolRunner', () {
Expand All @@ -110,7 +105,8 @@ echo:
// This test must come first, to verify that the first run creates
// a snapshot.
test('Tool definition includes compile arguments.', () async {
DartToolDefinition definition = runner.toolConfiguration.tools['drill'];
var definition =
runner.toolConfiguration.tools['drill'] as DartToolDefinition;
expect(definition.compileArgs, equals(['--no-sound-null-safety']));
});
test('can invoke a Dart tool, and second run is a snapshot.', () async {
Expand Down
6 changes: 2 additions & 4 deletions test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// 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

library dartdoc.utils_test;

import 'package:dartdoc/src/utils.dart';
import 'package:test/test.dart';

void main() {
String comment;
String documentation;
late String comment;
late String documentation;

// For readability, the multiline strings below have a left margin. This
// is the length of that left margin.
Expand Down
13 changes: 6 additions & 7 deletions test/warnings_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import 'package:test/test.dart';

void main() {
ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
Folder tempDir, testPackageOne, testPackageTwo, testPackageThree;
File pubspecYamlOne, pubspecYamlTwo, pubspecYamlThree, dartdocYamlThree;
Folder testPackageOne, testPackageTwo, testPackageThree;
DartdocOptionSet optionSet;

setUpAll(() {
tempDir = resourceProvider.createSystemTemp('warnings_test');
var tempDir = resourceProvider.createSystemTemp('warnings_test');
testPackageOne = resourceProvider.getFolder(
resourceProvider.pathContext.join(tempDir.path, 'test_package_one'))
..create();
Expand All @@ -32,13 +31,13 @@ void main() {
testPackageThree = resourceProvider.getFolder(
resourceProvider.pathContext.join(tempDir.path, 'test_package_three'))
..create();
pubspecYamlOne = resourceProvider.getFile(
var pubspecYamlOne = resourceProvider.getFile(
resourceProvider.pathContext.join(testPackageOne.path, 'pubspec.yaml'));
pubspecYamlOne.writeAsStringSync('name: test_package_one');
pubspecYamlTwo = resourceProvider.getFile(
var pubspecYamlTwo = resourceProvider.getFile(
resourceProvider.pathContext.join(testPackageTwo.path, 'pubspec.yaml'));
pubspecYamlTwo.writeAsStringSync('name: test_package_two');
dartdocYamlThree = resourceProvider.getFile(resourceProvider.pathContext
var dartdocYamlThree = resourceProvider.getFile(resourceProvider.pathContext
.join(testPackageThree.path, 'dartdoc_options.yaml'));
dartdocYamlThree.writeAsStringSync('''
dartdoc:
Expand All @@ -50,7 +49,7 @@ dartdoc:
ignore:
- ambiguous-reexport
''');
pubspecYamlThree = resourceProvider.getFile(resourceProvider.pathContext
var pubspecYamlThree = resourceProvider.getFile(resourceProvider.pathContext
.join(testPackageThree.path, 'pubspec.yaml'));
pubspecYamlThree.writeAsStringSync('name: test_package_three');
});
Expand Down