<commit_before>
/*
    Utilities for testing jQuery-based JavaScript code.
*/
tests = {};

tests.waitFor = function(checkCondition, config) {
    /*
        Wait for a condition before doing anything else.

        Good for making async tests fast on fast machines.
        Use it like this::

          tests.waitFor(function() {
              return (thing == 'done);
          }).thenDo(function() {
              equals(1,1);
              ok(stuff());
          });

        You can pass in a config object as the second argument
        with these possible attributes:

        **config.interval**
          milliseconds to wait between polling condition
        **config.timeout**
          milliseconds to wait before giving up on condition
    */
    if (typeof(config) === 'undefined') {
        config = {};
    }
    var interval = config.interval || 5,
        timeout = config.timeout || 300,
        run,
        runWhenReady,
        timeSpent = 0;

    run = function() {
        if (timeSpent > timeout) {
            var cond = checkCondition.toString()
            ok(false, "Spent too long waiting for: " + cond);
            start();
        }
        timeSpent += interval;
        var ready = checkCondition();
        if (!ready) {
            setTimeout(run, interval);<commit_msg>Eases the polling hammer after test failures (@washort is right about polling)<commit_after>
/*
    Utilities for testing jQuery-based JavaScript code.
*/
tests = {};

tests.waitFor = function(checkCondition, config) {
    /*
        Wait for a condition before doing anything else.

        Good for making async tests fast on fast machines.
        Use it like this::

          tests.waitFor(function() {
              return (thing == 'done);
          }).thenDo(function() {
              equals(1,1);
              ok(stuff());
          });

        You can pass in a config object as the second argument
        with these possible attributes:

        **config.interval**
          milliseconds to wait between polling condition
        **config.timeout**
          milliseconds to wait before giving up on condition
    */
    if (typeof(config) === 'undefined') {
        config = {};
    }
    var interval = config.interval || 20,
        timeout = config.timeout || 1000,
        run,
        runWhenReady,
        timeSpent = 0;

    run = function() {
        if (timeSpent > timeout) {
            var cond = checkCondition.toString()
            ok(false, "Spent too long waiting for: " + cond);
            start();
        }
        timeSpent += interval;
        var ready = checkCondition();
        if (!ready) {
            setTimeout(run, interval);
{'fraction_non_alphanumeric': 0.10257366654233495, 'fraction_numerical': 0.005967922417008579, 'mean_word_length': 1.8291139240506329, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5077539', 'n_tokens_mistral': 689, 'n_tokens_neox': 660, 'n_words': 230}