Skip to content

Commit ff9af3d

Browse files
rmgisaacs
authored andcommittedMay 12, 2015
run: perform globbing on path arguments
close #127
1 parent a970809 commit ff9af3d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 

‎bin/run.js

+9
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ else
272272
if (bail)
273273
process.env.TAP_BAIL = '1'
274274

275+
var glob = require('glob')
276+
files = files.reduce(function(acc, f) {
277+
// glob claims patterns MUST not include any '\'s
278+
if (!/\\/.test(f)) {
279+
f = glob.sync(f) || f
280+
}
281+
return acc.concat(f)
282+
}, [])
283+
275284
if (files.length === 0) {
276285
console.error('Reading TAP data from stdin (use "-" argument to suppress)')
277286
files.push('-')

‎test/runner.js

+15
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ t.test('bailout args', function (t) {
101101
t.end()
102102
})
103103

104+
t.test('path globbing', function (t) {
105+
var glob = 'fixtures/*-success.js'
106+
var opt = { env: { TAP: 1 }, cwd: __dirname }
107+
var child = spawn(node, [run, glob], opt)
108+
var out = ''
109+
child.stdout.on('data', function (c) {
110+
out += c
111+
})
112+
child.on('close', function (code) {
113+
t.equal(code, 0, 'exits successfully')
114+
t.match(out, /trivial-success.js/g, 'includes a matched file')
115+
t.end()
116+
})
117+
})
118+
104119
t.test('save-file', function (t) {
105120
var saveFile = 'runner-save-test'
106121
function saveFileTest(cb) {

0 commit comments

Comments
 (0)
Please sign in to comment.