From 2c43548ac629467596ee64d0c614a0cef3169852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 27 Mar 2013 09:40:53 -0400 Subject: [PATCH] Tests: Handle globals in .jshintrc. --- tests/unit/testsuite.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index d2403beeb..ddc59ed08 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -77,16 +77,22 @@ TestHelpers.testJshint = function( module ) { dataType: "text" }) ).done(function( hintArgs, srcArgs ) { - var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ), - errors = $.map( JSHINT.errors, function( error ) { - // JSHINT may report null if there are too many errors - if ( !error ) { - return; - } + var globals, passed, errors, + jshintrc = hintArgs[ 0 ], + source = srcArgs[ 0 ]; - return "[L" + error.line + ":C" + error.character + "] " + - error.reason + "\n" + error.evidence + "\n"; - }).join( "\n" ); + globals = jshintrc.globals || {}; + delete jshintrc.globals; + passed = JSHINT( source, jshintrc, globals ), + errors = $.map( JSHINT.errors, function( error ) { + // JSHINT may report null if there are too many errors + if ( !error ) { + return; + } + + return "[L" + error.line + ":C" + error.character + "] " + + error.reason + "\n" + error.evidence + "\n"; + }).join( "\n" ); ok( passed, errors ); start(); })