Rust, neon, inversion of control

  1. Currently, when using https://github.com/neon-bindings/neon , npm is "in control" -- the Rust code is compiled to a npm module.

  2. This is not very pleasant work experience, as I prefer to work entirely in IntelliJ/Rust plugin, and be able to run from IntelliJ + run unit tests from IntelliJ.

  3. Is there a way to "invert control" in the neon bindings? I want to be able to use rust to make calls to npm, but instead of "compile Rust to a npm module", I want Rust to be "in control", so that npm is just some crate I add as a dependency ... and I can utilize the neon bindings directly in rust unit tests / rust apps.

Perhaps you could make a wrapper crate that runs npm from build.rs, and launches npm test from a Rust #[test] function?

In IntelliJ, I have blocks like

#[test]
pub fn test_00() {
...
}

Then, IntelliJ puts a green arrow next to the "pub fn test" where when I click on it, it runs the unit tests.

It's not clear to me how this npm / build.rs approach launches npm from my Rust unit test.

I had std::process::Command in mind, but to have such annotation per test case, I guess you'd have to launch node separately for every test case, and that's a lot of test boilerplate, and a lot of node processes run :confused:

So running a unit test in crate-foo involves

  1. the unit test recompiling crate-foo as a npm module
  2. the unit test firing up npm to load the module + run ?

This sounds like a rube goldberg machine that also breaks any hope of debugging.