Skip to content

Detect if XCTest is installed on Darwin #7805

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

Merged
merged 2 commits into from
Jul 26, 2024
Merged

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jul 22, 2024

This PR checks if XCTest is available before invoking XCTest-based tests on Darwin. There are three possible outcomes:

  1. If XCTest is available, we will run XCTest-based tests (as we have historically.)
  2. If XCTest is not available and the user explicitly passed --enable-xctest, we will attempt to run XCTest-based tests, but in general this code path will continue to fail as swift test has historically done when XCTest is not available.
  3. If XCTest is not available and the user did not pass --enable-xctest, we skip running any XCTest logic.

On Linux/Windows/etc., XCTest is always present via swift-corelibs-xctest and so this change has no practical effect there. On Darwin, XCTest may be missing if the user has installed the Xcode Command Line Tools, but not the full Xcode IDE. XCTest is not included with the Xcode Command Line Tools package.

The purpose of this change is to allow running swift test when XCTest is unavailable but Swift Testing is available.

@grynspan grynspan added enhancement swift test Changes impacting `swift test` tool labels Jul 22, 2024
@grynspan grynspan self-assigned this Jul 22, 2024
@grynspan grynspan changed the title [WIP] Weak-link to XCTest [WIP, DNM] Weak-link to XCTest Jul 22, 2024
@grynspan
Copy link
Contributor Author

Did some experimenting—I think that what I really need here is not weak-linked XCTest, but simply to detect if swift test is using Xcode CL Tools instead of Xcode and to set XCTest as disabled by default if so.

This PR checks if XCTest is available before invoking XCTest-based tests on
Darwin. There are three possible outcomes:

1. If XCTest is available, we will run XCTest-based tests (as we have
   historically.)
2. If XCTest is not available and the user explicitly passed `--enable-xctest`,
   we will attempt to run XCTest-based tests, but in general this code path will
   continue to fail as `swift test` has historically done when XCTest is not
   available.
3. If XCTest is not available and the user did not pass `--enable-xctest`, we
   skip running any XCTest logic.

On Linux/Windows/etc., XCTest is always present via swift-corelibs-xctest and so
this change has no practical effect there. On Darwin, XCTest may be missing if
the user has installed the Xcode Command Line Tools, but not the full Xcode IDE.
XCTest is not included with the Xcode Command Line Tools package.

The purpose of this change is to allow running `swift test` when XCTest is
unavailable but Swift Testing _is_ available.
@grynspan grynspan force-pushed the jgrynspan/weak-link-XCTest branch from bdb90fd to cc032ce Compare July 23, 2024 15:02
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan grynspan changed the title [WIP, DNM] Weak-link to XCTest [WIP, DNM] Detect if XCTest is installed on Darwin. Jul 23, 2024
@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@grynspan grynspan requested a review from compnerd July 23, 2024 15:21
@grynspan grynspan changed the title [WIP, DNM] Detect if XCTest is installed on Darwin. Detect if XCTest is installed on Darwin. Jul 23, 2024
@grynspan grynspan closed this Jul 23, 2024
@grynspan grynspan reopened this Jul 23, 2024
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@grynspan grynspan marked this pull request as ready for review July 23, 2024 20:59
@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@MaxDesiatov MaxDesiatov changed the title Detect if XCTest is installed on Darwin. Detect if XCTest is installed on Darwin Jul 26, 2024
@grynspan grynspan merged commit 5f38882 into main Jul 26, 2024
5 checks passed
@grynspan grynspan deleted the jgrynspan/weak-link-XCTest branch July 26, 2024 14:11
bnbarham pushed a commit that referenced this pull request Oct 11, 2024
This PR checks if XCTest is available before invoking XCTest-based tests
on Darwin. There are three possible outcomes:

1. If XCTest is available, we will run XCTest-based tests (as we have
historically.)
2. If XCTest is not available and the user explicitly passed
`--enable-xctest`, we will attempt to run XCTest-based tests, but in
general this code path will continue to fail as `swift test` has
historically done when XCTest is not available.
3. If XCTest is not available and the user did not pass
`--enable-xctest`, we skip running any XCTest logic.

On Linux/Windows/etc., XCTest is always present via
swift-corelibs-xctest and so this change has no practical effect there.
On Darwin, XCTest may be missing if the user has installed the Xcode
Command Line Tools, but not the full Xcode IDE. XCTest is not included
with the Xcode Command Line Tools package.

The purpose of this change is to allow running `swift test` when XCTest
is unavailable but Swift Testing _is_ available.
bnbarham pushed a commit to bnbarham/swift-package-manager that referenced this pull request Oct 12, 2024
This PR checks if XCTest is available before invoking XCTest-based tests
on Darwin. There are three possible outcomes:

1. If XCTest is available, we will run XCTest-based tests (as we have
historically.)
2. If XCTest is not available and the user explicitly passed
`--enable-xctest`, we will attempt to run XCTest-based tests, but in
general this code path will continue to fail as `swift test` has
historically done when XCTest is not available.
3. If XCTest is not available and the user did not pass
`--enable-xctest`, we skip running any XCTest logic.

On Linux/Windows/etc., XCTest is always present via
swift-corelibs-xctest and so this change has no practical effect there.
On Darwin, XCTest may be missing if the user has installed the Xcode
Command Line Tools, but not the full Xcode IDE. XCTest is not included
with the Xcode Command Line Tools package.

The purpose of this change is to allow running `swift test` when XCTest
is unavailable but Swift Testing _is_ available.
bnbarham pushed a commit that referenced this pull request Oct 15, 2024
This PR checks if XCTest is available before invoking XCTest-based tests
on Darwin. There are three possible outcomes:

1. If XCTest is available, we will run XCTest-based tests (as we have
historically.)
2. If XCTest is not available and the user explicitly passed
`--enable-xctest`, we will attempt to run XCTest-based tests, but in
general this code path will continue to fail as `swift test` has
historically done when XCTest is not available.
3. If XCTest is not available and the user did not pass
`--enable-xctest`, we skip running any XCTest logic.

On Linux/Windows/etc., XCTest is always present via
swift-corelibs-xctest and so this change has no practical effect there.
On Darwin, XCTest may be missing if the user has installed the Xcode
Command Line Tools, but not the full Xcode IDE. XCTest is not included
with the Xcode Command Line Tools package.

The purpose of this change is to allow running `swift test` when XCTest
is unavailable but Swift Testing _is_ available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement swift test Changes impacting `swift test` tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants