<commit_before>/*global afterEach, beforeEach, describe, it */
'use strict';

var assert = require('assert');
var binCheck = require('bin-check');
var BinWrapper = require('bin-wrapper');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var rm = require('rimraf');

describe('optipng()', function () {
    afterEach(function (cb) {
        rm(path.join(__dirname, 'tmp'), cb);
    });

    beforeEach(function (cb) {
        fs.mkdir(path.join(__dirname, 'tmp'), cb);
    });

    it('should rebuild the mozjpeg binaries', function (cb) {
        var bin = new BinWrapper({ bin: 'jpegtran', dest: path.join(__dirname, 'tmp') });
        var bs = 'autoreconf -fiv && ./configure --prefix="' + bin.dest +
                 '" --bindir="' + bin.dest + '" --libdir="' + bin.dest + '" && make && make install';

        bin
            .addSource('https://github.com/mozilla/mozjpeg/archive/v1.0.1.tar.gz')
            .build(bs)
            .on('finish', function () {
                cb(assert(true));
            });
    });

    it('should return path to binary and verify that it is working', function (cb) {
        var binPath = require('../').path;

        binCheck(binPath, '--version', function (err, works) {
            cb(assert.equal(works, true));
        });
    });

    it('should minify a JPEG', function (cb) {
        var binPath = require('../').path;
        var args = [
            '-optimize',
            '-outfile', path.join(__dirname, 'tmp/test.jpg'),
            path.join(__dirname, 'fixtures', 'test.jpg')
        ];

        spawn(binPath, args).on('close', function () {
            var src = fs.statSync(path.join(__dirname, 'fixtures/test.jpg')).size;
            var dest = fs.statSync(path.join(__dirname, 'tmp/test.jpg')).size;

            assert(dest < src);
            assert(dest > 0);
            cb();
        });
    });
});
<commit_msg>Fix tests<commit_after>/*global afterEach, beforeEach, describe, it */
'use strict';

var assert = require('assert');
var binCheck = require('bin-check');
var BinWrapper = require('bin-wrapper');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var rm = require('rimraf');

describe('optipng()', function () {
    afterEach(function (cb) {
        rm(path.join(__dirname, 'tmp'), cb);
    });

    beforeEach(function (cb) {
        fs.mkdir(path.join(__dirname, 'tmp'), cb);
    });

    it('should rebuild the mozjpeg binaries', function (cb) {
        var bin = new BinWrapper({ bin: 'jpegtran', dest: path.join(__dirname, 'tmp') });
        var bs = 'autoreconf -fiv && ./configure --prefix="' + bin.dest +
                 '" --bindir="' + bin.dest + '" --libdir="' + bin.dest + '" && make && make install';

        bin
            .addSource('https://github.com/mozilla/mozjpeg/archive/v1.0.1.tar.gz')
            .build(bs)
            .on('finish', function () {
                cb(assert(true));
            });
    });

    it('should return path to binary and verify that it is working', function (cb) {
        var binPath = require('../').path;
        var args = [
            '-outfile', path.join(__dirname, 'tmp/test.jpg'),
            path.join(__dirname, 'fixtures/test.jpg')
        ];

        binCheck(binPath, args, function (err, works) {
            cb(assert.equal(works, true));
        });
    });

    it('should minify a JPEG', function (cb) {
        var binPath = require('../').path;
        var args = [
            '-outfile', path.join(__dirname, 'tmp/test.jpg'),
            path.join(__dirname, 'fixtures', 'test.jpg')
        ];

        spawn(binPath, args).on('close', function () {
            var src = fs.statSync(path.join(__dirname, 'fixtures/test.jpg')).size;
            var dest = fs.statSync(path.join(__dirname, 'tmp/test.jpg')).size;

            assert(dest < src);
            assert(dest > 0);
            cb();
        });
    });
});

{'fraction_non_alphanumeric': 0.1838124054462935, 'fraction_numerical': 0.002017145738779627, 'mean_word_length': 2.2278275020341742, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1010788', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1183, 'n_words': 273}