Git Product home page Git Product logo

Comments (7)

staxmanade avatar staxmanade commented on May 29, 2024

It's a good question...

I could see some benefit to making it more "synchronous" as you explained above. Currently it's just going to verify, throw up the tool - and sadly if you have 100 failures - it gets a little messy.

But going through 100 synchronously feels like it could never end as well.

Not sure how I think about this - maybe a PR that made it configurable would be interesting to explore.

Personally I've never had a problem with them failing - I fix any with p4merge and once all the instances of the open tool windows have been addressed - re-run tests to re-verify (should be good habit anyway).

Thoughts?

from approvals.nodejs.

alexanderbird avatar alexanderbird commented on May 29, 2024

Interesting -- what platform do you run it from? For me, on mac, each new failure uses the original p4merge window -- so my workflow is run them all with a donothing reporter, then rerun each failure individually and resolve it with p4merge. But maybe there's something I can change about either my p4merge setup on my machine, or the way the p4merge reporter delegates to p4merge in mac mode.

The other part is that I like having the "resolve" command on my clipboard... it's not that bad to type it in the terminal by reading p4merge titles and using tab completion, but it feels like an unnecessary step. I'm also using this on a project that is in it's baby stages, so there are often trivial UI changes that I want to approve. My guess is once things stabilize I won't have quite so many to approve all the time.

So if the mac/p4merge thing doesn't go anywhere, here's what I was thinking for API changes:

In GenericDiffReporterBase.js on line 66 (spawn(exe, [received, approved], {), we can save the return value from spawn -- it's an instance of ChildProcess (except in tests where a fake spawn is injected). Instead of returning nothing from report(), we can return a Promise that resolves when the ChildProcess' exit event is fired.

That Promise could be passed through and returned by each of the verify methods. So then it's fully opt-in: if you want to wait for the reporter to be closed, you do:

it(...., function(done) {
  approvals.verify(.....)
    .then(() => {
      done();
    });
});

from approvals.nodejs.

alexanderbird avatar alexanderbird commented on May 29, 2024

From a testing perspective, I was thinking we could write a unit test that uses a custom reporter that calls to a process that waits for some UDP message before terminating. Then we assert that the returned promise has not resolved yet, send the message to that process to terminate, and then assert that the promise has resolved. waits 2 seconds before terminating. The test would be something like

  it(...., function(done) {
    let didResolve = false;
    verify(....).then(() => { didResolve = true });
    expect(didResolve).to.be.false
    setTimeout(() => expect(didResolve).to.be.false, 1500);
    setTimeout(() => expect(didResolve).to.be.true, 2500);
    setTimeout(() => done(), 2501);
  });

from approvals.nodejs.

mattgodbolt avatar mattgodbolt commented on May 29, 2024

+1 to something. I just tried approvals for the first time, and 300+ meld sessions spawning back to back nearly crushed my computer!

from approvals.nodejs.

staxmanade avatar staxmanade commented on May 29, 2024

To follow up here...

@mattgodbolt We've thrown a some updates into a beta build of approvals at v4.0.0-beta.2 to help with the 300+ meld sessions... Give it a look

@alexanderbird - in doing some thinking I like the idea of verify returning a promise - but didn't get that in yet. There are a few knobs to play with at the config level that can help you now though (if you use a difftool that is more synchronous like opendiff or p4merge).

from approvals.nodejs.

alexanderbird avatar alexanderbird commented on May 29, 2024

👍🏻 Thanks for the update!

from approvals.nodejs.

mattgodbolt avatar mattgodbolt commented on May 29, 2024

@staxmanade Looks great: thanks!

from approvals.nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.