Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
Fix output paths and urls for use on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
metafeather committed Apr 23, 2012
1 parent e791477 commit e98ab49
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion run-yuitest-multi.js
Expand Up @@ -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)) {

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion yuitest/urls.js
Expand Up @@ -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
Expand Down
23 changes: 19 additions & 4 deletions yuitest/utils.js
Expand Up @@ -33,6 +33,12 @@ function isObject(ref){
return (typeof(ref) === 'object');
}

/**
* 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.
*/
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
});
}
Expand Down

0 comments on commit e98ab49

Please sign in to comment.