iamchrismiller / grunt-casper

Run CasperJS Scripts/Functional Tests
Other
69 stars 38 forks source link

Casper test does not run in parallel #32

Closed shsnyder closed 10 years ago

shsnyder commented 10 years ago

Chris, thanks for the update to get casper test execution working. However, while the casper test works correctly, it only executes once, regardless of the number I use for the concurrency.

Scotts-MacBook-Pro-2:grunttest sh_snyder$ grunt --verbose casper:simpletest
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK

Registering "grunt-casper" local Npm module tasks.
Reading /Users/sh_snyder/Documents/grunttest/node_modules/grunt-casper/package.json...OK
Parsing /Users/sh_snyder/Documents/grunttest/node_modules/grunt-casper/package.json...OK
Loading "casper.js" tasks...OK
+ casper
Loading "Gruntfile.js" tasks...OK
+ default

Running tasks: casper:simpletest

Running "casper:simpletest" (casper) task
Verifying property casper.simpletest exists in config...OK
Files: simple.js
Options: log-level="debug", test, parallel, concurrency=3
Arguments: (none)
Preparing casperjs spawn
Adding Option --log-level=debug
Spawning casperjs with args: test,simple.js,--verbose,--log-level=debug
Test file: simple.js
Opened page with title "Google"
Casper Task 'casper:simpletest' took ~3369ms to run

Done, without errors.

I was looking at the grunt-casper source and the call that is supposed to execute the calls in parallel "grunt.util.async.forEachLimit" is expecting an array of files as the first parameter. When I instrumented the async.forEachLimit call in async.js I see that once the initial call is made, the number of completed calls is compared to the file array length.

                    if (err) {
                        callback(err);
                        callback = function () {};
                    }
                    else {
                        completed += 1;
                        running -= 1;
                        if (completed === arr.length) {
                            callback();
                        }
                        else {
                            replenish();
                        }
                    }

Since that is 1, the function exits after one call. Perhaps there is another async call that is more appropriate. Let me know if I can help with debugging.

iamchrismiller commented 10 years ago

It is functioning as expected. It runs multiple test files in parallel where you can then set the concurrency. I have a test for it in the Gruntfile grunt casper:parallel which has 5 test files and a concurrency of 5 and it passes as expected.