Permalink
Browse files

Fixed ci output for non-tap outputing processes.

  • Loading branch information...
1 parent 00d8bed commit d912782c79e6442c6df4c3e8cb48427f8d257436 @airportyh airportyh committed Aug 13, 2012
Showing with 81 additions and 47 deletions.
  1. +44 −6 lib/ci_mode_app.js
  2. +5 −4 lib/launcher.js
  3. +24 −29 lib/runners.js
  4. +7 −7 tests/runner_clients_tests.js
  5. +1 −1 tests/splitlines_tests.js
View
@@ -16,6 +16,8 @@ var yaml = require('js-yaml')
, async = require('async')
, Backbone = require('backbone')
, Config = require('./config')
+ , log = require('winston')
+ , TestResults = require('./runners').TestResults
, EventEmitter = require('events').EventEmitter
var fileExists = fs.exists || path.exists
@@ -71,9 +73,42 @@ App.prototype = {
}
}
- launcher.once('processExit', function(){
+ launcher.once('processExit', function(code){
processExited = true
- if (gotTestResults) finish()
+ if (launcher.settings.protocol === 'browser' ||
+ launcher.settings.protocol === 'tap'){
+ if (gotTestResults) finish()
+ }else{
+ var results = new TestResults
+ var command = launcher.settings.command
+ var stdout = launcher.runner.get('messages')
+ .filter(function(m){
+ return m.get('type') === 'log'
+ }).map(function(m){
+ return m.get('text')
+ }).join('\n')
+ var stderr = launcher.runner.get('messages')
+ .filter(function(m){
+ return m.get('type') === 'error'
+ }).map(function(m){
+ return m.get('text')
+ }).join('\n')
+ var result = {
+ passed: code === 0
+ , failed: code !== 0
+ , total: 1
+ , id: 1
+ , name: '"' + command + '"'
+ , items: [{
+ passed: false
+ , message: 'Exited with code ' + code
+ , stdout: stdout
+ , stderr: stderr
+ }]
+ }
+ results.addResult(result)
+ self.emit('all-test-results', results)
+ }
})
self.once('all-test-results', function(results){
@@ -128,13 +163,16 @@ App.prototype = {
return !i.passed
})[0]
- producer.write({
+ var line = {
id: this.testId++
, ok: false
, name: testName
- , message: '"' + item.message + '"'
- , stacktrace: item.stacktrace
- })
+ , message: item.message
+ }
+ if (item.stacktrace) line.stacktrace = item.stacktrace
+ if (item.stdout) line.stdout = item.stdout
+ if (item.stderr) line.stderr = item.stderr
+ producer.write(line)
}
}.bind(this))
View
@@ -28,10 +28,11 @@ Launcher.prototype = {
if (this.isProcess()){
var self = this
var app = this.app
- app.runners.push(new ProcessRunner({
+ self.runner = new ProcessRunner({
app: app
, launcher: self
- }))
+ })
+ app.runners.push(self.runner)
}else{
this.launch()
}
@@ -85,8 +86,8 @@ Launcher.prototype = {
if (cb) cb(self.process)
}
}
- , onExit: function(){
- this.emit('processExit')
+ , onExit: function(code){
+ this.emit('processExit', code)
this.process = null
}
, kill: function(sig, cb){
View
@@ -208,39 +208,34 @@ var ProcessRunner = Backbone.Model.extend({
}
return
}
- try{
- var results = this.get('results')
+ var results = this.get('results')
- if (data.id === undefined) {
- return
- }
+ if (data.id === undefined) {
+ return
+ }
- var test = {
- passed: 0
- , failed: 0
- , total: 1
- , id: data.id
- , name: data.name.trim()
- , items: []
- }
+ var test = {
+ passed: 0
+ , failed: 0
+ , total: 1
+ , id: data.id
+ , name: data.name.trim()
+ , items: []
+ }
- if (!data.ok) {
- test.items.push({
- passed: false
- , message: this.message
- , stacktrace: this.stacktrace.join('\n')
- })
- test.failed++
- } else {
- test.passed++
- }
- results.addResult(test)
- this.message = null
- this.stacktrace = []
- }catch(e){
- log.error(e.message)
- log.error(e.stack)
+ if (!data.ok) {
+ test.items.push({
+ passed: false
+ , message: this.message
+ , stacktrace: this.stacktrace.join('\n')
+ })
+ test.failed++
+ } else {
+ test.passed++
}
+ results.addResult(test)
+ this.message = null
+ this.stacktrace = []
}
, onTapError: function(){
this.set('results', null)
@@ -1,12 +1,12 @@
-var runner_clients = require('../lib/runner_clients')
- , BrowserClient = runner_clients.BrowserClient
- , ProcessClient = runner_clients.ProcessClient
+var runner_clients = require('../lib/runners')
+ , BrowserRunner = runner_clients.BrowserRunner
+ , ProcessRunner = runner_clients.ProcessRunner
, test = require('./testutils.js')
, EventEmitter = require('events').EventEmitter
, expect = test.expect
-describe('BrowserClient', function(){
+describe('BrowserRunner', function(){
var socket, app, client, server
beforeEach(function(){
socket = new EventEmitter
@@ -18,7 +18,7 @@ describe('BrowserClient', function(){
app = {
server: server
}
- client = new BrowserClient({
+ client = new BrowserRunner({
client: socket
, app: app
})
@@ -103,11 +103,11 @@ describe('BrowserClient', function(){
})
})
-describe('ProcessClient', function(){
+describe('ProcessRunner', function(){
var client
var onStdoutData
beforeEach(function(){
- client = new ProcessClient({
+ client = new ProcessRunner({
app: {}
, launcher: {
process: {
@@ -1,6 +1,6 @@
var test = require('./testutils.js')
var expect = test.expect
-var StyledString = require('../lib/styled_string')
+var StyledString = require('styled_string')
var splitLines = require('../lib/splitlines')
describe('splitLines', function(){

0 comments on commit d912782

Please sign in to comment.