test: add test for spawnSync() env option

The `env` option to `spawnSync()` is currently broken. A fix is available in #8546, but no test is provided. This PR adds a test, which will fail until #8546 is merged.