<commit_before>// PhantomJS QUnit Test Runner

/*globals QUnit phantom*/

var system = require("system"),
    args = phantom.args;

if (args === undefined) {
  args = system.args;
  args.shift();
}

if (args.length < 1 || args.length > 2) {
  console.log("Usage: " + phantom.scriptName + " <URL> <timeout>");
  phantom.exit(1);
}

var page = require("webpage").create();

page.onConsoleMessage = function(msg) {
  if (msg.slice(0, 8) === "WARNING:") { return; }
  if (msg.slice(0, 6) === "DEBUG:") { return; }

  console.log(msg);
};

page.onCallback = function (message) {
  // forward the message to the standard output
  system.stdout.write(message);
};

page.open(args[0], function(status) {
  if (status !== "success") {
    console.error("Unable to access network");
    phantom.exit(1);
  } else {
    page.evaluate(logQUnit);

    var timeout = parseInt(args[1] || 130000, 10),
        start = Date.now();

    var interval = setInterval(function() {
      if (Date.now() > start + timeout) {
        console.error("Tests timed out");
        phantom.exit(124);
      } else {
        var qunitDone = page.evaluate(function() {
          return window.qunitDone;
        });

        if (qunitDone) {
          clearInterval(interval);
          if (qunitDone.failed > 0) {
            phantom.exit(1);
          } else {
            phantom.exit();
          }
        }<commit_msg>Fix qunit tests on Travis.<commit_after>// PhantomJS QUnit Test Runner

/*globals QUnit phantom*/

var system = require("system"),
    args = phantom.args;

if (args === undefined) {
  args = system.args;
  args.shift();
}

if (args.length < 1 || args.length > 2) {
  console.log("Usage: " + phantom.scriptName + " <URL> <timeout>");
  phantom.exit(1);
}

var page = require("webpage").create();

page.onConsoleMessage = function(msg) {
  if (msg.slice(0, 8) === "WARNING:") { return; }
  if (msg.slice(0, 6) === "DEBUG:") { return; }

  console.log(msg);
};

page.onCallback = function (message) {
  // forward the message to the standard output
  system.stdout.write(message);
};

page.open(args[0], function(status) {
  if (status !== "success") {
    console.error("Unable to access network");
    phantom.exit(1);
  } else {
    page.evaluate(logQUnit);

    var timeout = parseInt(args[1] || 200000, 10),
        start = Date.now();

    var interval = setInterval(function() {
      if (Date.now() > start + timeout) {
        console.error("Tests timed out");
        phantom.exit(124);
      } else {
        var qunitDone = page.evaluate(function() {
          return window.qunitDone;
        });

        if (qunitDone) {
          clearInterval(interval);
          if (qunitDone.failed > 0) {
            phantom.exit(1);
          } else {
            phantom.exit();
          }
        }
{'fraction_non_alphanumeric': 0.16565295169946334, 'fraction_numerical': 0.016457960644007157, 'mean_word_length': 2.566326530612245, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6873553', 'n_tokens_mistral': 965, 'n_tokens_neox': 884, 'n_words': 206}