Skip to content

Commit afec43f

Browse files
MasterOdinagnivade
authored andcommitted
fix running tests under windows
The tests used a linux path separator for referencing things on the filesystem, except that then uses path.sep under the hood for path splitting, which is / on *unix and \\ on windows. Instead of hard-coding the separator, we can use path.join instead which will give us the right seperator. Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
1 parent e2a3526 commit afec43f

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest, macos-latest] # todo: windows-latest
15+
os: [ubuntu-latest, macos-latest, windows-latest]
1616
node-version: [10.x, 12.x, 13.x, 14.x]
1717

1818
steps:
@@ -21,7 +21,7 @@ jobs:
2121
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id }}
2222
with:
2323
access_token: ${{ github.token }}
24-
24+
2525
- uses: actions/checkout@v2
2626

2727
- name: Cache node modules

test/index.spec.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const fs = require('fs-extra');
4+
const path = require('path');
45
const index = require('../lib/index');
56
const utils = require('../lib/utils');
67
const sinon = require('sinon');
@@ -25,7 +26,9 @@ const pages = [
2526
'/pages/sunos/dd.md',
2627
'/pages/sunos/du.md',
2728
'/pages/sunos/svcs.md'
28-
];
29+
].map((x) => {
30+
return path.join(x);
31+
});
2932

3033
describe('Index building', () => {
3134
beforeEach(() => {
@@ -81,77 +84,77 @@ describe('Index', () => {
8184
it('should find Linux platform for apk command for Chinese', () => {
8285
return index.findPage('apk', 'linux', 'zh')
8386
.then((folder) => {
84-
return folder.should.equal('pages.zh/linux');
87+
return folder.should.equal(path.join('pages.zh', 'linux'));
8588
});
8689
});
8790

8891
it('should find Linux platform for apk command for Chinese given Windows', () => {
8992
return index.findPage('apk', 'windows', 'zh')
9093
.then((folder) => {
91-
return folder.should.equal('pages.zh/linux');
94+
return folder.should.equal(path.join('pages.zh', 'linux'));
9295
});
9396
});
9497

9598
it('should find Linux platform for dd command', () => {
9699
return index.findPage('dd', 'linux', 'en')
97100
.then((folder) => {
98-
return folder.should.equal('pages/linux');
101+
return folder.should.equal(path.join('pages', 'linux'));
99102
});
100103
});
101104

102105
it('should find platform common for cp command for English', () => {
103106
return index.findPage('cp', 'linux', 'en')
104107
.then((folder) => {
105-
return folder.should.equal('pages/common');
108+
return folder.should.equal(path.join('pages', 'common'));
106109
});
107110
});
108111

109112
it('should find platform common for cp command for Tamil', () => {
110113
return index.findPage('cp', 'linux', 'ta')
111114
.then((folder) => {
112-
return folder.should.equal('pages.ta/common');
115+
return folder.should.equal(path.join('pages.ta', 'common'));
113116
});
114117
});
115118

116119
it('should find platform common for cp command for Italian', () => {
117120
return index.findPage('cp', 'linux', 'it')
118121
.then((folder) => {
119-
return folder.should.equal('pages.it/common');
122+
return folder.should.equal(path.join('pages.it', 'common'));
120123
});
121124
});
122125

123126
it('should find platform common for cp command for Italian given Windows', () => {
124127
return index.findPage('cp', 'windows', 'it')
125128
.then((folder) => {
126-
return folder.should.equal('pages.it/common');
129+
return folder.should.equal(path.join('pages.it', 'common'));
127130
});
128131
});
129132

130133
it('should find platform common for ls command for Italian', () => {
131134
return index.findPage('ls', 'linux', 'it')
132135
.then((folder) => {
133-
return folder.should.equal('pages/common');
136+
return folder.should.equal(path.join('pages', 'common'));
134137
});
135138
});
136139

137140
it('should find platform common for cp command for Italian given common platform', () => {
138141
return index.findPage('cp', 'common', 'it')
139142
.then((folder) => {
140-
return folder.should.equal('pages.it/common');
143+
return folder.should.equal(path.join('pages.it', 'common'));
141144
});
142145
});
143146

144147
it('should find platform common for cp command for English given a bad language', () => {
145148
return index.findPage('cp', 'linux', 'notexist')
146149
.then((folder) => {
147-
return folder.should.equal('pages/common');
150+
return folder.should.equal(path.join('pages', 'common'));
148151
});
149152
});
150153

151154
it('should find platform for svcs command on Linux', () => {
152155
return index.findPage('svcs', 'linux', 'en')
153156
.then((folder) => {
154-
return folder.should.equal('pages/sunos');
157+
return folder.should.equal(path.join('pages', 'sunos'));
155158
});
156159
});
157160

0 commit comments

Comments
 (0)