Skip to content
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

Dynamically creates a launch agent to facilitate testing #117

Merged
merged 2 commits into from
Jul 23, 2022

Conversation

jakaplan
Copy link
Contributor

A launch agent running as a completely separate process is now created, registered (load) with launchd, and can be communicated with. This allows for testing shared memory functionality in a separate process.

Cleanup logic also exists to unload the agent and delete all of the created files. However, the paths and service name are all randomly generated, so nothing bad ought to happen if cleanup fails (for example because a test fails).

Building SecureXPC from scratch takes a long time, so the code has been written in such a way that people using this framework can provide a path to the pre-built module - this will speed things up about 25x.

For reference, these were helpful resources in figuring out how to use swiftc:

A launch agent running as a completely separate process is now created, registered (load) with `launchd`, and can be communicated with. This allows for testing shared memory functionality in a separate process.

Cleanup logic also exists to unload the agent and delete all of the created files. However, the paths and service name are all randomly generated, so nothing bad ought to happen if cleanup fails (for example because a test fails).

Building SecureXPC from scratch takes a long time, so the code has been written in such a way that people using this framework can provide a path to the pre-built module - this will speed things up about 25x.

Note, these were helpful resources in figuring out how to use `swiftc`:
https://theswiftdev.com/building-static-and-dynamic-swift-libraries-using-the-swift-compiler/
https://blog.spencerkohan.com/building-swift-without-a-build-system/
@jakaplan
Copy link
Contributor Author

@amomchilov For your future reference, if you want to write tests which access a launch agent that runs in a completely separate process that will now be possible.

@jakaplan jakaplan merged commit 2486aff into main Jul 23, 2022
@jakaplan jakaplan deleted the multiprocess-testing branch July 23, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant