Skip to content

Commit 3f79e04

Browse files
committed
Skip tests on Windows
1 parent ec54e67 commit 3f79e04

3 files changed

Lines changed: 87 additions & 79 deletions

File tree

test/cp.js

Lines changed: 69 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -231,36 +231,38 @@ assert.equal(shell.error(), null); // crash test only
231231
assert.ok(!result.stderr);
232232
assert.equal(result.code, 0);
233233

234-
// Recursive, everything exists, overwrite a real file with a link (if same name)
235-
// Because -R implies to not follow links!
236-
shell.rm('-rf', 'tmp/*');
237-
shell.cp('-R', 'resources/cp/*', 'tmp');
238-
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
239-
assert.ok(!(fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink())); // this one isn't
240-
assert.notEqual(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
241-
result = shell.cp('-R', 'tmp/links/*', 'tmp/fakeLinks');
242-
assert.equal(shell.error(), null);
243-
assert.ok(!result.stderr);
244-
assert.equal(result.code, 0);
245-
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
246-
assert.ok(fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink()); // this one is now a link
247-
assert.equal(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
248-
249-
// Recursive, everything exists, overwrite a real file *by following a link*
250-
// Because missing the -R implies -L.
251-
shell.rm('-rf', 'tmp/*');
252-
shell.cp('-R', 'resources/cp/*', 'tmp');
253-
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
254-
assert.ok(!(fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink())); // this one isn't
255-
assert.notEqual(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
256-
result = shell.cp('tmp/links/*', 'tmp/fakeLinks'); // don't use -R
257-
assert.equal(shell.error(), null);
258-
assert.ok(!result.stderr);
259-
assert.equal(result.code, 0);
260-
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
261-
assert.ok(!fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink()); // this one is still not a link
262-
// But it still follows the link
263-
assert.equal(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
234+
if (process.platform !== 'win32') {
235+
// Recursive, everything exists, overwrite a real file with a link (if same name)
236+
// Because -R implies to not follow links!
237+
shell.rm('-rf', 'tmp/*');
238+
shell.cp('-R', 'resources/cp/*', 'tmp');
239+
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
240+
assert.ok(!(fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink())); // this one isn't
241+
assert.notEqual(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
242+
result = shell.cp('-R', 'tmp/links/*', 'tmp/fakeLinks');
243+
assert.equal(shell.error(), null);
244+
assert.ok(!result.stderr);
245+
assert.equal(result.code, 0);
246+
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
247+
assert.ok(fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink()); // this one is now a link
248+
assert.equal(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
249+
250+
// Recursive, everything exists, overwrite a real file *by following a link*
251+
// Because missing the -R implies -L.
252+
shell.rm('-rf', 'tmp/*');
253+
shell.cp('-R', 'resources/cp/*', 'tmp');
254+
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
255+
assert.ok(!(fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink())); // this one isn't
256+
assert.notEqual(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
257+
result = shell.cp('tmp/links/*', 'tmp/fakeLinks'); // don't use -R
258+
assert.equal(shell.error(), null);
259+
assert.ok(!result.stderr);
260+
assert.equal(result.code, 0);
261+
assert.ok(fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink()); // this one is a link
262+
assert.ok(!fs.lstatSync('tmp/fakeLinks/sym.lnk').isSymbolicLink()); // this one is still not a link
263+
// But it still follows the link
264+
assert.equal(shell.cat('tmp/links/sym.lnk').toString(), shell.cat('tmp/fakeLinks/sym.lnk').toString());
265+
}
264266

265267
//recursive, everything exists, with force flag
266268
shell.rm('-rf', 'tmp/*');
@@ -306,12 +308,12 @@ assert.equal(fs.existsSync('tmp/dest/z'), true);
306308

307309
// On Windows, permission bits are quite different so skip those tests for now
308310
if (common.platform !== 'win') {
309-
//preserve mode bits
310-
shell.rm('-rf', 'tmp/*');
311-
var execBit = parseInt('001', 8);
312-
assert.equal(fs.statSync('resources/cp-mode-bits/executable').mode & execBit, execBit);
313-
shell.cp('resources/cp-mode-bits/executable', 'tmp/executable');
314-
assert.equal(fs.statSync('resources/cp-mode-bits/executable').mode, fs.statSync('tmp/executable').mode);
311+
//preserve mode bits
312+
shell.rm('-rf', 'tmp/*');
313+
var execBit = parseInt('001', 8);
314+
assert.equal(fs.statSync('resources/cp-mode-bits/executable').mode & execBit, execBit);
315+
shell.cp('resources/cp-mode-bits/executable', 'tmp/executable');
316+
assert.equal(fs.statSync('resources/cp-mode-bits/executable').mode, fs.statSync('tmp/executable').mode);
315317
}
316318

317319
// Make sure hidden files are copied recursively
@@ -335,7 +337,7 @@ assert.ok(fs.existsSync('tmp/file1.txt'));
335337
shell.rm('-rf', 'tmp/');
336338
shell.mkdir('tmp/');
337339
result = shell.cp('resources/file1.txt', 'resources/file2.txt', 'resources/cp',
338-
'resources/ls/', 'tmp/');
340+
'resources/ls/', 'tmp/');
339341
assert.ok(shell.error());
340342
assert.ok(!fs.existsSync('tmp/.hidden_file')); // doesn't copy dir contents
341343
assert.ok(!fs.existsSync('tmp/ls')); // doesn't copy dir itself
@@ -344,6 +346,36 @@ assert.ok(!fs.existsSync('tmp/cp')); // doesn't copy dir itself
344346
assert.ok(fs.existsSync('tmp/file1.txt'));
345347
assert.ok(fs.existsSync('tmp/file2.txt'));
346348

349+
if (process.platform !== 'win32') {
350+
// -R implies -P
351+
shell.rm('-rf', 'tmp/*');
352+
shell.cp('-R', 'resources/cp/links/sym.lnk', 'tmp');
353+
assert.ok(fs.lstatSync('tmp/sym.lnk').isSymbolicLink());
354+
355+
// using -P explicitly works
356+
shell.rm('-rf', 'tmp/*');
357+
shell.cp('-P', 'resources/cp/links/sym.lnk', 'tmp');
358+
assert.ok(fs.lstatSync('tmp/sym.lnk').isSymbolicLink());
359+
360+
// using -PR on a link to a folder does not follow the link
361+
shell.rm('-rf', 'tmp/*');
362+
shell.cp('-PR', 'resources/cp/symFolder', 'tmp');
363+
assert.ok(fs.lstatSync('tmp/symFolder').isSymbolicLink());
364+
365+
// Recursive, copies entire directory with no symlinks and -L option does not cause change in behavior.
366+
shell.rm('-rf', 'tmp/*');
367+
result = shell.cp('-rL', 'resources/cp/dir_a', 'tmp/dest');
368+
assert.equal(shell.error(), null);
369+
assert.ok(!result.stderr);
370+
assert.equal(result.code, 0);
371+
assert.equal(fs.existsSync('tmp/dest/z'), true);
372+
}
373+
374+
// using -R on a link to a folder *does* follow the link
375+
shell.rm('-rf', 'tmp/*');
376+
shell.cp('-R', 'resources/cp/symFolder', 'tmp');
377+
assert.ok(!fs.lstatSync('tmp/symFolder').isSymbolicLink());
378+
347379
// Without -R, -L is implied
348380
shell.rm('-rf', 'tmp/*');
349381
shell.cp('resources/cp/links/sym.lnk', 'tmp');
@@ -359,39 +391,11 @@ shell.rm('-rf', 'tmp/*');
359391
shell.cp('-LR', 'resources/cp/links/sym.lnk', 'tmp');
360392
assert.ok(!fs.lstatSync('tmp/sym.lnk').isSymbolicLink());
361393

362-
// -R implies -P
363-
shell.rm('-rf', 'tmp/*');
364-
shell.cp('-R', 'resources/cp/links/sym.lnk', 'tmp');
365-
assert.ok(fs.lstatSync('tmp/sym.lnk').isSymbolicLink());
366-
367-
// using -P explicitly works
368-
shell.rm('-rf', 'tmp/*');
369-
shell.cp('-P', 'resources/cp/links/sym.lnk', 'tmp');
370-
assert.ok(fs.lstatSync('tmp/sym.lnk').isSymbolicLink());
371-
372394
// using -LR also works recursively on directories containing links
373395
shell.rm('-rf', 'tmp/*');
374396
shell.cp('-LR', 'resources/cp/links', 'tmp');
375397
assert.ok(!fs.lstatSync('tmp/links/sym.lnk').isSymbolicLink());
376398

377-
// using -PR on a link to a folder does not follow the link
378-
shell.rm('-rf', 'tmp/*');
379-
shell.cp('-PR', 'resources/cp/symFolder', 'tmp');
380-
assert.ok(fs.lstatSync('tmp/symFolder').isSymbolicLink());
381-
382-
// using -R on a link to a folder *does* follow the link
383-
shell.rm('-rf', 'tmp/*');
384-
shell.cp('-R', 'resources/cp/symFolder', 'tmp');
385-
assert.ok(!fs.lstatSync('tmp/symFolder').isSymbolicLink());
386-
387-
// Recursive, copies entire directory with no symlinks and -L option does not cause change in behavior.
388-
shell.rm('-rf', 'tmp/*');
389-
result = shell.cp('-rL', 'resources/cp/dir_a', 'tmp/dest');
390-
assert.equal(shell.error(), null);
391-
assert.ok(!result.stderr);
392-
assert.equal(result.code, 0);
393-
assert.equal(fs.existsSync('tmp/dest/z'), true);
394-
395399
// Test max depth.
396400
shell.rm('-rf', 'tmp/');
397401
shell.mkdir('tmp/');

test/rm.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,16 @@ assert.equal(fs.existsSync('tmp/rm/link_to_a_dir'), false);
226226
assert.equal(fs.existsSync('tmp/rm/a_dir'), true);
227227

228228
// remove broken symbolic link
229-
result = shell.rm('-rf', 'tmp');
230-
shell.mkdir('tmp');
231-
shell.cp('-R', 'resources/rm', 'tmp');
232-
assert.ok(shell.test('-L', 'tmp/rm/fake.lnk'));
233-
result = shell.rm('tmp/rm/fake.lnk');
234-
assert.equal(shell.error(), null);
235-
assert.equal(result.code, 0);
236-
assert.ok(!shell.test('-L', 'tmp/rm/fake.lnk'));
237-
assert.equal(fs.existsSync('tmp/rm/fake.lnk'), false);
229+
if (process.platform !== 'win32') {
230+
result = shell.rm('-rf', 'tmp');
231+
shell.mkdir('tmp');
232+
shell.cp('-R', 'resources/rm', 'tmp');
233+
assert.ok(shell.test('-L', 'tmp/rm/fake.lnk'));
234+
result = shell.rm('tmp/rm/fake.lnk');
235+
assert.equal(shell.error(), null);
236+
assert.equal(result.code, 0);
237+
assert.ok(!shell.test('-L', 'tmp/rm/fake.lnk'));
238+
assert.equal(fs.existsSync('tmp/rm/fake.lnk'), false);
239+
}
238240

239241
shell.exit(123);

test/touch.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ assert(fs.existsSync(testFile));
110110
assert(fs.existsSync(testFile2));
111111

112112
// touching broken link creates a new file
113-
result = shell.touch('resources/badlink');
114-
assert.equal(result.code, 0);
115-
assert.ok(!shell.error());
116-
assert.ok(fs.existsSync('resources/not_existed_file'));
117-
shell.rm('resources/not_existed_file');
113+
if (process.platform !== 'win32') {
114+
result = shell.touch('resources/badlink');
115+
assert.equal(result.code, 0);
116+
assert.ok(!shell.error());
117+
assert.ok(fs.existsSync('resources/not_existed_file'));
118+
shell.rm('resources/not_existed_file');
119+
}
118120

119121
function resetUtimes(f) {
120122
var d = new Date();

0 commit comments

Comments
 (0)