Permalink
Browse files

Fix output paths and urls for use on Windows

  • Loading branch information...
1 parent e791477 commit e98ab49dd871cafbfaff06513d7cd58b06102fdb @metafeather committed Apr 23, 2012
Showing with 24 additions and 6 deletions.
  1. +4 −1 run-yuitest-multi.js
  2. +1 −1 yuitest/urls.js
  3. +19 −4 yuitest/utils.js
View
@@ -7,7 +7,7 @@
* Home: https://github.com/metafeather/phantomjs-yuitest
*/
-var fileoverview = "PhantomJS YUITest Driver (v0.3.13)";
+var fileoverview = "PhantomJS YUITest Driver (v0.3.14)";
if (typeof(phantom) !== "undefined" && (phantom.version.major >= 1 && phantom.version.minor >= 4)) {
@@ -56,6 +56,9 @@ if (typeof(phantom) !== "undefined" && (phantom.version.major >= 1 && phantom.ve
outDir += (!isUndefined(options.testRunId) ? options.testRunId + fs.separator : '0' + fs.separator);
outDir += (!isUndefined(options.browserId) ? options.browserId + fs.separator : 'unknown' + fs.separator);
+ // make path x-platform
+ outDir = fixPathSeparator(outDir);
+
// clear old results
fs.removeTree(outDir);
View
@@ -37,7 +37,7 @@ function makeTestUrls(options){
for(var i = 0; i < allFiles.length; i++) {
var file = allFiles[i],
fullPath = fs.absolute(file),
- relativePath = fullPath.replace(dir + fs.separator, ''),
+ relativePath = fullPath.replace(dir + '/', ''),
testUrl = '';
// check if path exists and matches, then create a test url to it
View
@@ -34,6 +34,12 @@ function isObject(ref){
}
/**
+ * Normalise path separators x-platform.
+ */
+function fixPathSeparator(path) {
+ return path.replace(/\\/g, fs.separator).replace(/\//g, fs.separator);
+}
+/**
* Turn a path into just the directory part.
*/
function toFileDir(path) {
@@ -45,7 +51,16 @@ function toFileDir(path) {
*/
function toFileName(path) {
var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
- return path.substring(nameStart);
+ var filename = path.substring(nameStart);
+
+ // remove bad chars
+ [':', '\\', '/', '*', '"', '<', '>', '|' , '^', '\\0'].forEach(
+ function (v,i,a){
+ filename = filename.replace(v, '');
+ }
+ )
+ filename = filename.replace('?', '#'); // treat query as fragment
+ return filename;
}
/**
* Get the extension of a filename
@@ -133,9 +148,9 @@ function dirwalk(path) {
files.push(path);
} else if (fs.isDirectory(path)) {
files.push(path);
- fs.list(path).forEach(function (e) {
- if ( e !== "." && e !== ".." ) { //< Avoid loops
- scanDirectory(path + '/' + e);
+ fs.list(path).forEach(function (v,i,a) {
+ if ( v !== "." && v !== ".." ) { //< Avoid loops
+ scanDirectory(path + fs.separator + v);
}
});
}

0 comments on commit e98ab49

Please sign in to comment.