Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for windows systems #973

Merged
merged 2 commits into from
Apr 8, 2013
Merged

Fix tests for windows systems #973

merged 2 commits into from
Apr 8, 2013

Conversation

stevenbenner
Copy link
Contributor

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.

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.
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.
valueof added a commit that referenced this pull request Apr 8, 2013
Fix tests for windows systems
@valueof valueof merged commit b216fd7 into jshint:master Apr 8, 2013
@valueof
Copy link
Member

valueof commented Apr 8, 2013

Thanks!

jugglinmike pushed a commit to jugglinmike/jshint that referenced this pull request Oct 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants