<commit_before>var srcFolder = "../../../src/node_modules/";
var wd = require(srcFolder + "wd");
var async = require(srcFolder + "async");

var config = {
	  host: "ondemand.saucelabs.com"
  , port: 80
  , username: process.env.SAUCE_USER
  , accessKey: process.env.SAUCE_KEY
}

var allTestsPassed = true;

var sauceTestWorker = async.queue(function (testSettings, callback) {
  var browser = wd.remote(config.host, config.port, config.username, config.accessKey);
  var browserChain = browser.chain();
  var name = process.env.GIT_HASH + " - " + testSettings.browserName + " " + testSettings.version + ", " + testSettings.platform;
  testSettings.name = name;
  console.log("Remote sauce test '" + name + "' started!");

  browserChain.init(testSettings).get("http://localhost:9001/tests/frontend/", function(){
    //tear down the test excecution
    var stopSauce = function(success){
      getStatusInterval && clearInterval(getStatusInterval);
      clearTimeout(timeout);

      browserChain.quit();

      if(!success){
        allTestsPassed = false;
      }

      var testResult = knownConsoleText.replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m')
                       .replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m');
      testResult = testResult.split("\n").map(function(line){
        var newLine = "[" + testSettings.browserName + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] ";
      }).join("\n");
      
      console.log(testResult);
      console.log("Remote sauce test '" + name + "' finished!");

      callback();
    }

    //timeout for the case the test hangs
    var timeout = setTimeout(function(){
      stopSauce(false);
    }, 60000 * 10);

    var knownConsoleText = "";
    var getStatusInterval = setInterval(function(){
      browserChain.eval("$('#console').text()", function(err, consoleText){
        if(!consoleText || err){
          return;
        }
        knownConsoleText = consoleText;

        if(knownConsoleText.indexOf("FINISHED") > 0){
          var success = knownConsoleText.indexOf("FAILED") === -1;
          stopSauce(success);
        }
      });
    }, 5000);
  });
}, 2); //run 2 tests in parrallel

// Firefox 
sauceTestWorker.push({
    'platform'       : 'Linux'
  , 'browserName'    : 'firefox'
  , 'version'        : ''
});

// Chrome
sauceTestWorker.push({<commit_msg>Let's try 5 tests in parrallel<commit_after>var srcFolder = "../../../src/node_modules/";
var wd = require(srcFolder + "wd");
var async = require(srcFolder + "async");

var config = {
	  host: "ondemand.saucelabs.com"
  , port: 80
  , username: process.env.SAUCE_USER
  , accessKey: process.env.SAUCE_KEY
}

var allTestsPassed = true;

var sauceTestWorker = async.queue(function (testSettings, callback) {
  var browser = wd.remote(config.host, config.port, config.username, config.accessKey);
  var browserChain = browser.chain();
  var name = process.env.GIT_HASH + " - " + testSettings.browserName + " " + testSettings.version + ", " + testSettings.platform;
  testSettings.name = name;
  console.log("Remote sauce test '" + name + "' started!");

  browserChain.init(testSettings).get("http://localhost:9001/tests/frontend/", function(){
    //tear down the test excecution
    var stopSauce = function(success){
      getStatusInterval && clearInterval(getStatusInterval);
      clearTimeout(timeout);

      browserChain.quit();

      if(!success){
        allTestsPassed = false;
      }

      var testResult = knownConsoleText.replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m')
                       .replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m');
      testResult = testResult.split("\n").map(function(line){
        var newLine = "[" + testSettings.browserName + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] ";
      }).join("\n");
      
      console.log(testResult);
      console.log("Remote sauce test '" + name + "' finished!");

      callback();
    }

    //timeout for the case the test hangs
    var timeout = setTimeout(function(){
      stopSauce(false);
    }, 60000 * 10);

    var knownConsoleText = "";
    var getStatusInterval = setInterval(function(){
      browserChain.eval("$('#console').text()", function(err, consoleText){
        if(!consoleText || err){
          return;
        }
        knownConsoleText = consoleText;

        if(knownConsoleText.indexOf("FINISHED") > 0){
          var success = knownConsoleText.indexOf("FAILED") === -1;
          stopSauce(success);
        }
      });
    }, 5000);
  });
}, 5); //run 2 tests in parrallel

// Firefox 
sauceTestWorker.push({
    'platform'       : 'Linux'
  , 'browserName'    : 'firefox'
  , 'version'        : ''
});

// Chrome
sauceTestWorker.push({
{'fraction_non_alphanumeric': 0.16996047430830039, 'fraction_numerical': 0.013938007073018515, 'mean_word_length': 2.9153094462540716, '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': '7044309', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1491, 'n_words': 278}