Permalink
Browse files

Merge from Upstream

  • Loading branch information...
2 parents 2d77a7a + d1d02e0 commit ae4a2145989483b6b968e226dc17065cd39bbc72 @adamstallard committed Aug 19, 2013
View
@@ -1,6 +1,6 @@
language: node_js
node_js:
- - 0.4
- - 0.6
-
+ - 0.8
+ - 0.9
+ - "0.10"
View
@@ -4,7 +4,7 @@
var path = require('path'),
fs = require('fs'),
util = require('util'),
- wildcard = require('../lib/utils/wildcard').wildcard,
+ glob = require('glob'),
NopStream = require('../lib/utils/nopstream').NopStream,
events = require('events');
@@ -270,12 +270,8 @@ if (! options.watch) {
// preprocess the list of files for any wildcards. win32 does not handle wildcards before calling vows
// any paths not containing wildcards are simple returned by wildcard()
files.forEach(function(a) {
- if(a.indexOf('*') !== -1) {
- wildcardFiles = wildcardFiles.concat(wildcard(a));
- } else {
- wildcardFiles.push(a);
- }
- });
+ wildcardFiles = wildcardFiles.concat(glob.sync(a));
+ });
// now set up the file list for vows including all the wildcard files
files = wildcardFiles.map(function (a) {
@@ -299,7 +295,7 @@ if (! options.watch) {
msg('runner', 'finish');
_reporter.report(['finish', results], {
write: function (str) {
- util.print(str.replace(/^\n\n/, '\n'));
+ process.stdout.write(str.replace(/^\n\n/, '\n'));
}
});
try {
@@ -368,7 +364,7 @@ if (! options.watch) {
//
// Utility functions
//
- function print(str) { util.print(str) }
+ function print(str) { process.stdout.write(str) }
function esc(str) { print("\x1b[" + str) }
function eraseLine() { esc("0K") }
function cursorRestore() { esc("0G") }
@@ -617,7 +613,8 @@ function paths(dir) {
function msg(cmd, subject, str, p) {
if (options.verbose) {
- util[p ? 'print' : 'puts']( stylize('vows ', 'green')
+ var func = p ? process.stdout.write.bind(process.stdout) : console.log;
+ func( stylize('vows ', 'green')
+ stylize(cmd, 'bold')
+ ' ' + subject + ' '
+ (str ? (typeof(str) === 'string' ? str : inspect(str)) : '')
View
@@ -1,114 +0,0 @@
-/**
- * (C) Microsoft Open Technologies, Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var PATH = require('path');
-var fs = require('fs');
-
-/**
- * @type {Function} wildcard(pattern)
- * wildcard searches for files matching pattern.
- *
- * @pattern {String} search pattern with optional * wildcards
- * @return an array containing the paths to the matching files
- */
-var wildcard = exports.wildcard = function(pattern) {
-
- // process pattern string for * wildcard
- var matchers = [],
- tokens,
- path;
-
- var index = pattern.indexOf('*');
- if(index === -1) {
- return [pattern];
- }
-
- path = pattern.substr(0, index-1);
- pattern = pattern.substr(index);
- pattern = pattern.replace(/\*/g, '(?=.*)');
- tokens = pattern.split(PATH.sep);
-
- // create matcher regex for each path component in pattern
- tokens.forEach(function(token, index, array) {
- var matcher = {};
- matcher.index = index;
- matcher.isDir = index < array.length -1;
- matcher.regex = new RegExp(token);
- matchers.push(matcher);
- });
-
- return process(path, matchers);
-};
-
-// searches starting from the path directory and returns files matching wildcard pattern
-// search only proceeds to directory depth equal to the numbe rof matchers.
-var process = function(path, matchers) {
-
- var files = [];
- var traverse = function(path, level) {
- var dirs,
- matcher;
-
- // check we have not exceeded search directory depth
- if(level >= matchers.length) {
- return;
- }
-
- // read the dirs and files from the current path
- dirs = fs.readdirSync(path);
- matcher = matchers[level];
-
- // check if each dir or file matches the matcher for the current directory level
- for(var i = 0; i < dirs.length; i++) {
- var dir = dirs[i];
-
- if(dir.match(matcher.regex) === null) {
- continue;
- }
-
- var pathName = PATH.join(path,dir);
-
- var stats = fs.statSync(pathName);
- if(stats.isDirectory()) {
- if(matcher.isDir) {
- traverse(pathName, level + 1);
- } else {
- continue;
- }
- }
- else if(level === matchers.length - 1) {
- // found a matching file
- if(stats.isFile()) {
- files.push(pathName);
- }
- }
- }
- };
-
- traverse(path, 0);
- return files;
-};
-
-
-
-//var pattern = '/Users/stammen/dev/microsoft/pkgcloud/test/*/*/*-test.js';
-//
-//var result = wildcard(pattern);
-//console.log(result);
-//console.log(result.length);
-
-
-
-
View
@@ -15,8 +15,7 @@
// }
// }).run();
//
-var util = require('util'),
- path = require('path'),
+var path = require('path'),
events = require('events'),
vows = exports;
@@ -33,6 +32,7 @@ vows.__defineGetter__('reporter', function () {
});
var stylize = require('./vows/console').stylize;
+var console = vows.console = require('./vows/console');
vows.console = require('./vows/console');
vows.inspect = require('./vows/console').inspect;
@@ -185,7 +185,7 @@ process.on('exit', function () {
}
});
- if (unFired.length > 0) { util.print('\n') }
+ if (unFired.length > 0) { console.log(); }
unFired.forEach(function (title) {
s.reporter.report(['error', {
@@ -205,7 +205,7 @@ process.on('exit', function () {
});
});
if (failure) {
- util.puts(vows.console.result(results));
+ console.log(console.result(results));
process.exit(1);
}
});
@@ -53,7 +53,7 @@ this.report = function (coverageMap) {
head = fs.readFileSync(__dirname + "/fragments/coverage-head.html", "utf8");
foot = fs.readFileSync(__dirname + "/fragments/coverage-foot.html", "utf8");
} catch (error) {
- util.print("Error: Unable to write to file coverage.html\n");
+ console.log("Error: Unable to write to file coverage.html");
return;
}
@@ -48,7 +48,7 @@ this.report = function (coverageMap) {
fs.writeSync(out, JSON.stringify(output));
fs.close(out);
} catch (error) {
- util.print("Error: Unable to write to file coverage.json\n");
+ console.log("Error: Unable to write to file coverage.json");
return;
}
};
@@ -24,15 +24,15 @@ this.report = function (coverageMap) {
if (coverageMap.hasOwnProperty(filename)) {
var data = file.coverage(filename, coverageMap[filename]);
- util.print(filename + ":\n");
- util.print("[ hits: " + data.hits + ", misses: " + data.misses);
- util.print(", sloc: " + data.sloc + ", coverage: " + data.coverage.toFixed(2) + "% ]\n");
+ console.log(filename + ":");
+ process.stdout.write("[ hits: " + data.hits + ", misses: " + data.misses);
+ console.log(", sloc: " + data.sloc + ", coverage: " + data.coverage.toFixed(2) + "% ]");
for (var i = 0; i < data.source.length; i++) {
- util.print(lpad(data.source[i].coverage, 5) + " | " + data.source[i].line + "\n");
+ console.log(lpad(data.source[i].coverage, 5) + " | " + data.source[i].line);
}
- util.print("\n");
+ console.log();
}
}
};
@@ -26,6 +26,7 @@ this.report = function (data) {
puts(console.vowText(event));
break;
case 'end':
+ console.log();
break;
case 'finish':
puts(console.result(event).join('\n'));
@@ -37,5 +38,5 @@ this.report = function (data) {
};
this.print = function (str) {
- util.print(str);
+ process.stdout.write(str);
};
View
@@ -5,7 +5,7 @@
"keywords" : ["testing", "spec", "test", "BDD"],
"author" : "Alexis Sellier <self@cloudhead.net>",
"contributors" : [{ "name": "Charlie Robbins", "email": "charlie.robbins@gmail.com" }],
- "dependencies" : {"eyes": ">=0.1.6", "diff": "~1.0.3"},
+ "dependencies" : {"eyes": ">=0.1.6", "diff": "~1.0.3", "glob": "3.1.x"},
"main" : "./lib/vows",
"bin" : {"vows": "./bin/vows"},
"directories" : {"test": "./test", "bin": "./bin"},

0 comments on commit ae4a214

Please sign in to comment.