<commit_before>'use strict';

var chai     = require('chai')
  , chaiHttp = require('chai-http')
  , spawn    = require('child_process').spawn
  , PORT     = 33399
  , should   = chai.should();

chai.use(chaiHttp);

var base_url = 'http://localhost:' + PORT;

var microserver = spawn('Rscript', [process.cwd() + '/inst/simple_server.R']);
microserver.on('data', function (data) {
  console.log('stdout: ' + data);
});
microserver.stderr.on('data', function (data) {
  console.log('stderr: ' + data);
});
microserver.on('close', function (code, signal) {
  console.log('R process exited with code ' + code + ' by signal ' + signal);
});
microserver.on('error', function (err) {
  console.log('Failed to start child process.');
});

describe('microserver', function() {
  beforeEach(function(done) {
    this.timeout(1500); // A very long environment setup.
    setTimeout(done, 1000);
  });
  it('should pong on a /ping', function(done) {
    chai.request(base_url)
      .get('/ping')
      .end(function(err, res) {
        res.should.have.status(200);
        res.text.should.equal('"pong"');
        done();
      });
  });
  it('should use a catch all route on other requests', function(done) {
    chai.request(base_url)
      .get('/foo')
      .end(function(err, res) {
        res.should.have.status(200);
        res.type.should.equal('text/json');
        JSON.parse(res.text).exception.should.equal('catch all route');
        done();
      });
  });
});
<commit_msg>update timeouts<commit_after>'use strict';

var chai     = require('chai')
  , chaiHttp = require('chai-http')
  , spawn    = require('child_process').spawn
  , PORT     = 33399
  , should   = chai.should();

chai.use(chaiHttp);

var base_url = 'http://localhost:' + PORT;

var microserver = spawn('Rscript', [process.cwd() + '/inst/simple_server.R']);
microserver.on('data', function (data) {
  console.log('stdout: ' + data);
});
microserver.stderr.on('data', function (data) {
  console.log('stderr: ' + data);
});
microserver.on('close', function (code, signal) {
  console.log('R process exited with code ' + code + ' by signal ' + signal);
});
microserver.on('error', function (err) {
  console.log('Failed to start child process.');
});

describe('microserver', function() {
  before(function(done) {
    this.timeout(2000); // A very long environment setup.
    setTimeout(done, 1900);
  });
  it('should pong on a /ping', function(done) {
    chai.request(base_url)
      .get('/ping')
      .end(function(err, res) {
        res.should.have.status(200);
        res.text.should.equal('"pong"');
        done();
      });
  });
  it('should use a catch all route on other requests', function(done) {
    chai.request(base_url)
      .get('/foo')
      .end(function(err, res) {
        res.should.have.status(200);
        res.type.should.equal('text/json');
        JSON.parse(res.text).exception.should.equal('catch all route');
        done();
      });
  });
});

{'fraction_non_alphanumeric': 0.1882193635748138, 'fraction_numerical': 0.012863913337846988, 'mean_word_length': 3.2456896551724137, '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': '6560407', 'n_tokens_mistral': 1012, 'n_tokens_neox': 971, 'n_words': 197}