Skip to content

Commit 5fe1859

Browse files
anthony-redFoxtmcw
authored andcommitted
text(windows): Fix tests on Windows platform
* Fixed find_git test for windows platform. * Fixed github test on windows platform. * Fixed bin tests which are executed process from node.js * On windows platform uses DOUBLE EXCLAMATION MARK instead of WARNING SIGN.
1 parent 72e04b8 commit 5fe1859

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

test/bin-readme.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function documentation(args, options, callback, parseJSON) {
1818

1919
options.maxBuffer = 1024 * 1024;
2020

21-
args.unshift(path.join(__dirname, '../bin/documentation.js'));
21+
args.unshift('node ' + path.join(__dirname, '..', 'bin', 'documentation.js'));
2222

2323
exec(args.join(' '), options, callback);
2424
}

test/bin-watch-serve.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ function documentation(args, options, callback, parseJSON) {
1818
}
1919

2020
options.maxBuffer = 1024 * 1024;
21+
args.unshift(path.join(__dirname, '..', 'bin', 'documentation.js'));
2122

2223
return spawn(
23-
path.join(__dirname, '../bin/documentation.js'),
24+
'node',
2425
args,
2526
options);
2627
}

test/bin.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function documentation(args, options, callback, parseJSON) {
2020

2121
options.maxBuffer = 1024 * 1024;
2222

23-
args.unshift(path.join(__dirname, '../bin/documentation.js'));
23+
args.unshift('node '+ path.join(__dirname, '..', 'bin', 'documentation.js'));
2424

2525
exec(args.join(' '), options, function (err, stdout, stderr) {
2626
if (err) {
@@ -240,12 +240,15 @@ test('lint command', function (group) {
240240

241241
group.test('generates lint output', options, function (t) {
242242
documentation(['lint fixture/lint/lint.input.js'], function (err, data) {
243-
var output = path.join(__dirname, 'fixture/lint/lint.output.js');
243+
var output = path.join(__dirname, 'fixture', 'lint', 'lint.output.js');
244244
data = data.toString().split('\n').slice(2).join('\n');
245245
if (process.env.UPDATE) {
246246
fs.writeFileSync(output, data);
247247
}
248248
t.equal(err.code, 1);
249+
if (os.type() === 'Windows_NT') {
250+
data = data.replace('‼', '⚠');
251+
}
249252
t.equal(data, fs.readFileSync(output, 'utf8'), 'outputs lint');
250253
t.end();
251254
});

test/lib/git/find_git.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
var test = require('tap').test,
44
mock = require('mock-fs'),
55
mockRepo = require('./mock_repo'),
6+
path = require('path'),
67
findGit = require('../../../lib/git/find_git');
78

89
test('findGit', function (t) {
910

1011
mock(mockRepo.master);
1112

13+
const root = path.parse(__dirname).root;
14+
1215
t.equal(
1316
findGit(
14-
'/my/repository/path/index.js'),
15-
'/my/repository/path/.git', 'finds git path');
17+
root + path.join('my', 'repository', 'path', 'index.js')),
18+
root + path.join('my', 'repository', 'path', '.git'), 'finds git path');
1619

1720
mock.restore();
1821

test/lib/github.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
var test = require('tap').test,
66
mock = require('mock-fs'),
7+
path = require('path'),
78
mockRepo = require('./git/mock_repo'),
89
parse = require('../../lib/parsers/javascript'),
910
github = require('../../lib/github');
@@ -15,8 +16,10 @@ function toComment(fn, filename) {
1516
}, {}).map(github);
1617
}
1718

19+
const root = path.parse(__dirname).root;
20+
1821
function evaluate(fn) {
19-
return toComment(fn, '/my/repository/path/index.js');
22+
return toComment(fn, root + path.join('my', 'repository', 'path', 'index.js'));
2023
}
2124

2225
test('github', function (t) {

0 commit comments

Comments
 (0)