Skip to content

Commit

Permalink
de-windows cwd paths in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Apr 16, 2023
1 parent aa41310 commit 454eded
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function deWindows(p) {
return p.replace(/\\/g, '/');
}

var cwd = deWindows(process.cwd());
var dir = deWindows(__dirname);

function suite(moduleName) {
Expand Down Expand Up @@ -357,18 +358,18 @@ function suite(moduleName) {
it('emits all objects (unordered) when given multiple absolute paths and no cwd', function (done) {
var expected = [
{
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures/whatsgoingon/hey/isaidhey/whatsgoingon',
path:
dir + '/fixtures/whatsgoingon/hey/isaidhey/whatsgoingon/test.txt',
},
{
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures',
path: dir + '/fixtures/test.coffee',
},
{
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures/whatsgoingon',
path: dir + '/fixtures/whatsgoingon/test.js',
},
Expand Down Expand Up @@ -527,7 +528,7 @@ function suite(moduleName) {

it('works with direct paths and no cwd', function (done) {
var expected = {
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures',
path: dir + '/fixtures/test.coffee',
};
Expand All @@ -545,21 +546,21 @@ function suite(moduleName) {

it('works with a relative cwd', function (done) {
var expected = {
cwd: process.cwd() + '/test',
cwd: cwd + '/test',
base: dir + '/fixtures',
path: dir + '/fixtures/test.coffee',
};

var cwd = path.relative(process.cwd(), __dirname);

function assert(pathObjs) {
expect(pathObjs.length).toEqual(1);
expect(pathObjs[0]).toEqual(expected);
}

stream.pipeline(
[
globStream(dir + '/fixtures/test.coffee', { cwd: cwd }),
globStream(dir + '/fixtures/test.coffee', {
cwd: path.relative(process.cwd(), __dirname),
}),
concat(assert),
],
done
Expand All @@ -568,7 +569,7 @@ function suite(moduleName) {

it('supports negative globs', function (done) {
var expected = {
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures/stuff',
path: dir + '/fixtures/stuff/run.dmc',
};
Expand All @@ -588,7 +589,7 @@ function suite(moduleName) {

it('supports negative file paths', function (done) {
var expected = {
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures/stuff',
path: dir + '/fixtures/stuff/run.dmc',
};
Expand Down Expand Up @@ -717,7 +718,7 @@ function suite(moduleName) {

it('resolves absolute paths when root option is given', function (done) {
var expected = {
cwd: process.cwd(),
cwd: cwd,
base: dir + '/fixtures',
path: dir + '/fixtures/test.coffee',
};
Expand Down

0 comments on commit 454eded

Please sign in to comment.