Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Nov 3, 2025

This PR adds some OpenBSD-specific code to capture the current working directory as early as possible. We then use that directory when argv[0] appears to be a relative path so that the following incantation works correctly:

./.build/debug/myPackageTests.xctest --testing-library swift-testing

This logic is not necessary on other platforms because they all provide a way to get the path to the current executable. OpenBSD has no such API.

Resolves #1348.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR adds some OpenBSD-specific code to capture the current working directory as early as possible. We then use that directory when argv[0] appears to be a relative path so that the following incantation works correctly:

```sh
./.build/debug/myPackageTests.xctest --testing-library swift-testing
```

This logic is not necessary on other platforms because they all provide a way to get the path to the current executable. OpenBSD has no such API.
@grynspan grynspan added this to the Swift 6.x (main) milestone Nov 3, 2025
@grynspan grynspan self-assigned this Nov 3, 2025
@grynspan grynspan added the workaround Workaround for an issue in another component (may need to revert later) label Nov 3, 2025
@grynspan grynspan added exit-tests ☠️ Work related to exit tests openbsd 🐡 OpenBSD support labels Nov 3, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Nov 3, 2025

@3405691582 please take a look!

Copy link
Member

@3405691582 3405691582 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@grynspan
Copy link
Contributor Author

grynspan commented Nov 4, 2025

Discussed with @3405691582 in DMs; will need to move the constructor function down to C++ (darn) to ensure it compiles correctly on at least some 6.3-dev toolchains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exit-tests ☠️ Work related to exit tests openbsd 🐡 OpenBSD support workaround Workaround for an issue in another component (may need to revert later)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve CommandLine.executablePath implementation on OpenBSD

4 participants