-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Issues with grunt build, grunt test. #356
Comments
It's the end-of-line conversion in Windows. I fixed it with a
After a |
after a The same test still fails though, and now all my files are marked as changed due to the lf / crlf change |
In general when working on cross-platform projects you should set eol to lf and autocrlf to input: $ git config --global core.eol lf
$ git config --global core.autocrlf input and of course you should make sure you IDE is not messing up the line endings. I'd suggest making those config changes then doing a clean checkout. |
@domenic, thanks. That solved my lf/crlf issue correctly and is great advice in general. I still have problems with the tests. Do you have any suggestions? |
Can you pull latest master and try again? The test runner now outputs which file failed |
Thanks for not forgetting about the issue. I pulled, rebuilt and ran tests. It does show the filename it's running which is where the error occurs, but it's not always the same file. There's still a timeout error. So I ran it with --verbose and saw some errors - my first intuition was to xdescribe a few tests to see if I can pinpoint it:
when_reduce is inconsistent. Sometimes it would cause a failure, and sometimes it wouldn't, so I xdescribed it for consistency. Finally it 'all' passed... So I went to mocharun.js and changed the timeout to 1s, and started returning the tests. All in all it looks like the tests with the most inconsistency are the ones which use setTimeout in them. In our projects, we use jasmine and mock the clock. This way you won't rely on the actual time passing, so you can have consistent behavior in the tests. It should also allow the slower tests to run much faster. I hope this helps. |
That fake clock is synchronous. All the tests that use timers use it for the reason of emulating a real asynchronous operation taking the given amount of time. It is weird that the timeout of 500ms is not enough for your machine. |
Indeed it is weird. |
One thing, just to make sure, you are running these in command line, right? Because if you run in browser for example Chrome will make all timers have a 1000ms minimum time when the tab is not focused. |
Yea, running it through the CLI - grunt testrun (after I got fed up with the build each time during test). Regarding the clock- it's synchronous, but in your tests you want to emulate an asynchronous operation as well. I think emulating the clock should suffice for you. |
I'll write a fake asynchronous clock, stay tuned |
Sounds good 👍 I'm guessing you mean something like:
? |
I am just doing this in mochaRun.js: var currentTime = 0;
var timers = {};
var currentId = 0;
function checkTimers() {
Object.keys(timers).forEach(function(key) {
var timer = timers[key];
if (currentTime > timer.ends) {
delete timers[key];
timer.fn.call(global);
}
});
}
function setTimeout(fn, time) {
var id = currentId++;
time = (+time || 0) | 0;
if (time < 0) time = 0;
timers[id] = {
fn: fn,
ends: time + currentTime
};
return id;
}
function clearTimeout(id) {
delete timers[id];
}
(function tick() {
currentTime += 10;
checkTimers();
setImmediate(tick);
})();
global.setTimeout = setTimeout;
global.clearTimeout = clearTimeout; Seems to work great, all the tests run instantly for me :D Ill push it to master now |
looks good, except - setImmediate ? |
Well you can't call nextTick(tick) because it would crash to recursion |
yes but setImmediate is not cross-browser, so if you run the tests in browsers it might explode |
This file is not even used in browser tests, if it works for you i'll implement a similar thing for the browser runner as well |
👍 waiting to pull. |
hmm I pushed it 10 minutes ago, 40426a6 |
pulled & verified on several runs. You can close this issue :) |
Cheers |
I just forked the repo and did
npm install
.I have two issues:
grunt build
fails with the following error:However this is a clean fork. I removed all the carriage returns (the offending char) and it still happens, so I'm at a loss. I'm on windows 7.
grunt test
fails for me too:Can you help me get the local build & tests working?
The text was updated successfully, but these errors were encountered: