Open stephencelis opened 1 year ago
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?
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.
(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.)
There's no way for now as far as I remember.
I am trying to figure out how to detect, at runtime, from SwiftWasm, if it's being run from
carton test
, butProcessInfo
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.)