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

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AsaAyers committed Aug 19, 2014
1 parent 91dc8bf commit a532a15
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .coffeelintignore
@@ -0,0 +1,2 @@
node_modules
test/fixtures
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -47,9 +47,9 @@
"prepublish": "cake prepublish",
"publish": "cake publish",
"install": "cake install",
"lint": "cake compile && ./bin/coffeelint -f coffeelint.json src/*.coffee src/rules/*.coffee test/*.coffee test/*.litcoffee",
"lint-csv": "cake compile && ./bin/coffeelint --csv -f coffeelint.json src/*.coffee test/*.coffee",
"lint-jslint": "cake compile && ./bin/coffeelint --jslint -f coffeelint.json src/*.coffee test/*.coffee",
"lint": "cake compile && ./bin/coffeelint .",
"lint-csv": "cake compile && ./bin/coffeelint --csv .",
"lint-jslint": "cake compile && ./bin/coffeelint --jslint .",
"compile": "cake compile"
}
}
File renamed without changes.
74 changes: 38 additions & 36 deletions test/test_commandline.coffee
Expand Up @@ -11,13 +11,15 @@ coffeelint = require path.join('..', 'lib', 'coffeelint')


# The path to the command line tool.
coffeelintPath = path.join('bin', 'coffeelint')
coffeelintPath = path.join('..', 'bin', 'coffeelint')

execOptions =
cwd: __dirname
# Run the coffeelint command line with the given
# args. Callback will be called with (error, stdout,
# stderr)
commandline = (args, callback) ->
exec("#{coffeelintPath} #{args.join(" ")}", callback)
exec("#{coffeelintPath} #{args.join(" ")}", execOptions, callback)


process.env.HOME = ""
Expand Down Expand Up @@ -62,7 +64,7 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'--noconfig'
'test/fixtures/clean.coffee'
'fixtures/clean.coffee'
]
commandline args, this.callback
return undefined
Expand All @@ -77,7 +79,7 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'--noconfig'
'test/fixtures/fourspaces.coffee'
'fixtures/fourspaces.coffee'
]
commandline args, this.callback
return undefined
Expand All @@ -90,7 +92,7 @@ vows.describe('commandline').addBatch({

topic : () ->
args = [
'test/fixtures/findconfigtest/sevenspaces.coffee'
'fixtures/findconfigtest/sevenspaces.coffee'
]
commandline args, this.callback
return undefined
Expand All @@ -102,7 +104,7 @@ vows.describe('commandline').addBatch({

topic : () ->
args = [
'test/fixtures/findconfigtest/package/sixspaces.coffee'
'fixtures/findconfigtest/package/sixspaces.coffee'
]
commandline args, this.callback
return undefined
Expand All @@ -115,8 +117,8 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'-f'
'test/fixtures/fourspaces.json'
'test/fixtures/fourspaces.coffee'
'fixtures/fourspaces.json'
'fixtures/fourspaces.coffee'
]

commandline args, this.callback
Expand All @@ -133,7 +135,7 @@ vows.describe('commandline').addBatch({
# file modifies NODE_PATH so this can look like a 3rd party
# module.
"he_who_must_not_be_named"
'test/fixtures/custom_rules/voldemort.coffee'
'fixtures/custom_rules/voldemort.coffee'
]

commandline args, this.callback
Expand All @@ -147,8 +149,8 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'-f'
'test/fixtures/custom_rules/rule_module.json'
'test/fixtures/custom_rules/voldemort.coffee'
'fixtures/custom_rules/rule_module.json'
'fixtures/custom_rules/voldemort.coffee'
]

commandline args, this.callback
Expand All @@ -164,9 +166,9 @@ vows.describe('commandline').addBatch({
args = [
'--noconfig'
'-f'
'test/fixtures/fourspaces.json'
'test/fixtures/fourspaces.coffee'
'test/fixtures/clean.coffee'
'fixtures/fourspaces.json'
'fixtures/fourspaces.coffee'
'fixtures/clean.coffee'
]

commandline args, this.callback
Expand All @@ -178,15 +180,15 @@ vows.describe('commandline').addBatch({
'with configuration file' :

topic : () ->
configPath = 'generated_coffeelint.json'
configPath = '../generated_coffeelint.json'
configFile = fs.openSync configPath, 'w'
commandline ['--makeconfig'], (error, stdout, stderr) =>
fs.writeSync configFile, stdout
assert.isNull(error)
args = [
'-f'
configPath
'test/fixtures/clean.coffee'
'fixtures/clean.coffee'
]
commandline args, (args...) =>
this.callback stdout, args...
Expand All @@ -205,8 +207,8 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'-f'
'test/fixtures/twospaces.warning.json'
'test/fixtures/fourspaces.coffee'
'fixtures/twospaces.warning.json'
'fixtures/fourspaces.coffee'
]

commandline args, this.callback
Expand All @@ -220,7 +222,7 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'--noconfig'
'test/fixtures/syntax_error.coffee'
'fixtures/syntax_error.coffee'
]
commandline args, this.callback
return undefined
Expand All @@ -234,8 +236,8 @@ vows.describe('commandline').addBatch({
args = [
'--noconfig',
'-r',
'test/fixtures/clean.coffee',
'test/fixtures/subdir'
'fixtures/clean.coffee',
'fixtures/subdir'
]
commandline args, this.callback
return undefined
Expand All @@ -250,8 +252,8 @@ vows.describe('commandline').addBatch({
topic : () ->
args = [
'-f'
'coffeelint.json'
'test/fixtures/cyclo_fail.coffee'
'../coffeelint.json'
'fixtures/cyclo_fail.coffee'
'--reporter jslint'
]
commandline args, this.callback
Expand All @@ -265,7 +267,7 @@ vows.describe('commandline').addBatch({
'with working string':
topic: () ->
exec("echo y = 1 | #{coffeelintPath} --noconfig --stdin",
this.callback)
execOptions, this.callback)
return undefined

'passes': (error, stdout, stderr) ->
Expand All @@ -277,7 +279,7 @@ vows.describe('commandline').addBatch({
'with failing string due to whitespace':
topic: () ->
exec("echo 'x = 1 '| #{coffeelintPath} --noconfig --stdin",
this.callback)
execOptions, this.callback)
return undefined

'fails': (error, stdout, stderr) ->
Expand All @@ -290,7 +292,7 @@ vows.describe('commandline').addBatch({
topic: () ->
exec("echo 'This is Markdown\n\n y = 1' | " +
"#{coffeelintPath} --noconfig --stdin --literate",
this.callback)
execOptions, this.callback)
return undefined

'passes': (error, stdout, stderr) ->
Expand All @@ -303,7 +305,7 @@ vows.describe('commandline').addBatch({
topic: () ->
exec("echo 'This is Markdown\n\n x = 1 \n y=2'| " +
"#{coffeelintPath} --noconfig --stdin --literate",
this.callback)
execOptions, this.callback)
return undefined

'fails': (error, stdout, stderr) ->
Expand All @@ -315,7 +317,7 @@ vows.describe('commandline').addBatch({
'with non existing enviroment set config file':
topic: () ->
args = [
'test/fixtures/clean.coffee'
'fixtures/clean.coffee'
]
process.env.COFFEELINT_CONFIG = "not_existing_293ujff"
commandline args, this.callback
Expand All @@ -327,9 +329,9 @@ vows.describe('commandline').addBatch({
'with existing enviroment set config file':
topic: () ->
args = [
'test/fixtures/fourspaces.coffee'
'fixtures/fourspaces.coffee'
]
conf = "test/fixtures/fourspaces.json"
conf = "fixtures/fourspaces.json"
process.env.COFFEELINT_CONFIG = conf
commandline args, this.callback
return undefined
Expand All @@ -341,9 +343,9 @@ vows.describe('commandline').addBatch({
topic: () ->
args = [
'--noconfig'
'test/fixtures/fourspaces.coffee'
'fixtures/fourspaces.coffee'
]
conf = "test/fixtures/fourspaces.json"
conf = "fixtures/fourspaces.json"
process.env.COFFEELINT_CONFIG = conf
commandline args, this.callback
return undefined
Expand All @@ -355,7 +357,7 @@ vows.describe('commandline').addBatch({
'with option q set':
'and no errors occured':
topic: () ->
args = [ '-q', '--noconfig', 'test/fixtures/clean.coffee' ]
args = [ '-q', '--noconfig', 'fixtures/clean.coffee' ]
commandline args, this.callback
return undefined

Expand All @@ -364,7 +366,7 @@ vows.describe('commandline').addBatch({

'and errors occured':
topic: () ->
args = [ '-q', 'test/fixtures/syntax_error.coffee' ]
args = [ '-q', 'fixtures/syntax_error.coffee' ]
commandline args, this.callback
return undefined

Expand All @@ -374,7 +376,7 @@ vows.describe('commandline').addBatch({
'with option q not set':
'and no errors occured':
topic: () ->
args = [ 'test/fixtures/clean.coffee' ]
args = [ 'fixtures/clean.coffee' ]
commandline args, this.callback
return undefined

Expand All @@ -383,7 +385,7 @@ vows.describe('commandline').addBatch({

'and errors occured':
topic: () ->
args = [ 'test/fixtures/syntax_error.coffee' ]
args = [ 'fixtures/syntax_error.coffee' ]
commandline args, this.callback
return undefined

Expand Down

0 comments on commit a532a15

Please sign in to comment.