Skip to content

Commit f6f2a46

Browse files
committed
[Tests] fix symlink tests for windows
1 parent a01ddfb commit f6f2a46

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
@@ -101,6 +101,10 @@ test('async symlink from node_modules to other dir when preserveSymlinks = false
101101
});
102102

103103
test('packageFilter', function (t) {
104+
function relative(x) {
105+
return path.relative(__dirname, x);
106+
}
107+
104108
function testPackageFilter(preserveSymlinks) {
105109
return function (st) {
106110
st.plan(5);
@@ -120,13 +124,13 @@ test('packageFilter', function (t) {
120124
}
121125
});
122126
st.equal(
123-
actualPath.replace(__dirname + '/', ''),
124-
preserveSymlinks ? destMain : sourceMain,
127+
relative(actualPath),
128+
path.normalize(preserveSymlinks ? destMain : sourceMain),
125129
'sync: actual path is correct'
126130
);
127131
st.deepEqual(
128-
map(packageFilterPath, function (x) { return x.replace(__dirname + '/', ''); }),
129-
preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg],
132+
map(packageFilterPath, relative),
133+
map(preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg], path.normalize),
130134
'sync: packageFilter pkgfile arg is correct'
131135
);
132136

@@ -143,13 +147,13 @@ test('packageFilter', function (t) {
143147
function (err, actualPath) {
144148
st.error(err, 'no error');
145149
st.equal(
146-
actualPath.replace(__dirname + '/', ''),
147-
preserveSymlinks ? destMain : sourceMain,
150+
relative(actualPath),
151+
path.normalize(preserveSymlinks ? destMain : sourceMain),
148152
'async: actual path is correct'
149153
);
150154
st.deepEqual(
151-
map(asyncPackageFilterPath, function (x) { return x.replace(__dirname + '/', ''); }),
152-
preserveSymlinks ? [destPkg, destPkg, destPkg] : [sourcePkg, sourcePkg, sourcePkg],
155+
map(packageFilterPath, relative),
156+
map(preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg], path.normalize),
153157
'async: packageFilter pkgfile arg is correct'
154158
);
155159
}

0 commit comments

Comments
 (0)