<commit_before>function main (argv) {
  var fs = require("fs");
  var print = require("internal").print;
  if (argv.length < 2) {
    print("Usage: unittest TESTNAME [OPTIONS]");
    return;
  }
  var test = argv[1];
  var options = {};
  if (argv.length >= 3) {
    options = JSON.parse(argv[2]);
  }
  var UnitTest = require("org/arangodb/testing").UnitTest;
  start_pretty_print();
  var r = UnitTest(test,options); 
  fs.write("UNITTEST_RESULT.json",JSON.stringify(r));
  fs.write("UNITTEST_RESULT_SUMMARY.txt",JSON.stringify(r.all_ok));
  print(r);
}
<commit_msg>Output an XML status of the unittest which we hope is understood by Jenkins.<commit_after>function resultsToXml(results) {
  function xmlEscape(s) {
    return s.replace(/[<>&"]/g, function (c) {
      return "&"
        + { "<": "lt", ">": "gt", "&": "amp", "\"": "quot" }[c]
        + ";";
    });
  }

  var xml = [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ];

  xml.text = function (s) {
    Array.prototype.push.call(this, s);
    return this;
  };
  
  xml.elem = function (tagName, attrs, close) {
    this.text("<").text(tagName);

    for (var a in attrs || {}) {
      this.text(" ").text(a).text("=\"")
        .text(xmlEscape(String(attrs[a]))).text("\"");
    }

    close && this.text("/");
    this.text(">\n");

    return this;
  };

  xml.elem("testsuite", {
    errors: 0,
    failures: results.failed,
    name: results.suiteName,
    tests: results.total,
    time: results.duration
  });

  for (var i in  results.shell_server_aql) {
    var result = results.shell_server_aql[i];
    var success = (typeof(result) === 'boolean')? result : false;

    xml.elem("testcase", {
      name: i,
      time: 0.0
    }, success);
    
    if (!success) {
      xml.elem("failure", { message: result.message }, true)
        .elem("/testcase");
    }
  }

  xml.elem("/testsuite");

  return xml.join("");
}


function main (argv) {
  var fs = require("fs");
  var print = require("internal").print;
  if (argv.length < 2) {
    print("Usage: unittest TESTNAME [OPTIONS]");
    return;
  }
  var test = argv[1];
  var options = {};
  if (argv.length >= 3) {
    options = JSON.parse(argv[2]);
  }
  var UnitTest = require("org/arangodb/testing").UnitTest;
  start_pretty_print();
  var r = UnitTest(test,options); 
  fs.write("UNITTEST_RESULT.json",JSON.stringify(r));
  fs.write("UNITTEST_RESULT_SUMMARY.txt",JSON.stringify(r.all_ok));
  try {
    x = resultsToXml(r);
  }
  catch (x) {
    print(x.message);
  }
  fs.write("UNITTEST_RESULT.xml", x);
  
  print(r);
}

{'fraction_non_alphanumeric': 0.19561815336463223, 'fraction_numerical': 0.005477308294209703, 'mean_word_length': 3.026771653543307, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 1, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '6570134', 'n_tokens_mistral': 938, 'n_tokens_neox': 915, 'n_words': 181}