<commit_before>/**
 * Module dependencies
 */

var should = require('should');
var conf = global['hypertest-' + __filename];
var hyperagent = require('hyperagent')(conf.host);

describe(conf.host, function() {
  conf.tests.forEach(function(test) {
    describe(test.path, function() {
      beforeEach(function(done) {
        var self = this;
        hyperagent(test.path, function(err, value, res) {
          if (err) return done(err);
          self.val = value;
          self.res = res;
          done();
        });
      });

      test.assertions.forEach(function(assert) {
        it(assert.name, function(done) {
          var aliases = {
            val: this.val,
            value: this.val,
            res: this.res,
            path: test.path,
            key: test.path,
            should: should,
            hyperagent: hyperagent,
            hyper: hyperagent,
            done: done,
            fn: done,
            cb: done,
            require: require
          };
          var args = getArgs(assert.fn);
          var vals = args.map(function(arg) {
            if (!~['val', 'value'].indexOf(arg) && typeof aliases[arg] === 'undefined') throw new Error('invalid argument ' + arg);
            return aliases[arg];
          });
          assert.fn.apply(this, vals);
          if (!~args.indexOf('done')) done();
        });
      });
    });
  });
});

function getArgs(fn) {
  var str = fn.toString();
  return str.slice(str.indexOf('(') + 1, str.indexOf(')')).match(/([^\s,]+)/g);
}
<commit_msg>execute the request once per path<commit_after>/**
 * Module dependencies
 */

var should = require('should');
var conf = global['hypertest-' + __filename];
var hyperagent = require('hyperagent')(conf.host);

describe(conf.host, function() {
  conf.tests.forEach(function(test) {
    describe(test.path, function() {
      before(function(done) {
        var self = this;
        hyperagent(test.path, function(err, value, res) {
          if (err) return done(err);
          self.val = value;
          self.res = res;
          done();
        });
      });

      test.assertions.forEach(function(assert) {
        it(assert.name, function(done) {
          var aliases = {
            val: this.val,
            value: this.val,
            res: this.res,
            path: test.path,
            key: test.path,
            should: should,
            hyperagent: hyperagent,
            hyper: hyperagent,
            done: done,
            fn: done,
            cb: done,
            require: require
          };
          var args = getArgs(assert.fn);
          var vals = args.map(function(arg) {
            if (!~['val', 'value'].indexOf(arg) && typeof aliases[arg] === 'undefined') throw new Error('invalid argument ' + arg);
            return aliases[arg];
          });
          assert.fn.apply(this, vals);
          if (!~args.indexOf('done')) done();
        });
      });
    });
  });
});

function getArgs(fn) {
  var str = fn.toString();
  return str.slice(str.indexOf('(') + 1, str.indexOf(')')).match(/([^\s,]+)/g);
}

{'fraction_non_alphanumeric': 0.16049382716049382, 'fraction_numerical': 0.000649772579597141, 'mean_word_length': 1.877570093457944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1282033', 'n_tokens_mistral': 907, 'n_tokens_neox': 902, 'n_words': 199}