Skip to content

Commit c850242

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[test] Remove use of package:test from standalone tests.
Bug: #61548 Change-Id: I7a4d562a88d5d2f4ca2245e924411042ec463c37 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452544 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Brian Quinlan <bquinlan@google.com>
1 parent 95222f1 commit c850242

File tree

4 files changed

+287
-297
lines changed

4 files changed

+287
-297
lines changed

tests/standalone/io/non_utf8_directory_test.dart

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,92 @@
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-
import 'dart:async';
6-
import 'dart:io';
7-
import 'dart:typed_data';
5+
import "dart:async";
6+
import "dart:io";
7+
import "dart:typed_data";
88

9-
import 'package:test/test.dart';
9+
import "package:expect/expect.dart";
1010

11-
Future main() async {
12-
var asyncDir;
13-
var syncDir;
14-
15-
test('Non-UTF8 Directory Listing', () async {
16-
final tmp = await Directory.systemTemp.createTemp(
17-
'non_utf8_directory_test_async',
18-
);
19-
try {
20-
final rawPath = new Uint8List.fromList([182]);
21-
asyncDir = new Directory.fromRawPath(rawPath);
22-
if (Platform.isMacOS || Platform.isIOS) {
23-
try {
24-
await asyncDir.create();
25-
} on FileSystemException catch (e) {
26-
// Macos doesn't support non-UTF-8 paths.
27-
await tmp.delete(recursive: true);
28-
return;
29-
}
30-
} else {
11+
testAsync() async {
12+
final tmp = await Directory.systemTemp.createTemp(
13+
"non_utf8_directory_test_async",
14+
);
15+
try {
16+
final rawPath = new Uint8List.fromList([182]);
17+
final asyncDir = new Directory.fromRawPath(rawPath);
18+
if (Platform.isMacOS || Platform.isIOS) {
19+
try {
3120
await asyncDir.create();
21+
} on FileSystemException catch (e) {
22+
// Macos doesn"t support non-UTF-8 paths.
23+
await tmp.delete(recursive: true);
24+
return;
3225
}
33-
expect(await asyncDir.exists(), isTrue);
26+
} else {
27+
await asyncDir.create();
28+
}
29+
Expect.isTrue(await asyncDir.exists());
3430

35-
await for (final e in tmp.list()) {
36-
// FIXME(bkonyi): reenable when rawPath is exposed.
37-
/*
31+
await for (final e in tmp.list()) {
32+
// FIXME(bkonyi): reenable when rawPath is exposed.
33+
/*
3834
if (Platform.isWindows) {
3935
// Windows replaces invalid characters with � when creating file system
4036
// entities.
4137
final raw = e.rawPath;
42-
expect(raw.sublist(raw.length - 3), [239, 191, 189]);
38+
Expect.listEquals(raw.sublist(raw.length - 3), [239, 191, 189]);
4339
} else {
44-
expect(e.rawPath.last, 182);
40+
Expect.equals(e.rawPath.last, 182);
4541
}
4642
*/
47-
}
48-
await asyncDir.delete(recursive: true);
49-
} finally {
50-
await tmp.delete(recursive: true);
5143
}
52-
});
44+
await asyncDir.delete(recursive: true);
45+
} finally {
46+
await tmp.delete(recursive: true);
47+
}
48+
}
5349

54-
test('Non-UTF8 Directory Sync Listing', () {
55-
final tmp = Directory.systemTemp.createTempSync(
56-
'non_utf8_directory_test_sync',
57-
);
58-
try {
59-
final rawPath = new Uint8List.fromList([182]);
60-
syncDir = new Directory.fromRawPath(rawPath);
50+
testSync() {
51+
final tmp = Directory.systemTemp.createTempSync(
52+
"non_utf8_directory_test_sync",
53+
);
54+
try {
55+
final rawPath = new Uint8List.fromList([182]);
56+
final syncDir = new Directory.fromRawPath(rawPath);
6157

62-
if (Platform.isMacOS || Platform.isIOS) {
63-
try {
64-
syncDir.createSync();
65-
} on FileSystemException catch (e) {
66-
// Macos doesn't support non-UTF-8 paths.
67-
tmp.deleteSync(recursive: true);
68-
return;
69-
}
70-
} else {
58+
if (Platform.isMacOS || Platform.isIOS) {
59+
try {
7160
syncDir.createSync();
61+
} on FileSystemException catch (e) {
62+
// Macos doesn"t support non-UTF-8 paths.
63+
tmp.deleteSync(recursive: true);
64+
return;
7265
}
73-
expect(syncDir.existsSync(), isTrue);
66+
} else {
67+
syncDir.createSync();
68+
}
69+
Expect.isTrue(syncDir.existsSync());
7470

75-
for (final e in tmp.listSync()) {
76-
// FIXME(bkonyi): reenable when rawPath is exposed.
77-
/*
71+
for (final e in tmp.listSync()) {
72+
// FIXME(bkonyi): reenable when rawPath is exposed.
73+
/*
7874
if (Platform.isWindows) {
7975
// Windows replaces invalid characters with � when creating file system
8076
// entities.
8177
final raw = e.rawPath;
82-
expect(raw.sublist(raw.length - 3), [239, 191, 189]);
78+
Expect.listEquals(raw.sublist(raw.length - 3), [239, 191, 189]);
8379
} else {
84-
expect(e.rawPath.last, 182);
80+
Expect.isTrue(e.rawPath.last, 182);
8581
}
8682
*/
87-
}
88-
syncDir.deleteSync(recursive: true);
89-
} finally {
90-
tmp.deleteSync(recursive: true);
9183
}
92-
});
84+
syncDir.deleteSync(recursive: true);
85+
} finally {
86+
tmp.deleteSync(recursive: true);
87+
}
88+
}
89+
90+
main() async {
91+
await testAsync();
92+
testSync();
9393
}

tests/standalone/io/non_utf8_file_test.dart

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,97 @@
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-
import 'dart:async';
6-
import 'dart:io';
7-
import 'dart:typed_data';
5+
import "dart:async";
6+
import "dart:io";
7+
import "dart:typed_data";
88

9-
import 'package:test/test.dart';
9+
import "package:expect/expect.dart";
1010

11-
Future main() async {
12-
var asyncFile;
13-
var syncFile;
11+
testAsync() async {
12+
final tmp = await Directory.systemTemp.createTemp("non_utf8_file_test_async");
1413

15-
test('Non-UTF8 Filename', () async {
16-
final tmp = await Directory.systemTemp.createTemp(
17-
'non_utf8_file_test_async',
18-
);
19-
try {
20-
final rawPath = new Uint8List.fromList([182]);
21-
asyncFile = new File.fromRawPath(rawPath);
22-
if (Platform.isMacOS || Platform.isIOS) {
23-
try {
24-
await asyncFile.create();
25-
} on FileSystemException catch (e) {
26-
// Macos doesn't support non-UTF-8 paths.
27-
await tmp.delete(recursive: true);
28-
return;
29-
}
30-
} else {
14+
try {
15+
final rawPath = new Uint8List.fromList([182]);
16+
final asyncFile = new File.fromRawPath(rawPath);
17+
if (Platform.isMacOS || Platform.isIOS) {
18+
try {
3119
await asyncFile.create();
20+
} on FileSystemException catch (e) {
21+
// Macos doesn"t support non-UTF-8 paths.
22+
await tmp.delete(recursive: true);
23+
return;
3224
}
33-
expect(await asyncFile.exists(), isTrue);
25+
} else {
26+
await asyncFile.create();
27+
}
28+
Expect.isTrue(await asyncFile.exists());
3429

35-
for (final file in tmp.listSync()) {
36-
// FIXME(bkonyi): reenable when rawPath is exposed.
37-
/*
38-
if (Platform.isWindows) {
39-
// Windows replaces invalid characters with � when creating file system
40-
// entities.
41-
final raw = file.rawPath;
42-
expect(raw.sublist(raw.length - 3), [239, 191, 189]);
43-
} else {
44-
expect(file.rawPath.last, 182);
45-
}
46-
*/
47-
// FIXME(bkonyi): this isn't true on some versions of MacOS. Why?
48-
if (!Platform.isMacOS && !Platform.isIOS) {
49-
expect(file.path.endsWith('�'), isTrue);
50-
}
30+
for (final file in tmp.listSync()) {
31+
// FIXME(bkonyi): reenable when rawPath is exposed.
32+
/*
33+
if (Platform.isWindows) {
34+
// Windows replaces invalid characters with � when creating file system
35+
// entities.
36+
final raw = file.rawPath;
37+
Expect.listEquals(raw.sublist(raw.length - 3), [239, 191, 189]);
38+
} else {
39+
Expect.equals(file.rawPath.last, 182);
40+
}
41+
*/
42+
// FIXME(bkonyi): this isn"t true on some versions of MacOS. Why?
43+
if (!Platform.isMacOS && !Platform.isIOS) {
44+
Expect.isTrue(file.path.endsWith("�"));
5145
}
52-
await asyncFile.delete();
53-
} finally {
54-
await tmp.delete(recursive: true);
5546
}
56-
});
47+
await asyncFile.delete();
48+
} finally {
49+
await tmp.delete(recursive: true);
50+
}
51+
}
5752

58-
test('Non-UTF8 Filename Sync', () {
59-
final tmp = Directory.systemTemp.createTempSync('non_utf8_file_test_sync');
60-
try {
61-
final rawPath = new Uint8List.fromList([182]);
62-
syncFile = new File.fromRawPath(rawPath);
53+
testSync() {
54+
final tmp = Directory.systemTemp.createTempSync("non_utf8_file_test_sync");
55+
try {
56+
final rawPath = new Uint8List.fromList([182]);
57+
final syncFile = new File.fromRawPath(rawPath);
6358

64-
if (Platform.isMacOS || Platform.isIOS) {
65-
try {
66-
syncFile.createSync();
67-
} on FileSystemException catch (e) {
68-
// Macos doesn't support non-UTF-8 paths.
69-
tmp.deleteSync(recursive: true);
70-
return;
71-
}
72-
} else {
59+
if (Platform.isMacOS || Platform.isIOS) {
60+
try {
7361
syncFile.createSync();
62+
} on FileSystemException catch (e) {
63+
// Macos doesn"t support non-UTF-8 paths.
64+
tmp.deleteSync(recursive: true);
65+
return;
7466
}
75-
expect(syncFile.existsSync(), isTrue);
67+
} else {
68+
syncFile.createSync();
69+
}
70+
Expect.isTrue(syncFile.existsSync());
7671

77-
for (final file in tmp.listSync()) {
78-
// FIXME(bkonyi): reenable when rawPath is exposed.
79-
/*
80-
if (Platform.isWindows) {
81-
// Windows replaces invalid characters with � when creating file system
82-
// entities.
83-
final raw = file.rawPath;
84-
expect(raw.sublist(raw.length - 3), [239, 191, 189]);
85-
} else {
86-
expect(file.rawPath.last, 182);
87-
}
88-
*/
89-
// FIXME(bkonyi): this isn't true on some versions of MacOS. Why?
90-
if (!Platform.isMacOS && !Platform.isIOS) {
91-
expect(file.path.endsWith('�'), isTrue);
92-
}
72+
for (final file in tmp.listSync()) {
73+
// FIXME(bkonyi): reenable when rawPath is exposed.
74+
/*
75+
if (Platform.isWindows) {
76+
// Windows replaces invalid characters with � when creating file system
77+
// entities.
78+
final raw = file.rawPath;
79+
Expect.listEquals(raw.sublist(raw.length - 3), [239, 191, 189]);
80+
} else {
81+
Expect.equals(file.rawPath.last, 182);
82+
}
83+
*/
84+
// FIXME(bkonyi): this isn"t true on some versions of MacOS. Why?
85+
if (!Platform.isMacOS && !Platform.isIOS) {
86+
Expect.isTrue(file.path.endsWith("�"));
9387
}
94-
syncFile.deleteSync();
95-
} finally {
96-
tmp.deleteSync(recursive: true);
9788
}
98-
});
89+
syncFile.deleteSync();
90+
} finally {
91+
tmp.deleteSync(recursive: true);
92+
}
93+
}
94+
95+
main() async {
96+
await testAsync();
97+
testSync();
9998
}

0 commit comments

Comments
 (0)