<commit_before>var buster = require("buster");
var watchTree = require("../lib/watch-tree-unix").watchTree;
var walkTree = require("../lib/walk-tree");
var helper = require("./helper");
var path = require("path");
var fs = require("fs");
var rmrf = require("rimraf");

function p(filePath) {
    return path.resolve(helper.ROOT, filePath);
}

function assertWatched(spy, path) {
    var i, l;
    for (i = 0, l = spy.callCount; i < l; ++i) {
        if (spy.getCall(i).args[0] === path) {
            buster.assertions.emit("pass");
            return true;
        }
    }

    var e = new Error("Expected " + path + " to be watched, but wasn't\n" +
                      spy.printf("%C"));
    e.name = "AssertionError";
    buster.assertions.emit("failure", e);
}

function watchTest(options) {
    return function (done) {
        var self = this;

        this.onWatch = function () {
            if (fs.watch.callCount === this.expectedCount) {
                setTimeout(function () {
                    options.assert.call(self);
                    done();
                }, 10);
            }
        };

        options.act.call(this);
    };
}

function eventTest(options) {
    return watchTest({
        act: function () {
            this.callback = this.spy();

            if (options.act) {
                options.act.call(this);
            } else {
                watchTree(helper.ROOT, this.callback);
            }
        },

        assert: function () {
            var ev = (options && options.event) || {};
            fs.watch.args[0][1](ev.type, ev.file);
            options.assert.call(this);
        }
    });
}

buster.testCase("watch-tree-unix", {
    setUp: function () {
        fs.mkdirSync(helper.ROOT, "0755");

        helper.mktreeSync({
            "a-dir": { a1: {}, a2: { a21: {}, a22: {}, a23: "" } },
            "b-dir": { b1: "", b2: "", b3: {}, b4: { b41: { b411: {} } } }<commit_msg>prevent the test to be executed on windows<commit_after>var buster = require("buster");
var watchTree = require("../lib/watch-tree-unix").watchTree;
var walkTree = require("../lib/walk-tree");
var helper = require("./helper");
var path = require("path");
var fs = require("fs");
var rmrf = require("rimraf");

function p(filePath) {
    return path.resolve(helper.ROOT, filePath);
}

function assertWatched(spy, path) {
    var i, l;
    for (i = 0, l = spy.callCount; i < l; ++i) {
        if (spy.getCall(i).args[0] === path) {
            buster.assertions.emit("pass");
            return true;
        }
    }

    var e = new Error("Expected " + path + " to be watched, but wasn't\n" +
                      spy.printf("%C"));
    e.name = "AssertionError";
    buster.assertions.emit("failure", e);
}

function watchTest(options) {
    return function (done) {
        var self = this;

        this.onWatch = function () {
            if (fs.watch.callCount === this.expectedCount) {
                setTimeout(function () {
                    options.assert.call(self);
                    done();
                }, 10);
            }
        };

        options.act.call(this);
    };
}

function eventTest(options) {
    return watchTest({
        act: function () {
            this.callback = this.spy();

            if (options.act) {
                options.act.call(this);
            } else {
                watchTree(helper.ROOT, this.callback);
            }
        },

        assert: function () {
            var ev = (options && options.event) || {};
            fs.watch.args[0][1](ev.type, ev.file);
            options.assert.call(this);
        }
    });
}

buster.testCase("watch-tree-unix", {
    
    requiresSupportFor: {
        "*nix": process.platform != "win32"
    },
    
    setUp: function () {
        fs.mkdirSync(helper.ROOT, "0755");

        helper.mktreeSync({
            "a-dir": { a1: {}, a2: { a21: {}, a22: {}, a23: "" } },
            "b-dir": { b1: "", b2: "", b3: {}, b4: { b41: { b411: {} } } }
{'fraction_non_alphanumeric': 0.17318295739348372, 'fraction_numerical': 0.014035087719298246, 'mean_word_length': 1.7948179271708684, 'pattern_counts': {'":': 5, '<': 5, '<?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': '5873464', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1245, 'n_words': 253}