<commit_before>"use strict";

/*globals describe it */
const should = require("should");
const path = require("path");
const fs = require("fs");

const webpack = require("../lib/webpack");

const base = path.join(__dirname, "statsCases");
const outputBase = path.join(__dirname, "js", "stats");
const tests = fs.readdirSync(base).filter(testName =>
	fs.existsSync(path.join(base, testName, "index.js")) ||
	fs.existsSync(path.join(base, testName, "webpack.config.js"))
);
const Stats = require("../lib/Stats");

describe("Stats", () => {
	tests.forEach(testName => {
		it("should print correct stats for " + testName, (done) => {
			let options = {
				entry: "./index",
				output: {
					filename: "bundle.js"
				}
			};
			if(fs.existsSync(path.join(base, testName, "webpack.config.js"))) {
				options = require(path.join(base, testName, "webpack.config.js"));
			}
			(Array.isArray(options) ? options : [options]).forEach((options) => {
				if(!options.context) options.context = path.join(base, testName);
				if(!options.output) options.output = options.output || {};
				if(!options.output.path) options.output.path = path.join(outputBase, testName);
			});
			const c = webpack(options);
			const compilers = c.compilers ? c.compilers : [c];
			compilers.forEach((c) => {
				const ifs = c.inputFileSystem;
				c.inputFileSystem = Object.create(ifs);
				c.inputFileSystem.readFile = () => {
					const args = Array.prototype.slice.call(arguments);
					const callback = args.pop();
					ifs.readFile.apply(ifs, args.concat([(err, result) => {
						if(err) return callback(err);
						callback(null, result.toString("utf-8").replace(/\r/g, ""));<commit_msg>fixup function to be able to use arguments<commit_after>/*globals describe it */
"use strict";

require("should");
const path = require("path");
const fs = require("fs");

const webpack = require("../lib/webpack");

const base = path.join(__dirname, "statsCases");
const outputBase = path.join(__dirname, "js", "stats");
const tests = fs.readdirSync(base).filter(testName =>
	fs.existsSync(path.join(base, testName, "index.js")) ||
	fs.existsSync(path.join(base, testName, "webpack.config.js"))
);
const Stats = require("../lib/Stats");

describe("Stats", () => {
	tests.forEach(testName => {
		it("should print correct stats for " + testName, (done) => {
			let options = {
				entry: "./index",
				output: {
					filename: "bundle.js"
				}
			};
			if(fs.existsSync(path.join(base, testName, "webpack.config.js"))) {
				options = require(path.join(base, testName, "webpack.config.js"));
			}
			(Array.isArray(options) ? options : [options]).forEach((options) => {
				if(!options.context) options.context = path.join(base, testName);
				if(!options.output) options.output = options.output || {};
				if(!options.output.path) options.output.path = path.join(outputBase, testName);
			});
			const c = webpack(options);
			const compilers = c.compilers ? c.compilers : [c];
			compilers.forEach((c) => {
				const ifs = c.inputFileSystem;
				c.inputFileSystem = Object.create(ifs);
				c.inputFileSystem.readFile = function() {
					const args = Array.prototype.slice.call(arguments);
					const callback = args.pop();
					ifs.readFile.apply(ifs, args.concat([(err, result) => {
						if(err) return callback(err);
						callback(null, result.toString("utf-8").replace(/\r/g, ""));
{'fraction_non_alphanumeric': 0.18498659517426275, 'fraction_numerical': 0.0005957700327673518, 'mean_word_length': 4.011940298507462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '4075593', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1078, 'n_words': 214}