2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- @TestOn ('posix ' )
5
+ @TestOn ('vm ' )
6
6
library ;
7
7
8
8
import 'dart:io' ;
9
9
10
10
import 'package:io_file/io_file.dart' ;
11
11
import 'package:stdlibc/stdlibc.dart' as stdlibc;
12
12
import 'package:test/test.dart' ;
13
+ import 'package:win32/win32.dart' as win32;
13
14
14
15
import 'test_utils.dart' ;
15
16
@@ -39,9 +40,14 @@ void main() {
39
40
() => fileSystem.same (path1, path2),
40
41
throwsA (
41
42
isA <PathNotFoundException >()
42
- .having ((e) => e.message, 'message' , 'stat failed' )
43
43
.having ((e) => e.path, 'path' , path1)
44
- .having ((e) => e.osError? .errorCode, 'errorCode' , stdlibc.ENOENT ),
44
+ .having (
45
+ (e) => e.osError? .errorCode,
46
+ 'errorCode' ,
47
+ Platform .isWindows
48
+ ? win32.ERROR_FILE_NOT_FOUND
49
+ : stdlibc.ENOENT ,
50
+ ),
45
51
),
46
52
);
47
53
});
@@ -55,9 +61,14 @@ void main() {
55
61
() => fileSystem.same (path1, path2),
56
62
throwsA (
57
63
isA <PathNotFoundException >()
58
- .having ((e) => e.message, 'message' , 'stat failed' )
59
64
.having ((e) => e.path, 'path' , path2)
60
- .having ((e) => e.osError? .errorCode, 'errorCode' , stdlibc.ENOENT ),
65
+ .having (
66
+ (e) => e.osError? .errorCode,
67
+ 'errorCode' ,
68
+ Platform .isWindows
69
+ ? win32.ERROR_FILE_NOT_FOUND
70
+ : stdlibc.ENOENT ,
71
+ ),
61
72
),
62
73
);
63
74
});
@@ -70,9 +81,14 @@ void main() {
70
81
() => fileSystem.same (path1, path2),
71
82
throwsA (
72
83
isA <PathNotFoundException >()
73
- .having ((e) => e.message, 'message' , 'stat failed' )
74
84
.having ((e) => e.path, 'path' , path1)
75
- .having ((e) => e.osError? .errorCode, 'errorCode' , stdlibc.ENOENT ),
85
+ .having (
86
+ (e) => e.osError? .errorCode,
87
+ 'errorCode' ,
88
+ Platform .isWindows
89
+ ? win32.ERROR_FILE_NOT_FOUND
90
+ : stdlibc.ENOENT ,
91
+ ),
76
92
),
77
93
);
78
94
});
@@ -87,9 +103,14 @@ void main() {
87
103
() => fileSystem.same (path1, path2),
88
104
throwsA (
89
105
isA <PathNotFoundException >()
90
- .having ((e) => e.message, 'message' , 'stat failed' )
91
106
.having ((e) => e.path, 'path' , path1)
92
- .having ((e) => e.osError? .errorCode, 'errorCode' , stdlibc.ENOENT ),
107
+ .having (
108
+ (e) => e.osError? .errorCode,
109
+ 'errorCode' ,
110
+ Platform .isWindows
111
+ ? win32.ERROR_FILE_NOT_FOUND
112
+ : stdlibc.ENOENT ,
113
+ ),
93
114
),
94
115
);
95
116
});
@@ -104,9 +125,14 @@ void main() {
104
125
() => fileSystem.same (path1, path2),
105
126
throwsA (
106
127
isA <PathNotFoundException >()
107
- .having ((e) => e.message, 'message' , 'stat failed' )
108
128
.having ((e) => e.path, 'path' , path2)
109
- .having ((e) => e.osError? .errorCode, 'errorCode' , stdlibc.ENOENT ),
129
+ .having (
130
+ (e) => e.osError? .errorCode,
131
+ 'errorCode' ,
132
+ Platform .isWindows
133
+ ? win32.ERROR_FILE_NOT_FOUND
134
+ : stdlibc.ENOENT ,
135
+ ),
110
136
),
111
137
);
112
138
});
@@ -120,9 +146,14 @@ void main() {
120
146
() => fileSystem.same (path1, path2),
121
147
throwsA (
122
148
isA <PathNotFoundException >()
123
- .having ((e) => e.message, 'message' , 'stat failed' )
124
149
.having ((e) => e.path, 'path' , path1)
125
- .having ((e) => e.osError? .errorCode, 'errorCode' , stdlibc.ENOENT ),
150
+ .having (
151
+ (e) => e.osError? .errorCode,
152
+ 'errorCode' ,
153
+ Platform .isWindows
154
+ ? win32.ERROR_FILE_NOT_FOUND
155
+ : stdlibc.ENOENT ,
156
+ ),
126
157
),
127
158
);
128
159
});
@@ -174,13 +205,17 @@ void main() {
174
205
expect (fileSystem.same (path1, path2), isTrue);
175
206
});
176
207
177
- test ('hard links to same file' , () {
178
- final path1 = '$tmp /file1' ;
179
- final path2 = '$tmp /file2' ;
180
- File (path1).writeAsStringSync ('Hello World' );
181
- stdlibc.link (path1, path2);
182
- expect (fileSystem.same (path1, path2), isTrue);
183
- });
208
+ test (
209
+ 'hard links to same file' ,
210
+ () {
211
+ final path1 = '$tmp /file1' ;
212
+ final path2 = '$tmp /file2' ;
213
+ File (path1).writeAsStringSync ('Hello World' );
214
+ stdlibc.link (path1, path2);
215
+ expect (fileSystem.same (path1, path2), isTrue);
216
+ },
217
+ skip: Platform .isWindows ? 'hard links not supported' : false ,
218
+ );
184
219
185
220
test ('different directories, same content' , () {
186
221
final path1 = '$tmp /dir1' ;
0 commit comments