Skip to content

Commit

Permalink
test(e2e): make sure config files do not collide
Browse files Browse the repository at this point in the history
Closes #1291
  • Loading branch information
sjelin authored and juliemr committed Feb 20, 2015
1 parent f723f7a commit 7943931
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions test/e2e/steps/core_steps.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ coreSteps = ->
callback()

@When /^I (run|start|init) Karma$/, (command, callback) ->
@writeConfigFile tmpDir, tmpConfigFile, (err) =>
callback.fail new Error(err) if err
@writeConfigFile tmpDir, tmpConfigFile, (err, hash) =>
return callback.fail new Error(err) if err

configFile = path.join tmpDir, tmpConfigFile
configFile = path.join tmpDir, hash + '.' + tmpConfigFile
options =
stdio: 'pipe'
cwd: baseDir
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/support/world.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fs = require 'fs'
vm = require 'vm'
path = require 'path'
hasher = require('crypto').createHash

mkdirp = require 'mkdirp'
_ = require 'lodash'
Expand Down Expand Up @@ -29,13 +30,15 @@ World = (callback) ->
# Generate a configuration file and save it to path.
@writeConfigFile = (dir, file, done) =>
mkdirp dir, 0o0755, (err) =>
throw new Error(err) if err
return done err if err

# Remove dirname from config again
delete @configFile.__dirname

content = @generateJS @configFile
fs.writeFile path.join(dir, file), content, done
hash = hasher('md5').update(content + Math.random()).digest 'hex';
fs.writeFile path.join(dir, hash + '.' + file), content, (err) ->
done err, hash

@generateJS = (config) ->
_.template @template, {content: JSON.stringify config}
Expand Down

0 comments on commit 7943931

Please sign in to comment.