<commit_before>'use strict';

var fs = require('fs-extra');
var path = require('path');
var RSVP = require('rsvp');
var expect = require('chai').expect;
var walkSync = require('walk-sync');
var broccoli = require('broccoli-builder');
var rimraf = RSVP.denodeify(require('rimraf'));
var fixturify = require('fixturify');

require('mocha-jshint')({
  paths: [
    'tests/index.js',
    'index.js'
  ]
});

var Funnel = require('..');

describe('broccoli-funnel', function(){
  var builder;
  var FIXTURE_INPUT = path.resolve(__dirname, '../tmp/INPUT');

  beforeEach(function() {
    fs.mkdirpSync(FIXTURE_INPUT);
    fixturify.writeSync(FIXTURE_INPUT, {
      dir1: {
        subdir1: {
          subsubdir1: {
            'foo.png': ''
          },
          subsubdir2: {
            'some.js': ''
          }
        },
        subdir2: {
          'bar.css': ''
        },
        'root-file.txt': ''
      },
      lib: {
        utils: {
          'foo.js': ''
        },
        'utils.js': '',
        'main.js': ''
      }
    });
  });

  afterEach(function() {
    fs.removeSync(FIXTURE_INPUT);
    if (builder) {
      return builder.cleanup();
    }
  });

  describe('rebuilding', function() {
    it('correctly rebuilds', function() {
      var inputPath = FIXTURE_INPUT + '/dir1';
      var node = new Funnel(FIXTURE_INPUT + '/dir1', {
        include: ['**/*.js']
      });

      builder = new broccoli.Builder(node);
      return builder.build()
        .then(function(results) {
          var outputPath = results.directory;

          expect(walkSync(outputPath, ['**/*.js'])).to.eql(walkSync(inputPath, ['**/*.js']));

          var mutatedFile = inputPath + '/subdir1/subsubdir2/some.js';
          fs.writeFileSync(mutatedFile, fs.readFileSync(mutatedFile));
          return builder.build();
        })
        .then(function(results) {
          var outputPath = results.directory;

          expect(walkSync(outputPath, ['**/*.js'])).to.eql(walkSync(inputPath, ['**/*.js']));
        });
    });
  });

  describe.only('linkRoots', function() {
    it('links input to output if possible', function() {<commit_msg>remove only<commit_after>'use strict';

var fs = require('fs-extra');
var path = require('path');
var RSVP = require('rsvp');
var expect = require('chai').expect;
var walkSync = require('walk-sync');
var broccoli = require('broccoli-builder');
var rimraf = RSVP.denodeify(require('rimraf'));
var fixturify = require('fixturify');

require('mocha-jshint')({
  paths: [
    'tests/index.js',
    'index.js'
  ]
});

var Funnel = require('..');

describe('broccoli-funnel', function(){
  var builder;
  var FIXTURE_INPUT = path.resolve(__dirname, '../tmp/INPUT');

  beforeEach(function() {
    fs.mkdirpSync(FIXTURE_INPUT);
    fixturify.writeSync(FIXTURE_INPUT, {
      dir1: {
        subdir1: {
          subsubdir1: {
            'foo.png': ''
          },
          subsubdir2: {
            'some.js': ''
          }
        },
        subdir2: {
          'bar.css': ''
        },
        'root-file.txt': ''
      },
      lib: {
        utils: {
          'foo.js': ''
        },
        'utils.js': '',
        'main.js': ''
      }
    });
  });

  afterEach(function() {
    fs.removeSync(FIXTURE_INPUT);
    if (builder) {
      return builder.cleanup();
    }
  });

  describe('rebuilding', function() {
    it('correctly rebuilds', function() {
      var inputPath = FIXTURE_INPUT + '/dir1';
      var node = new Funnel(FIXTURE_INPUT + '/dir1', {
        include: ['**/*.js']
      });

      builder = new broccoli.Builder(node);
      return builder.build()
        .then(function(results) {
          var outputPath = results.directory;

          expect(walkSync(outputPath, ['**/*.js'])).to.eql(walkSync(inputPath, ['**/*.js']));

          var mutatedFile = inputPath + '/subdir1/subsubdir2/some.js';
          fs.writeFileSync(mutatedFile, fs.readFileSync(mutatedFile));
          return builder.build();
        })
        .then(function(results) {
          var outputPath = results.directory;

          expect(walkSync(outputPath, ['**/*.js'])).to.eql(walkSync(inputPath, ['**/*.js']));
        });
    });
  });

  describe('linkRoots', function() {
    it('links input to output if possible', function() {
{'fraction_non_alphanumeric': 0.1833294310465933, 'fraction_numerical': 0.00421446967923203, 'mean_word_length': 2.3296960249415433, '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': '863570', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1385, 'n_words': 233}