Skip to content

Commit

Permalink
could run single testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
winsonwq committed Mar 13, 2014
1 parent f2170e0 commit 47e387e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/comparison.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Comparison

diff: (callback) ->
defer = Q.defer()
promise = defer.promise.done callback
promise = defer.promise.then callback

that = @
fileData = _.values(@images)
Expand All @@ -31,7 +31,7 @@ class Comparison

@compare: (fileAData, fileBData, callback) ->
defer = Q.defer()
promise = defer.promise.done callback
promise = defer.promise.then callback

resemble(fileAData).compareTo(fileBData).onComplete (data) ->
defer.resolve data
Expand Down
20 changes: 13 additions & 7 deletions src/viff.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,15 @@ class Viff extends EventEmitter

compareTo = that.takeScreenshot _case.to.capability, _case.to.host, _case.url
Q.allSettled([compareTo]).then ([ts]) ->

if fs.reason or ts.reason
that.emit 'afterEach', _case, 0, fs.reason, ts.reason
next()
else
[fromImage, toImage] = [fs.value, ts.value]
imgWithEnvs = _.object [[_case.from.capability.key() + '-' + _case.from.name, fromImage], [_case.to.capability.key() + '-' + _case.to.name, toImage]]
comparison = new Comparison imgWithEnvs

comparison.diff (diffImg) ->
_case.result = comparison
that.emit 'afterEach', _case, Date.now() - startcase
that.runCase(_case, fs.value, ts.value).then ->
that.emit 'afterEach', _case, Date.now() - startcase, fs.reason, ts.reason
next()


, (err) ->
endTime = Date.now() - start
Expand All @@ -110,6 +107,15 @@ class Viff extends EventEmitter

defer.promise

runCase: (_case, fromImage, toImage, callback) ->
imgWithEnvs = _.object [[_case.from.capability.key() + '-' + _case.from.name, fromImage], [_case.to.capability.key() + '-' + _case.to.name, toImage]]
comparison = new Comparison imgWithEnvs

diff = comparison.diff (diffImg) -> _case.result = comparison
callback && diff.then callback

diff

closeDrivers: () ->
@drivers[browser].quit() for browser of @drivers

Expand Down

0 comments on commit 47e387e

Please sign in to comment.