From 11ade58e3f476ac2b6df32d15820d83847ad216d Mon Sep 17 00:00:00 2001 From: slieschke Date: Tue, 6 Aug 2013 15:48:14 +1200 Subject: [PATCH 1/4] Fixed running tests on Windows Tests specified by an absolute path on the command line and tests that reference relative resources now work on Windows. Also fixed the path resolution of tests to work correctly when using the prefix and server options. --- lib/options.js | 4 ++-- tests/1-args.js | 17 +++++++++++++++-- tests/html/assets/relativetest.js | 1 + tests/html/relative.html | 25 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 tests/html/assets/relativetest.js create mode 100644 tests/html/relative.html diff --git a/lib/options.js b/lib/options.js index 0a200ce..436a538 100644 --- a/lib/options.js +++ b/lib/options.js @@ -26,11 +26,11 @@ var path = require('path'), }, newPath, paths, a, p, t, v, concurrent, coverageFileName, sourceFilePrefix, phantom, stat, getPaths = function(opt) { - if (process.platform === 'win32' && !options.suffix) { //If options.suffix it's probably URL + if (process.platform === 'win32' && !options.suffix && !options.prefix && !options.server) { //If options.suffix it's probably a URL var g = glob.sync(opt, { cwd: process.cwd() }).map(function (filepath) { - return path.join(process.cwd(), filepath); + return path.relative(process.cwd(), filepath); //phantomjs won't "request" relative resources for absolute Windows paths }); if (g && g.length) { options.paths = [].concat(options.paths, g); diff --git a/tests/1-args.js b/tests/1-args.js index c7a02bb..871e747 100644 --- a/tests/1-args.js +++ b/tests/1-args.js @@ -612,8 +612,8 @@ var tests = { process.platform = _platform; return ret; }, - 'should expand 7 paths': function(topic) { - assert.equal(topic.paths.length, 7); + 'should expand 8 paths': function(topic) { + assert.equal(topic.paths.length, 8); } }, 'no files': { @@ -627,6 +627,19 @@ var tests = { 'should expand 0 paths': function(topic) { assert.equal(topic.paths.length, 0); } + }, + 'files on Windows': { + topic: function() { + var _platform = process.platform, ret; + process.platform = 'win32'; + ret = parse(['tests/html/relative.html', path.join(__dirname, '../tests/html/relative.html')]); + process.platform = _platform; + return ret; + }, + 'should return relative paths': function(topic) { + assert.equal(topic.paths[0], 'tests\\html\\relative.html') + assert.equal(topic.paths[1], 'tests\\html\\relative.html') + } } } }; diff --git a/tests/html/assets/relativetest.js b/tests/html/assets/relativetest.js new file mode 100644 index 0000000..3cd2220 --- /dev/null +++ b/tests/html/assets/relativetest.js @@ -0,0 +1 @@ +relativeVar = true; \ No newline at end of file diff --git a/tests/html/relative.html b/tests/html/relative.html new file mode 100644 index 0000000..b5d8ac3 --- /dev/null +++ b/tests/html/relative.html @@ -0,0 +1,25 @@ + + + + Test One + + + + + + + + From c9248e57a927e5a9882c3379324ab86c6c82dc56 Mon Sep 17 00:00:00 2001 From: slieschke Date: Tue, 6 Aug 2013 16:32:50 +1200 Subject: [PATCH 2/4] Added missing semicolons --- tests/1-args.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/1-args.js b/tests/1-args.js index 871e747..99fa428 100644 --- a/tests/1-args.js +++ b/tests/1-args.js @@ -637,8 +637,8 @@ var tests = { return ret; }, 'should return relative paths': function(topic) { - assert.equal(topic.paths[0], 'tests\\html\\relative.html') - assert.equal(topic.paths[1], 'tests\\html\\relative.html') + assert.equal(topic.paths[0], 'tests\\html\\relative.html'); + assert.equal(topic.paths[1], 'tests\\html\\relative.html'); } } } From 28ed55098456188319137fd561c29a0e0b14632e Mon Sep 17 00:00:00 2001 From: slieschke Date: Tue, 6 Aug 2013 16:44:56 +1200 Subject: [PATCH 3/4] Fixed relative path tests to work on *nix --- tests/1-args.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/1-args.js b/tests/1-args.js index 99fa428..df2c795 100644 --- a/tests/1-args.js +++ b/tests/1-args.js @@ -637,8 +637,8 @@ var tests = { return ret; }, 'should return relative paths': function(topic) { - assert.equal(topic.paths[0], 'tests\\html\\relative.html'); - assert.equal(topic.paths[1], 'tests\\html\\relative.html'); + assert.equal(topic.paths[0], path.join('tests', 'html', 'relative.html')); + assert.equal(topic.paths[1], path.join('tests', 'html', 'relative.html')); } } } From f3cc20861c1127bac2c96326d24bed4863ffe115 Mon Sep 17 00:00:00 2001 From: Simon Lieschke Date: Fri, 9 Aug 2013 22:09:18 +1200 Subject: [PATCH 4/4] Fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 094f391..947d876 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Using the built in server ------------------------- Using the `--server` command will fire up a server in the `process.cwd()` and serve anything -under it as statis content. Then when you select the tests to be run, they are converted to URL's +under it as static content. Then when you select the tests to be run, they are converted to URL's under the hood and fetched from the static server instead of the file system. Combine this with `-S` options like this: