<commit_before>// Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
(function () {
    "use strict";

    module.exports = function (grunt) {
        var config = require("../config.js");

        grunt.registerTask("test", function () {
            if (config.inRazzle) {
                grunt.task.run(["default", "clean:qunit", "shell:runTests"]);
            } else {
                grunt.task.run(["default", "connect:localhost"]);
            }
        });

        // Generate QUnit test pages
        grunt.registerTask("build-qunit", function () {
            var fs = require("fs");

            function extractDependencies(path) {
                var fileContents = fs.readFileSync(path, "utf-8");
                var dir = path.substring(0, path.lastIndexOf("/"));
                var deps = [];

                var lines = fileContents.split("\n");
                for (var i = 0; i < lines.length; i++) {
                    var line = lines[i];
                    var processedOne = false;
                    if (line.indexOf("<reference") < 0 || line.indexOf("ms-appx") >= 0) {
                        if (processedOne) {
                            break;
                        } else {
                            continue;
                        }
                    }

                    var startIndex = line.indexOf('path="') + 6;
                    var endIndex = line.indexOf('"', startIndex);
                    var path = dir + "/" + line.substring(startIndex, endIndex);
                    if (!fs.existsSync(path)) {
                        grunt.fail.warn("Could not find dependency:\n" + line + "in file:\n" + path);
                    }
                    deps.push(path);

                    processedOne = true;
                }
                return deps;
            }

            function arrayIndexOf(arr, obj) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i] === obj) {
                        return i;
                    }
                }
                return -1;
            }
<commit_msg>Fixed the test build to correctly check for case correctness in dependencies.<commit_after>// Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
(function () {
    "use strict";

    module.exports = function (grunt) {
        var config = require("../config.js");

        grunt.registerTask("test", function () {
            if (config.inRazzle) {
                grunt.task.run(["default", "clean:qunit", "shell:runTests"]);
            } else {
                grunt.task.run(["default", "connect:localhost"]);
            }
        });

        // Generate QUnit test pages
        grunt.registerTask("build-qunit", function () {
            var fs = require("fs");

            function extractDependencies(path) {
                // This function extracts the <reference path="..." /> tags in test files and returns their real paths.
                var fileContents = fs.readFileSync(path, "utf-8");
                var dir = path.substring(0, path.lastIndexOf("/"));
                var deps = [];

                var lines = fileContents.split("\n");
                var processedOne = false;
                for (var i = 0; i < lines.length; i++) {
                    var line = lines[i];
                    if (line.indexOf("<reference") < 0 || line.indexOf("ms-appx") >= 0) {
                        if (processedOne) {
                            // If we already processed a reference tag before and this line is not a reference tag,
                            // then we must be past the reference portion of the test file and can break here.
                            break;
                        } else {
                            // If we haven't processed any reference tags, then we could be looking at a blank line,
                            // or copyright line, or some other file header line; skip and continue with the next line.
                            continue;
                        }
                    }

                    // Extract the relative path from the reference tag.
                    var startIndex = line.indexOf('path="') + 6;
                    var endIndex = line.indexOf('"', startIndex);
                    var path = dir + "/" + line.substring(startIndex, endIndex);

                    // realpathSync will abort the build if the file can't be resolved.
                    var fullPath = fs.realpathSync(path);
                    fullPath = fullPath.replace(/\\/g, "/");

                    // This part checks if the filepath is correctly cased by walking the path starting
                    // from the repository root and comparing each step with the directory listing.
                    var rootFolder = "winjs/tests/";
                    var split = fullPath.split(rootFolder);
                    var steps = split[1].split("/");
                    var csPath = split[0] + rootFolder;
                    while (steps.length) {
                        var step = steps[0];
                        var files = fs.readdirSync(csPath);
                        if (files.indexOf(step) < 0) {
                            grunt.fail.warn("Incorrect casing for:\n" + line + "in file:\n" + fullPath + "\nstep: " + step);
                        }
                        csPath += "/" + step;
                        steps = steps.slice(1);
                    }
                    deps.push(path);
                    processedOne = true;
                }
                return deps;
            }

            function arrayIndexOf(arr, obj) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i] === obj) {
                        return i;
                    }
                }
                return -1;
            }

{'fraction_non_alphanumeric': 0.109141637945183, 'fraction_numerical': 0.004103069095683571, 'mean_word_length': 1.2039783001808317, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 6, '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': '7006375', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1404, 'n_words': 441}