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
[SR-1125] Make StdlibUnittest automatically run tests in process when run in the interpreter #43738
Comments
Is it reliable to check if |
It isn't, unfortunately. Script mode sets |
Note that "the interpreter" is different from "the integrated REPL" (and definitely different from "the real, LLDB-provided REPL"). The mode I'm referring to is |
Wait, shouldn't |
That's a good @gribozavr question, but I think that's the flag that says "yes, please crash; the parent process will pick it up". But we also want to do this without extra options, so that we don't have to change the RUN lines between compile/run and interpret builds. |
I think the argument you're thinking of is |
The way I imagined we would run tests in the interpreter is by teaching StdlibUnittest to run the subprocess with the interpreter correctly. Then everything will just work. > Wait, shouldn't --stdlib-unittest-in-process imply skipping crash tests? I'd say no. This option is very useful for running individual tests under the debugger, so it shouldn't disable tests by itself. |
I agree, that makes more sense. However, I can't seem to find any way of knowing the interpreter path at runtime. I've looked all over. Would this be a case for an environment variable like var pid: pid_t = -1
var childArgs = [Process.arguments[0]] + args
if let invocation = String(cString: getenv("SWIFT_INVOCATION")) {
childArgs.insert(invocation, at: 0)
}
let spawnResult = withArrayOfCStrings(childArgs) { //... } |
I thought the interpreter path is visible through |
Unfortunately, Should that invocation variable come from lit? Or how should it be set? |
How about a |
I'd rather not have to go through swift-evolution to enable more tests. ;-) |
Yes, the variable should be set by lit. Re: |
Well, what if we set the variable in |
That would change the compiler's behavior. StdlibUnittest could include the environment variable into the command line that it suggests for debugging. |
Ah, right. Didn't realize that was necessarily off-limits. 👍 |
Done? Great! But when? |
Actually months ago, haha |
Ah, I missed this. Cool! |
It doesn't work.
|
Hmm...this worked when I tried it in April. It's supposed to invoke a sub-interpreter when crashes are expected. I'll investigate again... |
So this specific issue is working correctly, but there are many test failures when running in the interpreter because of invariants that the interpreter doesn't satisfy. |
Additional Detail from JIRA
md5: 891687c76bd6a27a72b51e7b499c7049
relates to:
Issue Description:
By default StdlibUnittest runs tests out of process, so that it can detect expected and unexpected crashes. We should give it a mode where it
runs tests in process
skips crash tests (possibly with a new
skip
annotation)and figure out how to automatically make it use this mode when run under the Swift interpreter, at least during lit tests. (An environment variable might be an easy way to do this.)
The text was updated successfully, but these errors were encountered: