Skip to content

Commit

Permalink
Support symlinked test files - fixes #1143 (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
rnkdev authored and sindresorhus committed Dec 17, 2016
1 parent 415cd2f commit 033d4dc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var EventEmitter = require('events').EventEmitter;
var path = require('path');
var util = require('util');
var fs = require('fs');
var commonPathPrefix = require('common-path-prefix');
var uniqueTempDir = require('unique-temp-dir');
var findCacheDir = require('find-cache-dir');
Expand Down Expand Up @@ -67,7 +68,8 @@ module.exports = Api;
Api.prototype._runFile = function (file, runStatus, execArgv) {
var hash = this.precompiler.precompileFile(file);
var precompiled = {};
precompiled[file] = hash;
var resolvedfpath = fs.realpathSync(file);
precompiled[resolvedfpath] = hash;

var options = objectAssign({}, this.options, {
precompiled: precompiled
Expand Down
22 changes: 22 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,28 @@ function generateTests(prefix, apiCreator) {
});
});

test(prefix + 'symlink to directory containing test files', function (t) {
t.plan(1);

var api = apiCreator();

return api.run([path.join(__dirname, 'fixture/symlink')])
.then(function (result) {
t.is(result.passCount, 1);
});
});

test(prefix + 'symlink to test file directly', function (t) {
t.plan(1);

var api = apiCreator();

return api.run([path.join(__dirname, 'fixture/symlinkfile.js')])
.then(function (result) {
t.is(result.passCount, 1);
});
});

test(prefix + 'search directories recursively for files', function (t) {
t.plan(2);

Expand Down
1 change: 1 addition & 0 deletions test/fixture/symlink
5 changes: 5 additions & 0 deletions test/fixture/symlinkdir/symlink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import test from '../../../';

test(t => {
t.pass();
});
1 change: 1 addition & 0 deletions test/fixture/symlinkfile.js
5 changes: 5 additions & 0 deletions test/fixture/target-symlink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import test from '../../';

test(t => {
t.pass();
});

0 comments on commit 033d4dc

Please sign in to comment.