Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the grunt execution is stuck #71

Closed
p3x-robot opened this issue Oct 6, 2017 · 11 comments
Closed

the grunt execution is stuck #71

p3x-robot opened this issue Oct 6, 2017 · 11 comments

Comments

@p3x-robot
Copy link

Ciao!
How are you today?

It is very weird. I use it in like 33 projects, but I have a repo patrikx3/corifeus-builder-angular and it just stuck, it waits for something but I do not know what it does. Like 2 weeks ago it was working, not it is stuck.

All that happens is this:

patrikx3@workstation:~/Projects/patrikx3/corifeus/corifeus-builder-angular$ grunt mocha_istanbul:cory-coverage -v --force
Initializing
Command-line options: --verbose, --force

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Loading "Gruntfile.js" tasks...OK
+ cory-angular-generator, cory-build-run, cory-ensure-protractor, cory-generate-tasks, cory-generate-tasks-generator, cory-inject, cory-json2scss, cory-noop, cory-npm, cory-replace, cory-test, default

Running tasks: mocha_istanbul:cory-coverage

Loading "grunt-mocha-istanbul" plugin

Registering "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/node_modules/grunt-mocha-istanbul/tasks" tasks.
Loading "index.js" tasks...OK
+ istanbul_check_coverage, mocha_istanbul

Running "mocha_istanbul:cory-coverage" (mocha_istanbul) task
Verifying property mocha_istanbul.cory-coverage exists in config...OK
Files: /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/, /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/test/mocha/
Options: require=[], ui=false, globals=[], reporter=false, timeout=false, coverage=false, slow=false, includes=["/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/bin/**","/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/**","/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/test/mocha/**"], grep=false, dryRun=false, quiet=false, recursive=false, mask="**/*.js", root=false, print=false, noColors=false, harmony=false, coverageFolder="build/coverage/", cwd="/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular", reportFormats=["clover","html","text"], check={"statements":false,"lines":false,"functions":false,"branches":false}, excludes=false, mochaOptions=false, istanbulOptions=false, nodeOptions=false, nodeExec="/usr/bin/node"
>> Skipping empty options.require array
>> Skipping empty options.globals array
>> Will execute: /usr/bin/node /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/node_modules/istanbul/lib/cli.js cover -i /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/bin/** -i /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/** -i /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/test/mocha/** --dir /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/build/coverage/ --report clover --report html --report text /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/node_modules/mocha/bin/_mocha -- /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/**/*.js /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/test/mocha/**/*.js


  CI
    ✓ test


  1 passing (7ms)

That's it and it doesn't go to the next task in grunt.

Do you have an idea what it could be?

In the patrikx3/corifues-builder it is the exact structure and it works:

patrikx3@workstation:~/Projects/patrikx3/corifeus/corifeus-builder$ grunt
Running "generate-folder" task

Running "cory-generate-tasks" task

Running "cory-ensure-protractor" task
Protractor is not on the path
Running "cory-npm" task

Running "clean:cory-build" (clean) task
>> 1 path cleaned.

Running "mocha_istanbul:cory-coverage" (mocha_istanbul) task


  async/await
    ✓ main (753ms)

  src/git
commit: 159
branch: master
date: 1507308108
repo: corifeus-builder
    ✓ branch / data / commit / repo

  src/task/json2scss
    ✓ default

  src/task/npm/exec
new name: corifeus-builder
old name: corifeus-builder
new version: 1.7.877-160
old version: 1.7.876-160
    ✓ default

  src/task/replace
    ✓ default


  5 passing (810ms)

-----------------------|----------|----------|----------|----------|----------------|
File                   |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-----------------------|----------|----------|----------|----------|----------------|
All files              |    52.39 |    27.66 |       28 |    52.14 |                |
 src                   |    27.38 |     2.63 |    33.33 |       25 |                |
  git.js               |      100 |       50 |      100 |      100 |             10 |
  index.js             |      100 |      100 |      100 |      100 |                |
  loader.js            |     7.58 |        0 |        0 |     7.69 |... 238,242,243 |
 src/config            |    71.43 |      100 |        0 |    71.43 |                |
  index.js             |    71.43 |      100 |        0 |    71.43 |            5,6 |
 src/config/folder     |      100 |      100 |      100 |      100 |                |
  index.js             |      100 |      100 |      100 |      100 |                |
 src/config/grunt      |      100 |      100 |      100 |      100 |                |
  index.js             |      100 |      100 |      100 |      100 |                |
 src/config/grunt/js   |       60 |      100 |        0 |       60 |                |
  index.js             |       60 |      100 |        0 |       60 |          6,101 |
 src/config/grunt/ts   |    46.15 |      100 |        0 |    46.15 |                |
  index.js             |    46.15 |      100 |        0 |    46.15 |... 24,46,48,63 |
 src/config/task       |    88.46 |       50 |      100 |    88.46 |                |
  index.js             |    88.46 |       50 |      100 |    88.46 |       46,47,50 |
 src/task              |    18.42 |        0 |        0 |    18.42 |                |
  ensure-protractor.js |    16.67 |        0 |        0 |    16.67 |... 26,28,30,31 |
  generate-tasks.js    |     12.5 |        0 |        0 |     12.5 |... 19,20,24,34 |
  index.js             |      100 |      100 |      100 |      100 |                |
  noop.js              |    33.33 |      100 |        0 |    33.33 |            2,3 |
 src/task/inject       |    22.73 |        0 |        0 |    22.73 |                |
  index.js             |       25 |        0 |        0 |       25 |   4,5,6,7,9,10 |
  inject.js            |    22.22 |        0 |        0 |    22.22 |... 47,48,49,51 |
 src/task/json2scss    |    80.49 |       75 |     62.5 |    80.49 |                |
  index.js             |       25 |        0 |        0 |       25 |  4,6,7,8,10,11 |
  json2scss.js         |    93.94 |    85.71 |      100 |    93.94 |          16,32 |
 src/task/npm          |    74.36 |       60 |    33.33 |    74.36 |                |
  index.js             |       25 |      100 |        0 |       25 |   4,5,6,7,8,10 |
  npm.js               |     87.1 |       60 |      100 |     87.1 |    18,19,31,39 |
 src/task/replace      |    71.79 |     62.5 |     37.5 |    71.79 |                |
  index.js             |       25 |        0 |        0 |       25 |  5,7,8,9,11,12 |
  replace.js           |    83.87 |    83.33 |       60 |    83.87 | 65,67,69,70,74 |
-----------------------|----------|----------|----------|----------|----------------|

=============================== Coverage summary ===============================
Statements   : 52.39% ( 186/355 )
Branches     : 27.66% ( 26/94 )
Functions    : 28% ( 14/50 )
Lines        : 52.14% ( 183/351 )
================================================================================
>> Done. Check coverage folder.

Running "cory-replace" task
Replaced: README.md, Pre:  #@corifeus-header, Post:  #@corifeus-header:end
Replaced: artifacts/readme/builds/folders.md, Pre:  #@corifeus-header, Post:  #@corifeus-header:end
Replaced: artifacts/readme/builds/tasks.md, Pre:  #@corifeus-header, Post:  #@corifeus-header:end
Replaced: artifacts/readme/builds/folders.md, Pre:  #@corifeus-footer, Post:  #@corifeus-footer:end
Replaced: artifacts/readme/builds/tasks.md, Pre:  #@corifeus-footer, Post:  #@corifeus-footer:end

Done.


Execution Time (2017-10-06 18:46:09 UTC+2)
mocha_istanbul:cory-coverage  1.8s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 97%
Total 1.9s

No idea it is stuck. :(

With

./node_modules/.bin/istanbul cover node_modules/mocha/bin/_mocha --report clover -- -R spec test/mocha/**/*.js

It works though, just shows no coverage.

@p3x-robot
Copy link
Author

OK, I found the error. it is a webpack folder the src, it is like this:

   coverage.src = [
            `${process.cwd()}/${builder.config.folder.src.root}config/grunt/**`,
            `${process.cwd()}/${builder.config.folder.src.root}config/karma/**`,
            `${process.cwd()}/${builder.config.folder.src.root}config/protractor/**`,
//            `${process.cwd()}/${builder.config.folder.src.root}config/webpack/**`,
            `${process.cwd()}/${builder.config.folder.src.root}task/**`,
            `${process.cwd()}/${builder.config.folder.test.mocha.root}**`
        ];

Is there an exclude in the coverage.src ?
In Istanbul it works, but for me the problem is that src which is not related to Istanbul, I guess it should be in mocha somewhere?

@p3x-robot
Copy link
Author

I added this:

{
    "cory-coverage": {
        "src": [
            "!/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/config/webpack",
            "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/bin/",
            "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/",
            "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/test/mocha/"
        ],
        "options": {
            "mask": "**/*.js",
            "includes": [
                "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/bin/**",
                "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/src/**",
                "/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder-angular/test/mocha/**"
            ],
            "coverageFolder": "build/coverage/",
            "reportFormats": [
                "clover",
                "html",
                "text"
            ]
        }
    }
}

But it doesn't allow me to exclude with ! .
Is there an options like that?

@p3x-robot
Copy link
Author

p3x-robot commented Oct 6, 2017

I found the file that stops, do you have an idea why it stops the processing?

(function(window, document, navigator) {
    'use strict';
    if (window.corifeusCssFiles === undefined && window.corifeusScriptFiles === undefined) {
        window.corifeusCssFiles = [];
        window.corifeusScriptFiles = [];
    }
    window.corifeus = {
        booted: false,
        core: {
            http: {
                counter: 0
            }
        }
    }
    window.corifeusPreloader = {
        wait: navigator.userAgent === 'corifeus-server-renderer',
        status: {
            corifeus: window.corifeus
        }
    }

    'GENERATED-HEAD';

    if (!document.getElementById) {
        document.getElementById = function() {};
    }

    var cssFiles = window.corifeusCssFiles;
    var scriptFiles = window.corifeusScriptFiles;
    var files = cssFiles.concat(scriptFiles);
    var progress = {};
    var responseText = {};
    var started = new Date().getTime();

    function formatBytes(bytes,decimals) {
        if(bytes == 0) return '0 Byte';
        var k = 1000; // or 1024 for binary
        var dm = decimals + 1 || 3;
        var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
        var i = Math.floor(Math.log(bytes) / Math.log(k));
        return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
    }
    var formatTime = function(time) {
        var seconds = Math.floor(time / 1000);
        var minutes = Math.floor(seconds / 60);
        var hours = Math.floor(minutes / 60);
        var days = Math.floor(hours / 24);

        hours = hours - (days * 24);
        minutes = minutes - (days * 24 * 60) - (hours * 60);
        seconds = seconds - (days * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60);
        if (days < 10) days = '0' + days;
        if (hours < 10) hours = '0' + hours;
        if (minutes < 10) minutes = '0' + minutes;
        if (seconds < 10) seconds = '0' + seconds;

        var template = '';
        if (days != '00') {
            template += days + ':';
        }
        if (hours != '00' || days != '00') {
            template += hours + ':';
        }
        template += minutes + ':';
        template += seconds

        return template;
    }
    function loadFile(url) {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", url, true);
        xhr.onreadystatechange = function() {
            if (this.readyState == this.DONE) {
                responseText[url] = xhr.responseText;
                fire(true, this.responseText);
            }
        };
        xhr.onprogress = function(event) {
            progress[url] = event;
            fire();
        }
        xhr.send();
    }
    function iterate(cb) {
        for(var index = 0; index < files.length; index++) {
            var file = files[index];
            cb(file);
        }
    }
    function includesCss(file) {
        for(var index = 0; index < cssFiles.length; index++) {
            var cssFile = cssFiles[index];
            if (cssFile === file) {
                return true;
            }
        }
        return false;
    }
    var total = 0;
    var loaded = 0;
    var counter = 0;
    var totalDone = false;
    var frame = 33;
    var computable = true;
    var overlayPercent = function(percent) {
        document.getElementById('cory-loader-progress-overlay').style.height = Math.round(percent) + '%';
        document.getElementById('cory-loader-progress-overlay').style.width = '100%';
    }

    var loop = (function() {
        if (totalDone) {
            return;
        }
        if (document.getElementById('cory-loader-progress-bottom')) {
            var percentRaw = (loaded / total);
            var percent = (percentRaw * 100).toFixed(2);
            var totalMB = formatBytes(total, 1);
            var loadedMB = formatBytes(loaded, 1);
            if (isNaN(percent)) {
                percent = 0.5;
            }
            var current = new Date().getTime() - started;
            var maxTime = current / percent * 100;
            var left = maxTime - current;

            overlayPercent(percent);
            var top = document.getElementById('cory-loader-progress-top');
            var bottom = document.getElementById('cory-loader-progress-bottom');

            if (computable) {
                top.innerHTML = formatTime(left);
                bottom.innerHTML  = percent + '%' + '<div class="cory-loader-progress-info">' + loadedMB + ' / ' + totalMB + '</br>' + formatTime(current) + ' / ' + formatTime(maxTime) + '</div>';
            } else {
                top.innerHTML = '<div class="cory-loader-progress-info">gzip</div>';
                bottom.innerHTML = formatTime(current) + '</br></br>' + loadedMB;
            }
        }
        setTimeout(loop, frame);
    });
    loop();

    function fire(isDone) {
        total = 0;
        loaded = 0;
        iterate(function(file) {
            if (progress[file] !== undefined) {
                if (progress[file].lengthComputable === false) {
                    computable = false;
                    total += progress[file].loaded;
                } else {
                    total += progress[file].total;
                }
                loaded += progress[file].loaded;
            }
        })

        totalDone = isDone === true && ++counter == files.length;

    }
    var final = function() {
//        document.getElementById('cory-loader-progress-top').innerHTML = '<div></div>';
//        document.getElementById('cory-loader-progress-bottom').innerHTML = '<span class="cory-loader-progress-start">START</span>';
        overlayPercent(100);
        setTimeout(function() {
            iterate(function(file) {
                var body = document.querySelector('body');
                var head = document.querySelector('head');
                // it is important so that the css is in the head
                if (includesCss(file)) {
                    /*
                    var style = document.createElement('style');
                    style.type = 'text/css';
                    style.innerHTML = responseText[file];
                     head.appendChild(style)
                    */
                    var link = document.createElement('link');
                    link.rel = 'stylesheet';
                    link.href = file;
                    link.type = 'text/css';
                    head.appendChild(link);
                } else {
                    var script = document.createElement("script");
                    script.type = 'text/javascript';
                    script.defer = true;
                    script.src = file;
                    /*
                    script.innerHTML= responseText[file];
                    */
                    body.appendChild(script);
                }
            })
            var booted = function() {
                if (window.corifeus.booted === true) {
                    var removeMe = document.getElementById('cory-loader');
                    if (removeMe !== null) {
                        removeMe.parentNode.removeChild(removeMe);
                    }
                }
                else {
                    setTimeout(booted, 100);
                }

            }
            booted();
        }, frame)
    }

    iterate(function(file) {
        loadFile(file, fire)
    })

    var waitForDone = function() {
        if (totalDone && !window.corifeusPreloader.wait) {
            final();
            return;
        }
        window.corifeusPreloader.status.corifeus = window.corifeus;
        setTimeout(waitForDone, frame);
    }
    waitForDone();
})(typeof(window) === 'undefined' ? this : window, typeof(document) === 'undefined' ? {} : document, typeof(navigator) === 'undefined' ? { userAgent : 'corifeus-server-renderer'} : navigator);

@p3x-robot
Copy link
Author

This is a plugin client side function.

@pocesar
Copy link
Owner

pocesar commented Oct 7, 2017

weird, maybe it's a mocha issue, but the only line that is awkward "js-wise" speaking is 'GENERATED-HEAD';

@p3x-robot
Copy link
Author

yeah i removed it, but still it keeps the stuck. i guess mocha 4 changed something that i don't know.

@pocesar
Copy link
Owner

pocesar commented Oct 7, 2017

because this grunt plugin is actually just a "exec thin layer", with only a few utilities added, it's either mocha or istanbul that is crapping out

@siburny
Copy link

siburny commented Oct 9, 2017

I am having exact same issue. I pushed some minor change to my code today, and Travis is failing on all nodejs versions.

@siburny
Copy link

siburny commented Oct 9, 2017

@p3x-robot you are right: they changed a default behavior in v4 to not "exit" but rather let the test program end. So if you use some libraries and don't clean up after them, your test program will be stuck indefinitely. To change the behavior to be like v3, we need to add flag --exit to mocha runner.

#2879: By default, Mocha will no longer force the process to exit once all tests complete.
This means any test code (or code under test) which would normally prevent node from exiting
will do so when run in Mocha. Supply the --exit flag to revert to pre-v4.0.0 behavior (@ScottFreeCode, @boneskull)

More info: mochajs/mocha#2879

@p3x-robot
Copy link
Author

ahh. thanks

@p3x-robot
Copy link
Author

yeah, it works, just added 👍

 mocha_istanbul: {
            'cory-coverage': {
                src: [
//                    `${process.cwd()}/${folder.bin.root}` ,
                    `${process.cwd()}/${folder.src.root}` ,
                    `${process.cwd()}/${folder.test.mocha.root}`,
                ], // the folder, not the files
                options: {
                    mochaOptions: ['--exit'],
                    mask: '**/*.js',
                    includes: [
//                        `${process.cwd()}/${folder.bin.root}**` ,
                        `${process.cwd()}/${folder.src.root}**` ,
                        `${process.cwd()}/${folder.test.mocha.root}**`,
                    ],
                    /*
                    to add more local files, outside directories
                     mochaOptions: [
                         'cli.js'
                     ],
                     */
                    coverageFolder: folder.build.coverage.root,
                    reportFormats: [
                        'clover',
                        'html',
                        'text'
                    ]
                }
            }
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants