Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix tests for windows systems #973

Merged
merged 2 commits into from

2 participants

@stevenbenner

Currently tests are producing several failures on windows systems. This is happening because of two issues where cli test conditions do not match the functionality in the cli code being tested. This patch resolves the following issues:

  1. Add process.env.HOMEPATH fallback for .jshintrc files
    The testHomeRcFile and testTargetRelativeRcLookup tests were only using process.env.HOME, which returns undefined on windows systems. It also does not match the functionality of findConfig() which coalesces the HOME and HOMEPATH environmental variables to support both *nix and windows.

  2. Normalize paths for stubbed .jshintrc files
    The testHomeRcFile and testTargetRelativeRcLookup tests were stubbing the .jshintrc files with hard coded forward slashes for path separators, which does not match the paths that the findConfig() will try to open. The findConfig() function runs the file paths through the path.resolve() method which returns a normalized path string. So the stubbed file commands were never actually being executed on windows systems.

Please note that I only fixed the failing tests in this patch. It might be a good idea to go through all of the tests at some point and make sure that paths are normalized across the board.

stevenbenner added some commits
@stevenbenner stevenbenner Added HOMEPATH fallback for HOME to cli tests.
The home path lookups in the cli tests were only using process.env.HOME,
which does not match the way the src/cli.js code works. This adds a
HOMEPATH fallback to match the tested functionality and support windows
systems.
e03688b
@stevenbenner stevenbenner Normalized stubbed .jshintrc paths for cli tests.
The paths that were being used to stub .jshintrc files did not match the
paths that would be searched for by the findConfig() function because
they are using hard coded forward slashes as path separators, but the
findConfig() function runs the supplied file path through path.resolve()
which returns normalized paths. This commit normalizes the stubbed
.jshintrc paths to match the functionality in findConfig() and support
windows systems.
3c74eb5
@valueof valueof merged commit b216fd7 into from
@valueof
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @stevenbenner

    Added HOMEPATH fallback for HOME to cli tests.

    stevenbenner authored
    The home path lookups in the cli tests were only using process.env.HOME,
    which does not match the way the src/cli.js code works. This adds a
    HOMEPATH fallback to match the tested functionality and support windows
    systems.
  2. @stevenbenner

    Normalized stubbed .jshintrc paths for cli tests.

    stevenbenner authored
    The paths that were being used to stub .jshintrc files did not match the
    paths that would be searched for by the findConfig() function because
    they are using hard coded forward slashes as path separators, but the
    findConfig() function runs the supplied file path through path.resolve()
    which returns normalized paths. This commit normalizes the stubbed
    .jshintrc paths to match the functionality in findConfig() and support
    windows systems.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 tests/cli.js
View
9 tests/cli.js
@@ -205,7 +205,7 @@ exports.group = {
testRcFile: function (test) {
sinon.stub(process, "cwd").returns(__dirname);
- var localRc = __dirname + "/.jshintrc";
+ var localRc = path.normalize(__dirname + "/.jshintrc");
var testStub = sinon.stub(shjs, "test");
var catStub = sinon.stub(shjs, "cat");
@@ -229,7 +229,7 @@ exports.group = {
},
testHomeRcFile: function (test) {
- var homeRc = path.join(process.env.HOME, ".jshintrc");
+ var homeRc = path.join(process.env.HOME || process.env.HOMEPATH, ".jshintrc");
var testStub = sinon.stub(shjs, "test");
var catStub = sinon.stub(shjs, "cat");
@@ -281,8 +281,9 @@ exports.group = {
},
testTargetRelativeRcLookup: function (test) {
- sinon.stub(process, "cwd").returns(process.env.HOME); // working from outside the project
- var projectRc = __dirname + "/.jshintrc";
+ // working from outside the project
+ sinon.stub(process, "cwd").returns(process.env.HOME || process.env.HOMEPATH);
+ var projectRc = path.normalize(__dirname + "/.jshintrc");
var srcFile = __dirname + "/sub/file.js";
var testStub = sinon.stub(shjs, "test");
var catStub = sinon.stub(shjs, "cat");
Something went wrong with that request. Please try again.