@@ -80,19 +80,25 @@ Future<int> test5CallCompute(int value) {
80
80
return compute (test5, value);
81
81
}
82
82
83
- Future <void > expectFileSuccessfullyCompletes (String filename) async {
83
+ Future <void > expectFileSuccessfullyCompletes (String filename,
84
+ [bool unsound = false ]) async {
84
85
// Run a Dart script that calls compute().
85
86
// The Dart process will terminate only if the script exits cleanly with
86
87
// all isolate ports closed.
87
88
const FileSystem fs = LocalFileSystem ();
88
89
const Platform platform = LocalPlatform ();
89
90
final String flutterRoot = platform.environment['FLUTTER_ROOT' ]! ;
90
- final String dartPath = fs.path.join (flutterRoot, 'bin' , 'cache' , 'dart-sdk' , 'bin' , 'dart' );
91
+ final String dartPath =
92
+ fs.path.join (flutterRoot, 'bin' , 'cache' , 'dart-sdk' , 'bin' , 'dart' );
91
93
final String packageRoot = fs.path.dirname (fs.path.fromUri (platform.script));
92
- final String scriptPath = fs.path.join (packageRoot, 'test' , 'foundation' , filename);
94
+ final String scriptPath =
95
+ fs.path.join (packageRoot, 'test' , 'foundation' , filename);
96
+ final String nullSafetyArg =
97
+ unsound ? '--no-sound-null-safety' : '--sound-null-safety' ;
93
98
94
99
// Enable asserts to also catch potentially invalid assertions.
95
- final ProcessResult result = await Process .run (dartPath, < String > ['run' , '--enable-asserts' , scriptPath]);
100
+ final ProcessResult result = await Process .run (
101
+ dartPath, < String > [nullSafetyArg, 'run' , '--enable-asserts' , scriptPath]);
96
102
expect (result.exitCode, 0 );
97
103
}
98
104
@@ -194,7 +200,8 @@ void main() {
194
200
expect (await computeInstanceMethod (10 ), 100 );
195
201
expect (computeInvalidInstanceMethod (10 ), throwsArgumentError);
196
202
197
- expect (await compute (testDebugName, null , debugLabel: 'debug_name' ), 'debug_name' );
203
+ expect (await compute (testDebugName, null , debugLabel: 'debug_name' ),
204
+ 'debug_name' );
198
205
expect (await compute (testReturnNull, null ), null );
199
206
}, skip: kIsWeb); // [intended] isn't supported on the web.
200
207
@@ -203,22 +210,26 @@ void main() {
203
210
await expectFileSuccessfullyCompletes ('_compute_caller.dart' );
204
211
});
205
212
test ('with invalid message' , () async {
206
- await expectFileSuccessfullyCompletes ('_compute_caller_invalid_message.dart' );
213
+ await expectFileSuccessfullyCompletes (
214
+ '_compute_caller_invalid_message.dart' );
207
215
});
208
216
test ('with valid error' , () async {
209
217
await expectFileSuccessfullyCompletes ('_compute_caller.dart' );
210
218
});
211
219
test ('with invalid error' , () async {
212
- await expectFileSuccessfullyCompletes ('_compute_caller_invalid_message.dart' );
220
+ await expectFileSuccessfullyCompletes (
221
+ '_compute_caller_invalid_message.dart' );
213
222
});
214
223
}, skip: kIsWeb); // [intended] isn't supported on the web.
215
224
216
225
group ('compute() works with unsound null safety caller' , () {
217
226
test ('returning' , () async {
218
- await expectFileSuccessfullyCompletes ('_compute_caller_unsound_null_safety.dart' );
227
+ await expectFileSuccessfullyCompletes (
228
+ '_compute_caller_unsound_null_safety.dart' , true );
219
229
});
220
230
test ('erroring' , () async {
221
- await expectFileSuccessfullyCompletes ('_compute_caller_unsound_null_safety_error.dart' );
231
+ await expectFileSuccessfullyCompletes (
232
+ '_compute_caller_unsound_null_safety_error.dart' , true );
222
233
});
223
234
}, skip: kIsWeb); // [intended] isn't supported on the web.
224
235
}
0 commit comments