Skip to content

Commit 1aedb83

Browse files
committed
[Tests] fix symlink tests for windows
1 parent d930f86 commit 1aedb83

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/symlinks.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ test('async symlink from node_modules to other dir when preserveSymlinks = false
9999
});
100100

101101
test('packageFilter', function (t) {
102+
function relative(x) {
103+
return path.relative(__dirname, x);
104+
}
105+
102106
function testPackageFilter(preserveSymlinks) {
103107
return function (st) {
104108
st.plan(5);
@@ -118,13 +122,13 @@ test('packageFilter', function (t) {
118122
}
119123
});
120124
st.equal(
121-
actualPath.replace(__dirname + '/', ''),
122-
preserveSymlinks ? destMain : sourceMain,
125+
relative(actualPath),
126+
path.normalize(preserveSymlinks ? destMain : sourceMain),
123127
'sync: actual path is correct'
124128
);
125129
st.deepEqual(
126-
map(packageFilterPath, function (x) { return x.replace(__dirname + '/', ''); }),
127-
preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg],
130+
map(packageFilterPath, relative),
131+
map(preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg], path.normalize),
128132
'sync: packageFilter pkgfile arg is correct'
129133
);
130134

@@ -141,13 +145,13 @@ test('packageFilter', function (t) {
141145
function (err, actualPath) {
142146
st.error(err, 'no error');
143147
st.equal(
144-
actualPath.replace(__dirname + '/', ''),
145-
preserveSymlinks ? destMain : sourceMain,
148+
relative(actualPath),
149+
path.normalize(preserveSymlinks ? destMain : sourceMain),
146150
'async: actual path is correct'
147151
);
148152
st.deepEqual(
149-
map(asyncPackageFilterPath, function (x) { return x.replace(__dirname + '/', ''); }),
150-
preserveSymlinks ? [destPkg, destPkg, destPkg] : [sourcePkg, sourcePkg, sourcePkg],
153+
map(packageFilterPath, relative),
154+
map(preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg], path.normalize),
151155
'async: packageFilter pkgfile arg is correct'
152156
);
153157
}

0 commit comments

Comments
 (0)