<commit_before>var helper = require("../../../test-helper");
var buster = require("buster");
var stdioLogger = require("buster-cli/lib/stdio-logger");
var assert = buster.assert;
var refute = buster.refute;
var browserRunner = helper.require("cli/runners/browser-runner");
var busterClient = require("buster-client").client;
var busterConfigExt = helper.require("config");
var busterPromise = require("buster-promise");
var remoteRunner = helper.require("test-runner/remote-runner");
var progressReporter = helper.require("test-runner/progress-reporter");
var reporters = require("buster-test").reporters;
var http = require("http");

buster.testCase("Browser runner", {
    setUp: function () {
        this.sessionPromise = busterPromise.create();
        this.client = { createSession: this.stub().returns(this.sessionPromise) };
        this.stub(busterClient, "create").returns(this.client);
        this.stub(busterConfigExt, "extendConfigurationGroup");
        this.options = { server: "http://127.0.0.1:1200" };
        this.runner = Object.create(browserRunner);

        var self = this;
        this.stdout = "";
        this.stderr = "";

        this.runner.logger = stdioLogger.create(
            { puts: function (msg) { self.stdout += msg + "\n"; } },
            { puts: function (msg) { self.stderr += msg + "\n"; } });
    },

    "should create client for configured location": function () {
        this.runner.run({ load: [] }, this.options);

        assert.calledWith(busterClient.create, "1200", "127.0.0.1");
    },

    "should extend configuration": function () {
        var config = { id: 42 };
        this.runner.run(config, this.options);

        assert.calledOnce(busterConfigExt.extendConfigurationGroup);
        assert.calledWith(busterConfigExt.extendConfigurationGroup, config);
    },

    "should create session using provided session configuration": function () {
        this.runner.run({ sessionConfig: { id: 41 } }, this.options);

        assert.calledOnce(this.client.createSession);
        assert.calledWith(this.client.createSession, { id: 41 });
    },

    "should be run with runSession": function () {
        this.stub(this.runner, "runSession");
        this.runner.run({ sessionConfig: { id: 41 } }, this.options);
<commit_msg>Update stdioLogger usage to new API<commit_after>var helper = require("../../../test-helper");
var buster = require("buster");
var stdioLogger = require("buster-cli/lib/stdio-logger");
var assert = buster.assert;
var refute = buster.refute;
var browserRunner = helper.require("cli/runners/browser-runner");
var busterClient = require("buster-client").client;
var busterConfigExt = helper.require("config");
var busterPromise = require("buster-promise");
var remoteRunner = helper.require("test-runner/remote-runner");
var progressReporter = helper.require("test-runner/progress-reporter");
var reporters = require("buster-test").reporters;
var http = require("http");

buster.testCase("Browser runner", {
    setUp: function () {
        this.sessionPromise = busterPromise.create();
        this.client = { createSession: this.stub().returns(this.sessionPromise) };
        this.stub(busterClient, "create").returns(this.client);
        this.stub(busterConfigExt, "extendConfigurationGroup");
        this.options = { server: "http://127.0.0.1:1200" };
        this.runner = Object.create(browserRunner);

        var self = this;
        this.stdout = "";
        this.stderr = "";

        this.runner.logger = stdioLogger(
            { write: function (msg) { self.stdout += msg; } },
            { write: function (msg) { self.stderr += msg; } });
    },

    "should create client for configured location": function () {
        this.runner.run({ load: [] }, this.options);

        assert.calledWith(busterClient.create, "1200", "1192.168.127.12");
    },

    "should extend configuration": function () {
        var config = { id: 42 };
        this.runner.run(config, this.options);

        assert.calledOnce(busterConfigExt.extendConfigurationGroup);
        assert.calledWith(busterConfigExt.extendConfigurationGroup, config);
    },

    "should create session using provided session configuration": function () {
        this.runner.run({ sessionConfig: { id: 41 } }, this.options);

        assert.calledOnce(this.client.createSession);
        assert.calledWith(this.client.createSession, { id: 41 });
    },

    "should be run with runSession": function () {
        this.stub(this.runner, "runSession");
        this.runner.run({ sessionConfig: { id: 41 } }, this.options);

{'fraction_non_alphanumeric': 0.15339297403447524, 'fraction_numerical': 0.013528256600480034, 'mean_word_length': 3.3450236966824645, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '6392', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1288, 'n_words': 267}