[v6.x backport] test: preserve env in test cases
Allows env vars to be passed through to child processes. This is needed for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared library.
Refs: https://github.com/nodejs/node/pull/13390
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows [commit guidelines]
Affected core subsystem(s)
test
Original PR: https://github.com/nodejs/node/pull/14822