<commit_before>var fs = require("fs");
var url = require("url");
var Mocha = require("mocha");

module.exports = function(grunt) {
    var browsers = [{
        browserName: "firefox",
        version: "19",
        platform: "XP"
    }, {
        browserName: "googlechrome",
        platform: "XP"
    }, {
        browserName: "internet explorer",
        platform: "XP",
        version: "6"
    }, {
        browserName: "googlechrome",
        platform: "linux"
    }, {
        browserName: "internet explorer",
        platform: "WIN8",
        version: "10"
    }];
    
    grunt.initConfig({
        connect: {
            server: {
                options: {
                    base: "",
                    port: 9000,
                    middleware: function(connect, options, middlewares) {
                        var mocha = new Mocha();
                        mocha.addFile(__dirname + "/test.js");
                        middlewares.push(function(req, res, next) {
                            var urlObj = url.parse(req.url, true);
                            switch(urlObj.pathname) {
                            case "/start":
                                res.setHeader("content-type", "text/javascript; utf-8");
                                
                                var runner = mocha.run();
                                var failedTests = [];
                                runner.on("end", function() {
                                    var mochaResults = runner.stats;
                                    mochaResults.reports = failedTests;
                                    res.end("onstart(" + JSON.stringify(JSON.stringify(mochaResults)) + ")");
                                });
                                runner.on("fail", function(test, err) {
                                    function flattenTitles(test) {
                                        var titles = [];
                                        while (test.parent.title) {
                                            titles.push(test.parent.title);
                                            test = test.parent;
                                        }
                                        return titles.reverse();
                                    };
                                    failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test)});
                                });
                                break;
                            default:
                                next();
                                break;
                            }
                        });
                        return middlewares;
                    }
                }
            }
        },
        "saucelabs-mocha": {
            all: {
                options: {
                    urls: ["http://127.0.0.1:9000/test.html"],
                    tunnelTimeout: 5,
                    build: process.env.TRAVIS_JOB_ID,
                    concurrency: 3,
                    browsers: browsers,
                    testname: "mocha tests",
                    tags: ["master"]
                }
            }
        }
    });
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-saucelabs");
    grunt.registerTask("test-local", ["connect:server:keepalive"]);
    grunt.registerTask("test", ["connect:server", "saucelabs-mocha"]);
};<commit_msg>Pass the test<commit_after>var fs = require("fs");
var url = require("url");
var Mocha = require("mocha");

module.exports = function(grunt) {
    var browsers = [{
        browserName: "firefox",
        version: "19",
        platform: "XP"
    }, {
        browserName: "googlechrome",
        platform: "XP"
    }, {
        browserName: "googlechrome",
        platform: "linux"
    }, {
        browserName: "internet explorer",
        platform: "WIN8",
        version: "10"
    }];
    
    grunt.initConfig({
        connect: {
            server: {
                options: {
                    base: "",
                    port: 9000,
                    middleware: function(connect, options, middlewares) {
                        var mocha = new Mocha();
                        mocha.addFile(__dirname + "/test.js");
                        middlewares.push(function(req, res, next) {
                            var urlObj = url.parse(req.url, true);
                            switch(urlObj.pathname) {
                            case "/start":
                                res.setHeader("content-type", "text/javascript; utf-8");
                                
                                var runner = mocha.run();
                                var failedTests = [];
                                runner.on("end", function() {
                                    var mochaResults = runner.stats;
                                    mochaResults.reports = failedTests;
                                    res.end("onstart(" + JSON.stringify(JSON.stringify(mochaResults)) + ")");
                                });
                                runner.on("fail", function(test, err) {
                                    function flattenTitles(test) {
                                        var titles = [];
                                        while (test.parent.title) {
                                            titles.push(test.parent.title);
                                            test = test.parent;
                                        }
                                        return titles.reverse();
                                    };
                                    failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test)});
                                });
                                break;
                            default:
                                next();
                                break;
                            }
                        });
                        return middlewares;
                    }
                }
            }
        },
        "saucelabs-mocha": {
            all: {
                options: {
                    urls: ["http://127.0.0.1:9000/test.html"],
                    tunnelTimeout: 5,
                    build: process.env.TRAVIS_JOB_ID,
                    concurrency: 3,
                    browsers: browsers,
                    testname: "mocha tests",
                    tags: ["master"]
                }
            }
        }
    });
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-saucelabs");
    grunt.registerTask("test-local", ["connect:server:keepalive"]);
    grunt.registerTask("test", ["connect:server", "saucelabs-mocha"]);
};
{'fraction_non_alphanumeric': 0.10742358078602621, 'fraction_numerical': 0.006550218340611353, 'mean_word_length': 0.8752729257641921, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3040690', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1530, 'n_words': 275}