<commit_before>var fs = require('fs'),
    _path = require('path');

function collect(path, files, matches) {
    matches = matches || function (path) {
        return path.match(/test\.\w+\.js$/);
    };

    if (fs.statSync(path).isDirectory()) {
        fs.readdirSync(path).forEach(function (item) {
            collect(_path.join(path, item), files, matches);
        });
    } else if (matches(path)) {
        files.push(path);
    }
}

module.exports = function () { 
    var connect = require('connect'),
        packager = require('../build/packager'),
        tests = [],
        html = fs.readFileSync(__dirname + "/suite.html", "utf-8"),
        doc,
        modules,
        specs,
        app = connect(
            connect.static(__dirname + "/../lib/"),
            connect.static(__dirname + "/../"),
            connect.static(__dirname),
            connect.router(function (app) {
                app.get('/', function (req, res) {
                    res.writeHead(200, {
                        "Cache-Control": "no-cache",
                        "Content-Type": "text/html"
                    });
                    tests = [];
                    collect(__dirname, tests);

                    specs = tests.map(function (file, path) {
                        return '<script src="' + file.replace(/^.*test/, "test") +
                            '" type="text/javascript" charset="utf-8"></script>';
                    }).join('');
                    modules = packager.modules('test'); 
                    doc = html.replace(/<!-- TESTS -->/g, specs).replace(/"##MODULES##"/g, modules);
                    res.end(doc);
                });
            })
        );

    app.listen(3000);

    process.stdout.write("Test Server running on:\n");
    process.stdout.write("http://127.0.0.1:3000\n");
};<commit_msg>added opening up browser to test task<commit_after>var fs = require('fs'),
    _path = require('path'),
    exec = require('child_process').exec;

function collect(path, files, matches) {
    matches = matches || function (path) {
        return path.match(/test\.\w+\.js$/);
    };

    if (fs.statSync(path).isDirectory()) {
        fs.readdirSync(path).forEach(function (item) {
            collect(_path.join(path, item), files, matches);
        });
    } else if (matches(path)) {
        files.push(path);
    }
}

module.exports = function () { 
    var connect = require('connect'),
        packager = require('../build/packager'),
        tests = [],
        html = fs.readFileSync(__dirname + "/suite.html", "utf-8"),
        doc,
        modules,
        specs,
        app = connect(
            connect.static(__dirname + "/../lib/"),
            connect.static(__dirname + "/../"),
            connect.static(__dirname),
            connect.router(function (app) {
                app.get('/', function (req, res) {
                    res.writeHead(200, {
                        "Cache-Control": "no-cache",
                        "Content-Type": "text/html"
                    });
                    tests = [];
                    collect(__dirname, tests);

                    specs = tests.map(function (file, path) {
                        return '<script src="' + file.replace(/^.*test/, "test") +
                            '" type="text/javascript" charset="utf-8"></script>';
                    }).join('');
                    modules = packager.modules('test'); 
                    doc = html.replace(/<!-- TESTS -->/g, specs).replace(/"##MODULES##"/g, modules);
                    res.end(doc);
                });
            })
        );

    app.listen(3000);

    process.stdout.write("Test Server running on:\n");
    process.stdout.write("http://127.0.0.1:3000\n");

    exec('open http://127.0.0.1:3000');
};
{'fraction_non_alphanumeric': 0.17442778216258878, 'fraction_numerical': 0.012628255722178374, 'mean_word_length': 1.5363575717144764, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '5473251', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1015, 'n_words': 188}