-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathintegration.js
192 lines (154 loc) · 5.2 KB
/
integration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var miss = require('mississippi');
var expect = require('expect');
var vfs = require('../');
var cleanup = require('./utils/cleanup');
var isWindows = require('./utils/is-windows');
var testStreams = require('./utils/test-streams');
var testConstants = require('./utils/test-constants');
var pipe = miss.pipe;
var concat = miss.concat;
var count = testStreams.count;
var base = testConstants.outputBase;
var inputDirpath = testConstants.inputDirpath;
var outputDirpath = testConstants.outputDirpath;
var symlinkDirpath = testConstants.symlinkDirpath;
var inputBase = path.join(base, './in/');
var inputDirpath = testConstants.inputDirpath;
var outputDirpath = testConstants.outputDirpath;
var symlinkDirpath = testConstants.symlinkDirpath;
var inputGlob = path.join(inputBase, './*.txt');
var outputBase = path.join(base, './out/');
var outputSymlink = path.join(symlinkDirpath, './foo');
var outputDirpathSymlink = path.join(outputDirpath, './foo');
var content = testConstants.contents;
var clean = cleanup(base);
describe('integrations', function() {
beforeEach(clean);
afterEach(clean);
it('does not exhaust available file descriptors when streaming thousands of files', function(done) {
// This can be a very slow test on boxes with slow disk i/o
this.timeout(0);
// Make a ton of files. Changed from hard links due to Windows failures
var expectedCount = 6000;
fs.mkdirSync(base);
fs.mkdirSync(inputBase);
for (var idx = 0; idx < expectedCount; idx++) {
var filepath = path.join(inputBase, './test' + idx + '.txt');
fs.writeFileSync(filepath, content);
}
pipe([
vfs.src(inputGlob, { buffer: false }),
count(expectedCount),
vfs.dest(outputBase),
], done);
});
it('(*nix) sources a directory, creates a symlink and copies it', function(done) {
if (isWindows) {
this.skip();
return;
}
function assert(files) {
var symlinkResult = fs.readlinkSync(outputSymlink);
var destResult = fs.readlinkSync(outputDirpathSymlink);
expect(symlinkResult).toEqual(inputDirpath);
expect(destResult).toEqual(inputDirpath);
expect(files[0].isSymbolic()).toBe(true);
expect(files[0].symlink).toEqual(inputDirpath);
}
pipe([
vfs.src(inputDirpath),
vfs.symlink(symlinkDirpath),
vfs.dest(outputDirpath),
concat(assert),
], done);
});
it('(windows) sources a directory, creates a junction and copies it', function(done) {
if (!isWindows) {
this.skip();
return;
}
function assert(files) {
// Junctions add an ending separator
var expected = inputDirpath + path.sep;
var symlinkResult = fs.readlinkSync(outputSymlink);
var destResult = fs.readlinkSync(outputDirpathSymlink);
expect(symlinkResult).toEqual(expected);
expect(destResult).toEqual(expected);
expect(files[0].isSymbolic()).toBe(true);
expect(files[0].symlink).toEqual(inputDirpath);
}
pipe([
vfs.src(inputDirpath),
vfs.symlink(symlinkDirpath),
vfs.dest(outputDirpath),
concat(assert),
], done);
});
it('(*nix) sources a symlink and copies it', function(done) {
if (isWindows) {
this.skip();
return;
}
fs.mkdirSync(base);
fs.mkdirSync(symlinkDirpath);
fs.symlinkSync(inputDirpath, outputSymlink);
function assert(files) {
var destResult = fs.readlinkSync(outputDirpathSymlink);
expect(destResult).toEqual(inputDirpath);
expect(files[0].isSymbolic()).toEqual(true);
expect(files[0].symlink).toEqual(inputDirpath);
}
pipe([
vfs.src(outputSymlink, { resolveSymlinks: false }),
vfs.dest(outputDirpath),
concat(assert),
], done);
});
it('(windows) sources a directory symlink and copies it', function(done) {
if (!isWindows) {
this.skip();
return;
}
fs.mkdirSync(base);
fs.mkdirSync(symlinkDirpath);
fs.symlinkSync(inputDirpath, outputSymlink, 'dir');
function assert(files) {
// 'dir' symlinks add an ending separator
var expected = inputDirpath + path.sep;
var destResult = fs.readlinkSync(outputDirpathSymlink);
expect(destResult).toEqual(expected);
expect(files[0].isSymbolic()).toEqual(true);
expect(files[0].symlink).toEqual(inputDirpath);
}
pipe([
vfs.src(outputSymlink, { resolveSymlinks: false }),
vfs.dest(outputDirpath),
concat(assert),
], done);
});
it('(windows) sources a junction and copies it', function(done) {
if (!isWindows) {
this.skip();
return;
}
fs.mkdirSync(base);
fs.mkdirSync(symlinkDirpath);
fs.symlinkSync(inputDirpath, outputSymlink, 'junction');
function assert(files) {
// Junctions add an ending separator
var expected = inputDirpath + path.sep;
var destResult = fs.readlinkSync(outputDirpathSymlink);
expect(destResult).toEqual(expected);
expect(files[0].isSymbolic()).toEqual(true);
expect(files[0].symlink).toEqual(inputDirpath);
}
pipe([
vfs.src(outputSymlink, { resolveSymlinks: false }),
vfs.dest(outputDirpath),
concat(assert),
], done);
});
});