4
4
5
5
import 'package:file/file.dart' ;
6
6
import 'package:file/memory.dart' ;
7
- import 'package:path/path.dart' as p;
8
7
import 'package:platform/platform.dart' ;
9
8
import 'package:process/src/interface/common.dart' ;
10
9
import 'package:test/test.dart' ;
@@ -14,13 +13,15 @@ void main() {
14
13
FileSystem fs;
15
14
Directory workingDir, dir1, dir2, dir3;
16
15
17
- setUp (() {
18
- fs = new MemoryFileSystem ();
19
- workingDir = fs.systemTempDirectory.createTempSync ('work_dir_' );
20
- dir1 = fs.systemTempDirectory.createTempSync ('dir1_' );
21
- dir2 = fs.systemTempDirectory.createTempSync ('dir2_' );
22
- dir3 = fs.systemTempDirectory.createTempSync ('dir3_' );
23
- });
16
+ void initialize (FileSystemStyle style) {
17
+ setUp (() {
18
+ fs = new MemoryFileSystem (style: style);
19
+ workingDir = fs.systemTempDirectory.createTempSync ('work_dir_' );
20
+ dir1 = fs.systemTempDirectory.createTempSync ('dir1_' );
21
+ dir2 = fs.systemTempDirectory.createTempSync ('dir2_' );
22
+ dir3 = fs.systemTempDirectory.createTempSync ('dir3_' );
23
+ });
24
+ }
24
25
25
26
tearDown (() {
26
27
< Directory > [workingDir, dir1, dir2, dir3]
@@ -30,6 +31,8 @@ void main() {
30
31
group ('on windows' , () {
31
32
Platform platform;
32
33
34
+ initialize (FileSystemStyle .windows);
35
+
33
36
setUp (() {
34
37
platform = new FakePlatform (
35
38
operatingSystem: 'windows' ,
@@ -41,7 +44,7 @@ void main() {
41
44
});
42
45
43
46
test ('absolute' , () {
44
- String command = p .join (dir3.path, 'bla.exe' );
47
+ String command = fs.path .join (dir3.path, 'bla.exe' );
45
48
String expectedPath = command;
46
49
fs.file (command).createSync ();
47
50
@@ -53,7 +56,7 @@ void main() {
53
56
);
54
57
_expectSamePath (executablePath, expectedPath);
55
58
56
- command = p .withoutExtension (command);
59
+ command = fs.path .withoutExtension (command);
57
60
executablePath = getExecutablePath (
58
61
command,
59
62
workingDir.path,
@@ -65,7 +68,7 @@ void main() {
65
68
66
69
test ('in path' , () {
67
70
String command = 'bla.exe' ;
68
- String expectedPath = p .join (dir2.path, command);
71
+ String expectedPath = fs.path .join (dir2.path, command);
69
72
fs.file (expectedPath).createSync ();
70
73
71
74
String executablePath = getExecutablePath (
@@ -76,7 +79,7 @@ void main() {
76
79
);
77
80
_expectSamePath (executablePath, expectedPath);
78
81
79
- command = p .withoutExtension (command);
82
+ command = fs.path .withoutExtension (command);
80
83
executablePath = getExecutablePath (
81
84
command,
82
85
workingDir.path,
@@ -88,8 +91,8 @@ void main() {
88
91
89
92
test ('in path multiple times' , () {
90
93
String command = 'bla.exe' ;
91
- String expectedPath = p .join (dir1.path, command);
92
- String wrongPath = p .join (dir2.path, command);
94
+ String expectedPath = fs.path .join (dir1.path, command);
95
+ String wrongPath = fs.path .join (dir2.path, command);
93
96
fs.file (expectedPath).createSync ();
94
97
fs.file (wrongPath).createSync ();
95
98
@@ -101,7 +104,7 @@ void main() {
101
104
);
102
105
_expectSamePath (executablePath, expectedPath);
103
106
104
- command = p .withoutExtension (command);
107
+ command = fs.path .withoutExtension (command);
105
108
executablePath = getExecutablePath (
106
109
command,
107
110
workingDir.path,
@@ -112,8 +115,8 @@ void main() {
112
115
});
113
116
114
117
test ('in subdir of work dir' , () {
115
- String command = p .join ('.' , 'foo' , 'bla.exe' );
116
- String expectedPath = p .join (workingDir.path, command);
118
+ String command = fs.path .join ('.' , 'foo' , 'bla.exe' );
119
+ String expectedPath = fs.path .join (workingDir.path, command);
117
120
fs.file (expectedPath).createSync (recursive: true );
118
121
119
122
String executablePath = getExecutablePath (
@@ -124,7 +127,7 @@ void main() {
124
127
);
125
128
_expectSamePath (executablePath, expectedPath);
126
129
127
- command = p .withoutExtension (command);
130
+ command = fs.path .withoutExtension (command);
128
131
executablePath = getExecutablePath (
129
132
command,
130
133
workingDir.path,
@@ -135,9 +138,9 @@ void main() {
135
138
});
136
139
137
140
test ('in work dir' , () {
138
- String command = p .join ('.' , 'bla.exe' );
139
- String expectedPath = p .join (workingDir.path, command);
140
- String wrongPath = p .join (dir2.path, command);
141
+ String command = fs.path .join ('.' , 'bla.exe' );
142
+ String expectedPath = fs.path .join (workingDir.path, command);
143
+ String wrongPath = fs.path .join (dir2.path, command);
141
144
fs.file (expectedPath).createSync ();
142
145
fs.file (wrongPath).createSync ();
143
146
@@ -149,7 +152,7 @@ void main() {
149
152
);
150
153
_expectSamePath (executablePath, expectedPath);
151
154
152
- command = p .withoutExtension (command);
155
+ command = fs.path .withoutExtension (command);
153
156
executablePath = getExecutablePath (
154
157
command,
155
158
workingDir.path,
@@ -161,9 +164,9 @@ void main() {
161
164
162
165
test ('with multiple extensions' , () {
163
166
String command = 'foo' ;
164
- String expectedPath = p .join (dir1.path, '$command .exe' );
165
- String wrongPath1 = p .join (dir1.path, '$command .bat' );
166
- String wrongPath2 = p .join (dir2.path, '$command .exe' );
167
+ String expectedPath = fs.path .join (dir1.path, '$command .exe' );
168
+ String wrongPath1 = fs.path .join (dir1.path, '$command .bat' );
169
+ String wrongPath2 = fs.path .join (dir2.path, '$command .exe' );
167
170
fs.file (expectedPath).createSync ();
168
171
fs.file (wrongPath1).createSync ();
169
172
fs.file (wrongPath2).createSync ();
@@ -188,21 +191,23 @@ void main() {
188
191
);
189
192
expect (executablePath, isNull);
190
193
});
191
- }, skip : 'https://github.com/google/file.dart/issues/68' );
194
+ });
192
195
193
196
group ('on Linux' , () {
194
197
Platform platform;
195
198
199
+ initialize (FileSystemStyle .posix);
200
+
196
201
setUp (() {
197
202
platform = new FakePlatform (
198
203
operatingSystem: 'linux' ,
199
204
environment: < String , String > {'PATH' : '${dir1 .path }:${dir2 .path }' });
200
205
});
201
206
202
207
test ('absolute' , () {
203
- String command = p .join (dir3.path, 'bla' );
208
+ String command = fs.path .join (dir3.path, 'bla' );
204
209
String expectedPath = command;
205
- String wrongPath = p .join (dir3.path, 'bla.bat' );
210
+ String wrongPath = fs.path .join (dir3.path, 'bla.bat' );
206
211
fs.file (command).createSync ();
207
212
fs.file (wrongPath).createSync ();
208
213
@@ -217,8 +222,8 @@ void main() {
217
222
218
223
test ('in path multiple times' , () {
219
224
String command = 'xxx' ;
220
- String expectedPath = p .join (dir1.path, command);
221
- String wrongPath = p .join (dir2.path, command);
225
+ String expectedPath = fs.path .join (dir1.path, command);
226
+ String wrongPath = fs.path .join (dir2.path, command);
222
227
fs.file (expectedPath).createSync ();
223
228
fs.file (wrongPath).createSync ();
224
229
0 commit comments