<commit_before>'use strict';

var pty = require('pty.js');

function Tui() {
  this.spawn = function(program, args, callback) {
    if(this.program) this.program.destroy();
    this.program = pty.spawn(program, args || [], {
      name: 'xterm-color',
      cols: 80,
      rows: 30,
      env: process.env
    });

    this.program.output = '';
    this.program.stdout.on('data', function(data) {
      this.program.output += data.toString('utf-8').replace('\\r', '');
    }.bind(this));

    this.program.on('exit', function() {
      callback();
    });
  };
}

module.exports = function() {
  this.World = Tui;
};
<commit_msg>gracefully timeout for ui tests<commit_after>'use strict';

var pty = require('pty.js');

function Tui() {
  this.spawn = function(program, args, callback) {
    // XXX temporary workaround for old version of node
    var exited = false;

    if(this.program) this.program.destroy();
    this.program = pty.spawn(program, args || [], {
      name: 'xterm-color',
      cols: 80,
      rows: 30,
      env: process.env
    });

    this.program.output = '';
    this.program.stdout.on('data', function(data) {
      this.program.output += data.toString('utf-8').replace('\\r', '');
    }.bind(this));

    this.program.on('exit', function() {
      exited = true;
      callback();
    });

    setTimeout(function() {
      if(!exited) return callback();
    }, 2000);
  };
}

module.exports = function() {
  this.World = Tui;
};

{'fraction_non_alphanumeric': 0.18767123287671234, 'fraction_numerical': 0.009589041095890411, 'mean_word_length': 2.765463917525773, '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': '1170445', 'n_tokens_mistral': 502, 'n_tokens_neox': 480, 'n_words': 96}