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

ProcessInfo is empty when invoking carton test #400

Open
stephencelis opened this issue May 5, 2023 · 4 comments
Open

ProcessInfo is empty when invoking carton test #400

stephencelis opened this issue May 5, 2023 · 4 comments

Comments

@stephencelis
Copy link

stephencelis commented May 5, 2023

I am trying to figure out how to detect, at runtime, from SwiftWasm, if it's being run from carton test, but ProcessInfo arguments and environment are totally empty. I was hoping to be able to see something like ["carton", "test", "--environment", "node"] and use this.

(I can't rely on arguments passed by the user, since this is library code.)

@kateinoigakukun
Copy link
Member

The CommandLine.arguments (as well ProcessInfo also IIRC) follow the WASI arguments concept, which cannot see the host environment arguments. For example, when you are running a WASI app with wasmtime and run the following command:

$ wasmtime run main.wasm -- --help

The WASI runtime passes only ["main.wasm", "--help"] and don't pass ["wasmtime", "run"] to the guest WASI process. So it's impossible to detect it from given arguments.

That being said, we can consider injecting some environment variables that appear only for testing. Does it help your scenario?

@stephencelis
Copy link
Author

stephencelis commented May 6, 2023

That would definitely help, yup! This is a reliable way to detect XCTest runs from both Linux/Windows SPM and Xcode, so a way of doing the same for Wasm would be great.

@stephencelis
Copy link
Author

(Also, just to confirm, is there any other existing way for Swift code to detect if it executing from carton tests? The subject of the issue is just one way I attempted to do so.)

@kateinoigakukun
Copy link
Member

There's no way for now as far as I remember.

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

No branches or pull requests

2 participants