<commit_before>var fs = require('fs'),
    jsdom = require('jsdom'),
    addScript = require('./test_util').addScript;

function dump_nodes(window) {
    var nodes = window.force.nodes();
    for(var i = 0 ; i < nodes.length; ++i) {
        console.log('nodes[' + nodes[i].id + '/' + nodes[i].type + '].[xy] = (' + nodes[i].x + ',' + nodes[i].y + ')');
    }
}

function dump_graphviz(force) {
    var i;
    var nodes = force.nodes();
    var links = force.links();
    var q = function(s) {
        if (s.search(' ') == -1) {
            return s;
        }
        return '"' + s + '"';
    };

    console.log('digraph {');
    for (i = 0 ; i < nodes.length; ++i) {
        if (nodes[i].type == 'bubble') {
            console.log(' BUBBLE;');
        } else {
            console.log(' ' + q(nodes[i].name) + ';');
        }
    }
    for (i = 0 ; i < links.length; ++i) {
        var link = links[i];
        console.log(' ' + q(link.__src.name) + ' -> ' + q(link.__dst.name) + ' [label=' + link.name + '];');
    }
    console.log('}');
}

function run_tests(settings) {
    var document = jsdom.jsdom('<html><body></body></html>');
    var window = document.parentWindow;

    window.console.log = console.log; // slightly evil
    window.process = process; // more evil
    window.is_node = true;
    if (settings.created) {
        settings.created(undefined, window);
    }
    debugger
    addScript(window, '../src/external/require.js')
        .load_next('../src/app.js')
        .done(function () {
            console.log('test harness: starting script loading with requirejs');
            window.require.config(window.rhizi_require_config);
            window.requirejs(['main'], function(main) {
                console.log('test harness: main loaded');
                main.main();
                if (settings.done) {
                    settings.done(undefined, window);
                }
                process.quit();
            });
        });
    //window.setInterval(function() { console.log('.'); return true; }, 100);
}

function reset(window) {
    window.require('rz_core').graph.clear();
}

function nodes(window) {
    return window.require('rz_core').force.nodes().map(function (n) {
        return n.name;
    });
}

function links(window) {
    return window.require('rz_core').force.links().map(function (l) {
        debugger;
        return [l.__src.name, l.__dst.name, l.name];
    });
}

exports.run_tests = run_tests;
exports.dump_graphviz = dump_graphviz;
exports.reset = reset;
exports.links = links;
exports.nodes = nodes;
<commit_msg>client-tests: small change, not working yet (i.e. still broken)<commit_after>var fs = require('fs'),
    jsdom = require('jsdom'),
    addScript = require('./test_util').addScript;

function dump_nodes(window) {
    var nodes = window.force.nodes();
    for(var i = 0 ; i < nodes.length; ++i) {
        console.log('nodes[' + nodes[i].id + '/' + nodes[i].type + '].[xy] = (' + nodes[i].x + ',' + nodes[i].y + ')');
    }
}

function dump_graphviz(force) {
    var i;
    var nodes = force.nodes();
    var links = force.links();
    var q = function(s) {
        if (s.search(' ') == -1) {
            return s;
        }
        return '"' + s + '"';
    };

    console.log('digraph {');
    for (i = 0 ; i < nodes.length; ++i) {
        if (nodes[i].type == 'bubble') {
            console.log(' BUBBLE;');
        } else {
            console.log(' ' + q(nodes[i].name) + ';');
        }
    }
    for (i = 0 ; i < links.length; ++i) {
        var link = links[i];
        console.log(' ' + q(link.__src.name) + ' -> ' + q(link.__dst.name) + ' [label=' + link.name + '];');
    }
    console.log('}');
}

function run_tests(settings) {
    var document = jsdom.jsdom('<html><body></body></html>');
    var window = document.parentWindow;

    window.console.log = console.log; // slightly evil
    window.process = process; // more evil
    window.is_node = true;
    if (settings.created) {
        settings.created(undefined, window);
    }
    debugger
    addScript(window, '../client/require.js')
        .load_next('../client/app.js')
        .done(function () {
            console.log('test harness: starting script loading with requirejs');
            console.dir(window.require);
            window.require.config(window.rhizi_require_config);
            window.requirejs(['main'], function(main) {
                console.log('test harness: main loaded');
                main.main();
                if (settings.done) {
                    settings.done(undefined, window);
                }
                process.quit();
            });
        });
    //window.setInterval(function() { console.log('.'); return true; }, 100);
}

function reset(window) {
    window.require('rz_core').graph.clear();
}

function nodes(window) {
    return window.require('rz_core').force.nodes().map(function (n) {
        return n.name;
    });
}

function links(window) {
    return window.require('rz_core').force.links().map(function (l) {
        debugger;
        return [l.__src.name, l.__dst.name, l.name];
    });
}

exports.run_tests = run_tests;
exports.dump_graphviz = dump_graphviz;
exports.reset = reset;
exports.links = links;
exports.nodes = nodes;

{'fraction_non_alphanumeric': 0.18221629855293223, 'fraction_numerical': 0.0026656511805026656, 'mean_word_length': 2.210880195599022, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '7626022', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1660, 'n_words': 321}