Skip to content

Commit 0a9c124

Browse files
authored
Migrate several test files to null safety (#2871)
1 parent 797cf81 commit 0a9c124

8 files changed

+19
-55
lines changed

test/markdown_processor_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
library dartdoc.markdown_processor_test;
86

97
import 'package:dartdoc/src/markdown_processor.dart';

test/model_utils_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
library dartdoc.model_utils_test;
86

97
import 'package:dartdoc/src/model_utils.dart';

test/quiver_test.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:dartdoc/src/quiver.dart';
86
import 'package:test/test.dart';
97

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

33-
test('should throw for null input', () {
34-
expect(() => concat(null), throwsNoSuchMethodError);
35-
});
36-
37-
test('should throw if any input is null', () {
38-
expect(
39-
() => concat([
40-
[1, 2],
41-
null,
42-
[3, 4]
43-
]).toList(),
44-
throwsNoSuchMethodError);
45-
});
46-
4731
test('should reflectchanges in the inputs', () {
4832
var a = [1, 2];
4933
var b = [4, 5];

test/resource_loader_test.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
library dartdoc.resource_loader_test;
86

9-
import 'package:analyzer/file_system/file_system.dart';
107
import 'package:analyzer/file_system/physical_file_system.dart';
118
import 'package:dartdoc/src/generator/resource_loader.dart';
129
import 'package:test/test.dart';
1310

1411
void main() {
1512
group('Resource Loader', () {
16-
ResourceProvider resourceProvider;
17-
18-
setUp(() {
19-
resourceProvider = PhysicalResourceProvider();
20-
});
13+
var resourceProvider = PhysicalResourceProvider();
2114

2215
test('load from packages', () async {
2316
var contents = await resourceProvider

test/source_linker_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
library dartdoc.source_linker_test;
86

97
import 'package:dartdoc/src/dartdoc_options.dart';

test/tool_runner_test.dart

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
library dartdoc.model_test;
86

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

2220
void main() {
2321
ToolConfiguration toolMap;
24-
Directory tempDir;
25-
File setupFile;
22+
Directory? tempDir;
23+
late File setupFile;
2624

27-
ToolRunner runner;
28-
ToolTempFileTracker tracker;
29-
ToolErrorCallback errorCallback;
25+
late ToolRunner runner;
26+
late ToolErrorCallback errorCallback;
3027
final errors = <String>[];
3128

3229
setUpAll(() async {
33-
ProcessResult result;
30+
ProcessResult? result;
3431
tempDir = Directory.systemTemp.createTempSync('tool_runner_test_');
35-
var snapshotFile = path.join(tempDir.path, 'drill.snapshot');
32+
var snapshotFile = path.join(tempDir!.path, 'drill.snapshot');
3633
try {
3734
result = Process.runSync(
3835
Platform.resolvedExecutable,
@@ -52,7 +49,7 @@ void main() {
5249
stderr.writeln(result.stderr);
5350
}
5451
expect(result?.exitCode, equals(0));
55-
setupFile = File(path.join(tempDir.path, 'setup.stamp'));
52+
setupFile = File(path.join(tempDir!.path, 'setup.stamp'));
5653
var nonDartName = Platform.isWindows ? 'non_dart.bat' : 'non_dart.sh';
5754
var nonDartExecutable =
5855
path.join(_toolExecutableDir.absolute.path, nonDartName);
@@ -94,13 +91,11 @@ echo:
9491
runner = ToolRunner(toolMap);
9592
errorCallback = (String message) => errors.add(message);
9693
});
94+
9795
tearDownAll(() {
9896
tempDir?.deleteSync(recursive: true);
99-
tracker?.dispose();
10097
SnapshotCache.instanceFor(pubPackageMetaProvider.resourceProvider)
10198
.dispose();
102-
setupFile = null;
103-
tempDir = null;
10499
});
105100

106101
group('ToolRunner', () {
@@ -110,7 +105,8 @@ echo:
110105
// This test must come first, to verify that the first run creates
111106
// a snapshot.
112107
test('Tool definition includes compile arguments.', () async {
113-
DartToolDefinition definition = runner.toolConfiguration.tools['drill'];
108+
var definition =
109+
runner.toolConfiguration.tools['drill'] as DartToolDefinition;
114110
expect(definition.compileArgs, equals(['--no-sound-null-safety']));
115111
});
116112
test('can invoke a Dart tool, and second run is a snapshot.', () async {

test/utils_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
library dartdoc.utils_test;
86

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

1210
void main() {
13-
String comment;
14-
String documentation;
11+
late String comment;
12+
late String documentation;
1513

1614
// For readability, the multiline strings below have a left margin. This
1715
// is the length of that left margin.

test/warnings_test.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ import 'package:test/test.dart';
1717

1818
void main() {
1919
ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
20-
Folder tempDir, testPackageOne, testPackageTwo, testPackageThree;
21-
File pubspecYamlOne, pubspecYamlTwo, pubspecYamlThree, dartdocYamlThree;
20+
Folder testPackageOne, testPackageTwo, testPackageThree;
2221
DartdocOptionSet optionSet;
2322

2423
setUpAll(() {
25-
tempDir = resourceProvider.createSystemTemp('warnings_test');
24+
var tempDir = resourceProvider.createSystemTemp('warnings_test');
2625
testPackageOne = resourceProvider.getFolder(
2726
resourceProvider.pathContext.join(tempDir.path, 'test_package_one'))
2827
..create();
@@ -32,13 +31,13 @@ void main() {
3231
testPackageThree = resourceProvider.getFolder(
3332
resourceProvider.pathContext.join(tempDir.path, 'test_package_three'))
3433
..create();
35-
pubspecYamlOne = resourceProvider.getFile(
34+
var pubspecYamlOne = resourceProvider.getFile(
3635
resourceProvider.pathContext.join(testPackageOne.path, 'pubspec.yaml'));
3736
pubspecYamlOne.writeAsStringSync('name: test_package_one');
38-
pubspecYamlTwo = resourceProvider.getFile(
37+
var pubspecYamlTwo = resourceProvider.getFile(
3938
resourceProvider.pathContext.join(testPackageTwo.path, 'pubspec.yaml'));
4039
pubspecYamlTwo.writeAsStringSync('name: test_package_two');
41-
dartdocYamlThree = resourceProvider.getFile(resourceProvider.pathContext
40+
var dartdocYamlThree = resourceProvider.getFile(resourceProvider.pathContext
4241
.join(testPackageThree.path, 'dartdoc_options.yaml'));
4342
dartdocYamlThree.writeAsStringSync('''
4443
dartdoc:
@@ -50,7 +49,7 @@ dartdoc:
5049
ignore:
5150
- ambiguous-reexport
5251
''');
53-
pubspecYamlThree = resourceProvider.getFile(resourceProvider.pathContext
52+
var pubspecYamlThree = resourceProvider.getFile(resourceProvider.pathContext
5453
.join(testPackageThree.path, 'pubspec.yaml'));
5554
pubspecYamlThree.writeAsStringSync('name: test_package_three');
5655
});

0 commit comments

Comments
 (0)