<commit_before>/*

browserclient.js
================

Model objects (via Backbone) for a browser client (a connection to a browser + the test run session)
and the returned test results for a run of tests.

*/

var log = require('winston')
  , Backbone = require('backbone')
  , tap = require('tap')

var TestResults = Backbone.Model.extend({
    initialize: function(){
        this.reset()
    }
    , reset: function(){
        this.set({
            topLevelError: null
            , failed: 0
            , passed: 0
            , total: 0
            , tests: new Backbone.Collection
            , all: false
        })
    }
    , addResult: function(result){
        var total = this.get('total')
          , passed = this.get('passed')
          , failed = this.get('failed')
        total++
        if (result.failed == 0)
            passed++
        else
            failed++
        this.set({
            total: total
            , passed: passed
            , failed: failed
            , items: result.items
        })
        this.get('tests').push(result)
    }
})

exports.TestResults = TestResults

var BrowserRunner = Backbone.Model.extend({
    defaults: {
        type: 'browser'
    }
    , initialize: function(attrs){
        var client = this.client = attrs.client
        this.app = attrs.app
        this.server = this.app.server
        this.set({
            name: null
            , messages: new Backbone.Collection
            , results: new TestResults
        })
        var self = this
          , server = this.server
          , results = this.get('results')
          , messages = this.get('messages')
        
        client.on('top-level-error', function(msg, url, line){
            var message = msg + ' at ' + url + ', line ' + line + '\n'
            messages.push({
                type: 'error'
                , text: message
            })
        })
        client.on('error', function(message){
            messages.push({
                type: 'error'
                , text: message
            })
        })
        client.on('warn', function(message){
            messages.push({
                type: 'warn'
                , text: message
            })
        })
        client.on('log', function(message){
            messages.push({
                type: 'log'
                , text: message
            })
        })<commit_msg>Fixed browser's console.log new line endings.<commit_after>/*

browserclient.js
================

Model objects (via Backbone) for a browser client (a connection to a browser + the test run session)
and the returned test results for a run of tests.

*/

var log = require('winston')
  , Backbone = require('backbone')
  , tap = require('tap')

var TestResults = Backbone.Model.extend({
    initialize: function(){
        this.reset()
    }
    , reset: function(){
        this.set({
            topLevelError: null
            , failed: 0
            , passed: 0
            , total: 0
            , tests: new Backbone.Collection
            , all: false
        })
    }
    , addResult: function(result){
        var total = this.get('total')
          , passed = this.get('passed')
          , failed = this.get('failed')
        total++
        if (result.failed == 0)
            passed++
        else
            failed++
        this.set({
            total: total
            , passed: passed
            , failed: failed
            , items: result.items
        })
        this.get('tests').push(result)
    }
})

exports.TestResults = TestResults

var BrowserRunner = Backbone.Model.extend({
    defaults: {
        type: 'browser'
    }
    , initialize: function(attrs){
        var client = this.client = attrs.client
        this.app = attrs.app
        this.server = this.app.server
        this.set({
            name: null
            , messages: new Backbone.Collection
            , results: new TestResults
        })
        var self = this
          , server = this.server
          , results = this.get('results')
          , messages = this.get('messages')
        
        client.on('top-level-error', function(msg, url, line){
            var message = msg + ' at ' + url + ', line ' + line + '\n'
            messages.push({
                type: 'error'
                , text: message
            })
        })
        client.on('error', function(message){
            messages.push({
                type: 'error'
                , text: message + '\n'
            })
        })
        client.on('warn', function(message){
            messages.push({
                type: 'warn'
                , text: message + '\n'
            })
        })
        client.on('log', function(message){
            messages.push({
                type: 'log'
                , text: message + '\n'
            })
        })
{'fraction_non_alphanumeric': 0.1267838676318511, 'fraction_numerical': 0.001654601861427094, 'mean_word_length': 1.4119700748129675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2828232', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1264, 'n_words': 324}