<commit_before>var fs = require('fs');
var path = require('path');
var glob = require('glob');
var mkdirp = require('mkdirp');
var tmp = require('tmp');
var checkSyntaxError = require('syntax-error');
var syntaxError = false;
var Cucumber = require.main.require('cucumber/lib/cucumber');
var configuration = Cucumber.Cli.Configuration({
   snippets: true,
   useColors: true,
   format: ['summary']
}, []);
var tempTestFolder = tmp.dirSync({ unsafeCleanup: true });
var cucumber = {
    path: tempTestFolder.name,
    features: {}
};
var runtime;

tmp.setGracefulCleanup();

function getFeatureSources() {
    var featureSources = [];

    glob.sync("features/**/*.feature").forEach(function(file) {
        featureSources.push([path.resolve(process.cwd(), file), fs.readFileSync(file)]);
    });

    return featureSources;
}

function getSupportCodeInitializer() {
    return function() {
        var files = [],
            supportCodeHelper = this;

        glob.sync("step-definitions/**/*.js").forEach(function(file) {
            files.push(path.resolve(process.cwd(), file));
        });

        files.forEach(function(file) {
            var initializer,
                src = fs.readFileSync(file),
                err = checkSyntaxError(src, file);

            if (err) {
                console.error(err);
                syntaxError = true;
                return;
            }

            initializer = require(file);

            if (typeof(initializer) === 'function')
                initializer.call(supportCodeHelper);
        });
    };
}

function getStepExecutor(step) {
    var stepDefinitions = runtime.getSupportCodeLibrary().lookupStepDefinitionsByName(step.getName());
    var getStep = function() { return step; };
    var formatter = configuration.getFormatters()[0];
    var colors = Cucumber.Util.Colors(true);

    if (!stepDefinitions || stepDefinitions.length == 0) {
        formatter.storeUndefinedStepResult({getStep: getStep});
        formatter.log(colors.pending('Undefined steps found!'));
        formatter.logUndefinedStepSnippets();
        return;
    }

    if (stepDefinitions.length > 1) {
        formatter.storeAmbiguousStepResult({getStep: getStep, getAmbiguousStepDefinitions: function() {
            return stepDefinitions;
        }});
        formatter.log(colors.ambiguous('Ambiguous steps found!'));
        formatter.logAmbiguousSteps();
        return;
    }

    return function (context, callback) {
        stepDefinitions[0].invoke(step, context, {getAttachments: function(){}}, 60000, callback);
    }
}

function getFeatureTags(feature) {
    return feature.getTags().map(function(tag) {
        return tag.getName().replace(/^@/, '');
    });
}

function discoverScenario(feature, scenario, steps) {
    var tags;

    if (!feature.discovered) {
        feature.discovered = {};
        cucumber.features[feature.getName()] = feature.discovered;

        tags = getFeatureTags(feature);

        if (tags.length) {
            feature.discovered['@tags'] = tags;
        }
    }

    feature.discovered[scenario.getName()] = function(browser) {
        steps.forEach(function(step) {
            step(browser, function(result) {
                if (result.getStatus() === Cucumber.Status.FAILED) {
                    console.log(result.getFailureException());
                }
            })
        });
        browser.end();
    };
}

function createTestFile(feature) {
    var testFileSource = 'module.exports = require("' + __filename + '").features["' + feature.getName() + '"];';
    var testFilePath = path.join(tempTestFolder.name, path.relative('features', feature.getUri())).replace(/\.[^/.]+$/, '.js');

    mkdirp.sync(path.dirname(testFilePath));
    fs.writeFileSync(testFilePath, testFileSource);
}<commit_msg>Fix path issue on Windows. Fixes #24<commit_after>var fs = require('fs');
var path = require('path');
var glob = require('glob');
var mkdirp = require('mkdirp');
var tmp = require('tmp');
var checkSyntaxError = require('syntax-error');
var syntaxError = false;
var Cucumber = require.main.require('cucumber/lib/cucumber');
var configuration = Cucumber.Cli.Configuration({
   snippets: true,
   useColors: true,
   format: ['summary']
}, []);
var tempTestFolder = tmp.dirSync({ unsafeCleanup: true });
var cucumber = {
    path: tempTestFolder.name,
    features: {}
};
var runtime;

tmp.setGracefulCleanup();

function getFeatureSources() {
    var featureSources = [];

    glob.sync("features/**/*.feature").forEach(function(file) {
        featureSources.push([path.resolve(process.cwd(), file), fs.readFileSync(file)]);
    });

    return featureSources;
}

function getSupportCodeInitializer() {
    return function() {
        var files = [],
            supportCodeHelper = this;

        glob.sync("step-definitions/**/*.js").forEach(function(file) {
            files.push(path.resolve(process.cwd(), file));
        });

        files.forEach(function(file) {
            var initializer,
                src = fs.readFileSync(file),
                err = checkSyntaxError(src, file);

            if (err) {
                console.error(err);
                syntaxError = true;
                return;
            }

            initializer = require(file);

            if (typeof(initializer) === 'function')
                initializer.call(supportCodeHelper);
        });
    };
}

function getStepExecutor(step) {
    var stepDefinitions = runtime.getSupportCodeLibrary().lookupStepDefinitionsByName(step.getName());
    var getStep = function() { return step; };
    var formatter = configuration.getFormatters()[0];
    var colors = Cucumber.Util.Colors(true);

    if (!stepDefinitions || stepDefinitions.length == 0) {
        formatter.storeUndefinedStepResult({getStep: getStep});
        formatter.log(colors.pending('Undefined steps found!'));
        formatter.logUndefinedStepSnippets();
        return;
    }

    if (stepDefinitions.length > 1) {
        formatter.storeAmbiguousStepResult({getStep: getStep, getAmbiguousStepDefinitions: function() {
            return stepDefinitions;
        }});
        formatter.log(colors.ambiguous('Ambiguous steps found!'));
        formatter.logAmbiguousSteps();
        return;
    }

    return function (context, callback) {
        stepDefinitions[0].invoke(step, context, {getAttachments: function(){}}, 60000, callback);
    }
}

function getFeatureTags(feature) {
    return feature.getTags().map(function(tag) {
        return tag.getName().replace(/^@/, '');
    });
}

function discoverScenario(feature, scenario, steps) {
    var tags;

    if (!feature.discovered) {
        feature.discovered = {};
        cucumber.features[feature.getName()] = feature.discovered;

        tags = getFeatureTags(feature);

        if (tags.length) {
            feature.discovered['@tags'] = tags;
        }
    }

    feature.discovered[scenario.getName()] = function(browser) {
        steps.forEach(function(step) {
            step(browser, function(result) {
                if (result.getStatus() === Cucumber.Status.FAILED) {
                    console.log(result.getFailureException());
                }
            })
        });
        browser.end();
    };
}

function createTestFile(feature) {
    var selfPath = __filename.split(path.sep).join('/');
    var testFileSource = 'module.exports = require("' + selfPath + '").features["' + feature.getName() + '"];';
    var testFilePath = path.join(tempTestFolder.name, path.relative('features', feature.getUri())).replace(/\.[^/.]+$/, '.js');

    mkdirp.sync(path.dirname(testFilePath));
    fs.writeFileSync(testFilePath, testFileSource);
}
{'fraction_non_alphanumeric': 0.14695153725898905, 'fraction_numerical': 0.0026055237102657635, 'mean_word_length': 2.8004950495049505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2662554', 'n_tokens_mistral': 2233, 'n_tokens_neox': 2128, 'n_words': 387}