-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardise process execution for tests #436
Conversation
👇 Click on the image for a new way to code review
Legend |
Aside from converting |
Regarding 501b803, this should be a separate PR, this requires changes to:
|
501b803
to
fd87744
Compare
Ah ok. I've dropped that commit and updated the PR description. So this is now just for standardising the process execution utils. |
This requires rebase on staging. The |
eadd771
to
407cb7d
Compare
I can't find any mention of there being a interface ISpawnOptions {
cwd?: string | undefined;
env?: any;
ignoreCase?: any;
stripColors?: any;
stream?: any;
verbose?: any;
} As a side note, the Interestingly it seems they made the switch due to compatibility issues on Windows nodejitsu/nexpect#37 |
407cb7d
to
0ee0b89
Compare
Regardless of whether options = options || {};
context = {
command: command,
cwd: options.cwd || undefined,
env: options.env || undefined,
ignoreCase: options.ignoreCase,
params: params,
queue: [],
stream: options.stream || 'stdout',
stripColors: options.stripColors,
verbose: options.verbose
}; So I don't think it's possible for |
1316751
to
abff46b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 comments for now. I need to head off for now but I'll come back and do a more thorough review.
Ok |
Add a comment to |
abff46b
to
a745f52
Compare
I think the You can keep it in Plus everywhere should be using If it doesn't exist, please create
This is similar to Any |
Did you create a separate issue for this? |
Not yet. Will reference here once I have. |
There's also:
Should these be using our exec utilities? |
Yeah it should be possible for those to switch over to using the new |
Beware that the new |
Please add this in the end to ignore the |
The nodes tests are timing out locally as well. I'm not sure what caused them to suddenly start doing this - the only change between the last time they were passing and the first time they started failing was changing the imports. I tried reverting this for |
Have a look at Obviously you want to look into why nodes tests are timing out now. Run them individually as well. Maybe see if this was brought in by some previous commits @tegefaulkes any ideas? |
Node connection tests will be using agents to test against. Check that all of the agents have the key generation override applied to them. It should look like If not that then are some tests timeout a connection when they shouldn't be?
|
These 2 locations:
Should be using Furthermore the path to the file is not robust. It should be using const testProcess = testUtils.spawn('ts-node', [ `${globalThis.testDir}/grpc/utils/testServer.ts` ]); Also @tegefaulkes has mentioned that there is no error event handler for these functions. You need to attach an error event handler for the |
Ok so I think the solution is this. Both Now in the case of exec, there are 2 events you are listening on:
In the case of
This way you can do |
If you're finishing up for the day @emmacasolin, @tegefaulkes can take over this, and get this merged. |
Note that this means the Individual tests should still be listening on the error event in case the spawned process itself still results in some kind of error. The |
When |
So, the command is not actually failing to spawn but it is throwing an error in const polykeyPath = path.resolve(
path.join(globalThis.projectDir, 'src/bin/polykey.ts'),
); This is sneaky one. This used to be inline in each function and was only run when the function was called. But here it's run during import of
|
So I was wrong about the So everywhere A similar const can be used like Also |
Standardised process execution for bin tests using `pkExec` and `pkSpawn`. - All usage of `pkExec`/`pkSpawn` calls underlying default `WithoutShell` or override `WithShell` methods - Combined `env` and `cwd` options into an `ExecOpts` object and added `command` and `shell` options - Refactored `pkSpawnNs` and `pkExecNs` to use standardised methods - Replaced all usage of `exec`/`execFile` with `spawn` - error handling for generic exec/spawn + using new generic spawn in NAT utils - ignore coverage from `src/proto` - removed spawnfile - added a check for if spawning process doesn't properly start
ec019bf
to
3da7b53
Compare
Description
There are many ways of running our tests across different platforms, and this should be standardised.
pkExec
/pkSpawn
/pkExpect
methods should have a default and override implementation. Default should run polykey as normal while the override should run polykey from a different entrypoint. The override should be taken from an argument first and then from an environment variable.pkStdio
and general process execution forexec
). All places in the code where such methods are used and these special cases do not apply should switch over to usingpkExec
or similar.We will need to ensure that signals and events are still handled correctly after making these changes.
Issues Fixed
tests/utils/exec.ts
#432Tasks
pkExpectsignatures to taken an options object at the very end for the command, env, and cwdpkExpectaccording to spec in Standardise Process Execution intests/utils/exec.ts
#432Final checklist