Skip to content

Commit

Permalink
text(windows): Fix tests on Windows platform
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
anthony-redFox authored and tmcw committed Mar 31, 2017
1 parent 72e04b8 commit 5fe1859
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/bin-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function documentation(args, options, callback, parseJSON) {

options.maxBuffer = 1024 * 1024;

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

exec(args.join(' '), options, callback);
}
Expand Down
3 changes: 2 additions & 1 deletion test/bin-watch-serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ function documentation(args, options, callback, parseJSON) {
}

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

return spawn(
path.join(__dirname, '../bin/documentation.js'),
'node',
args,
options);
}
Expand Down
7 changes: 5 additions & 2 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function documentation(args, options, callback, parseJSON) {

options.maxBuffer = 1024 * 1024;

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

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

group.test('generates lint output', options, function (t) {
documentation(['lint fixture/lint/lint.input.js'], function (err, data) {
var output = path.join(__dirname, 'fixture/lint/lint.output.js');
var output = path.join(__dirname, 'fixture', 'lint', 'lint.output.js');
data = data.toString().split('\n').slice(2).join('\n');
if (process.env.UPDATE) {
fs.writeFileSync(output, data);
}
t.equal(err.code, 1);
if (os.type() === 'Windows_NT') {
data = data.replace('‼', '⚠');
}
t.equal(data, fs.readFileSync(output, 'utf8'), 'outputs lint');
t.end();
});
Expand Down
7 changes: 5 additions & 2 deletions test/lib/git/find_git.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
var test = require('tap').test,
mock = require('mock-fs'),
mockRepo = require('./mock_repo'),
path = require('path'),
findGit = require('../../../lib/git/find_git');

test('findGit', function (t) {

mock(mockRepo.master);

const root = path.parse(__dirname).root;

t.equal(
findGit(
'/my/repository/path/index.js'),
'/my/repository/path/.git', 'finds git path');
root + path.join('my', 'repository', 'path', 'index.js')),
root + path.join('my', 'repository', 'path', '.git'), 'finds git path');

mock.restore();

Expand Down
5 changes: 4 additions & 1 deletion test/lib/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

var test = require('tap').test,
mock = require('mock-fs'),
path = require('path'),
mockRepo = require('./git/mock_repo'),
parse = require('../../lib/parsers/javascript'),
github = require('../../lib/github');
Expand All @@ -15,8 +16,10 @@ function toComment(fn, filename) {
}, {}).map(github);
}

const root = path.parse(__dirname).root;

function evaluate(fn) {
return toComment(fn, '/my/repository/path/index.js');
return toComment(fn, root + path.join('my', 'repository', 'path', 'index.js'));
}

test('github', function (t) {
Expand Down

0 comments on commit 5fe1859

Please sign in to comment.