Closed royriojas closed 9 years ago
I'd be surprised if this got merged. It clearly isn't the right solution to have to run it separately. I'm not familiar enough with the code either to know what is actually happening.
The fix for the tests is not what I'm interested about, but for the one avoiding the require
calls for mocks to be executed. I just wanted to be sure the code I introduced was not the guilty of the failures, as it clearly wasn't. The failure happens on browserify > 10.2.4. So it is probably something on their end and not in the tests
I have found the way to fix the tests, it seems that there is some sort of race condition. The approach I have here is first compile the code, then run the tests, with that, it seems that the race condition went away and no need to have one of the tests to run alone
Please don't change any existing tests or how they are run. Otherwise we cannot be sure that no existing functionality is affected by your change. Thanks.
@thlorenz this change required to change 1 of the tests because it no longer make sense. Since before you just put a require call the code of the module was executed immediately. this reported that the module was required 3 times, when in effect it was only required to be included twice.
The tests were broken (even without any changes) for browserify > 10.2.4
The change that I made was to make sure the tests were run sequentially without enter into race conditions which happened to fix the issues. I haven't change any other test, just make sure they were properly run in sequence
No need for promises to coordinate callback. run-parallel would do just fine on first glance.
@sure, I'm not familiar with run-parallel
if you point me to an example I can make the change if required.
But actually the problem is that tape need to run sequentially, not in parallel, to avoid the failure on browserify > 10.2.4
Let's do this w/out adding any dependencies like this unless we have a good reason. A simple callback should work here.
Additionally don't change anything about the way the tests run please. I'm not sure why that would be required to add the feature, so you'd have to have a good reason and explain why you need this.
@thlorenz sorry I updated the pull request before reading you don't want new dependencies. I used what @bendrucker suggested. run-parallel
So let's me explain why the test runner was modified.
master
and run npm test
you will see the tests are failing for browserify > 10.2.4let me be clear that I haven't modified any tests, but the one that was incorrect: expecting the require to happen 3 times was not correct if the code only 2 calls to proxyquire were done. The extra one was for the magic require inserted.
Let me know if you want me to modify this to not use any dep, I will kindly ask you to consider run-parallel
or even promises since they are dev dependencies not real dependencies.
Thanks for your time guys
Overall LGTM. Please fix the places I pointed out.
the issue seems to be that there is a race condition when entering the part that executes the code
We should check that that's not exposing a problem we need to fix in the code instead of just modifying the tests to cover it up.
WRT to run-parallel, although I'm convinced that this is totally overkill for what you're doing and it'd be a good exercise to write this with plain callbacks and task counting (unless it's obvious to you in which case it'll take a minute). However it'd fine either way and including it or not won't block this PR from my end.
Hi @thlorenz,
I guess I have cover all of your observations. I do agree, this might be at least a minor or even major change, since it changes one of the unit tests.
I have removed run-parallel
.
Thanks for your time
LGTM once the last few nits are fixed. Gonna wait for @bendrucker to review before merging.
Made some small stylistic comments, LGTM once they're resolved
All but the comment for other coverage tools are resolved. Each coverage tool has different ways to ignore block of codes.
I imagine that maybe a solution would be to actually register a module using b.require(module)
, but them we will have to find a way to register all the possible aliases during bundling.
That would require going back to the drawing board, so I guess is out of the scope of this pull request. I guess for now this is good enough
I don't really use coverage tools these days. Can you give some examples?
Hi @bendrucker,
the comment instruction I put there was for babel-istanbul
, I used with browserify-babel-istanbul they use /* istanbul ignore next */
I couldn't find info about any other coverage tool, blanketjs
is the other one I know, but that doesn't have a way to ignore the generated code.
Ok, I think it's fine to leave it for now
Noted some more minor nits in last last commit, please fix and we can merge if @bendrucker is ok with everything.
BTW thanks for your patience with nit fixing, but we need to uphold current style in module.
@thlorenz I made the requested changes. BTW Thanks for writing the module in the first place.
Looks okay to me, pending a squash
done!
So is this good to merge @bendrucker? If yes I'll try to get to it tomorrow.
Yes!
Ok, merged 0d5fe82f00b2a9e12c138f59544569cae1fb220d and published as v3. This is a major upgrade as discussed due to the breaking change in behavior.
@royriojas Can you do me a favor and send a PR to proxyquire-universal updating the peerDep?
sure @bendrucker, will do.
@bendrucker It seems that proxyquire-universal
was pin to use 1.x.x versions of proxyquireify
. Tests fails if I even try to use version 2.0.0 of proxyquireify
. That will require change on the tests on proxyquire-universal
. Are you open to do that? Wouldn't it be better to create a new issue for the update?
Yeah sure, really appreciate it
@royriojas I'd just create a PR over there with what you have so far (think of a PR as an issue with code). Then you guys can figure out how to solve the problem.
@thlorenz ok will open then the PR. Test won't pass though
Hi guys this is the improvement proposed as part of https://github.com/thlorenz/proxyquireify/issues/38
Couple of notes.