# Approaches for testing environment-dependent SwiftPM behavior?

**URL:** <https://forums.swift.org/t/approaches-for-testing-environment-dependent-swiftpm-behavior/78219>\
**Category:** Package Manager\
**Created:** [March 2, 2025, 12:53am UTC](https://forums.swift.org/t/approaches-for-testing-environment-dependent-swiftpm-behavior/78219 "2025-03-02T00:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [March 2, 2025, 12:53am UTC](https://forums.swift.org/t/approaches-for-testing-environment-dependent-swiftpm-behavior/78219/1 "2025-03-02T00:53:30Z")

</div>

as i’m working on improving the test coverage for the [[Pitch] Replaceable Library Plugins](https://forums.swift.org/t/pitch-replaceable-library-plugins/77605) feature, i’m running into a conundrum where we need to be able to _test_ that SwiftPM can use a precompiled binary dependency, but none of the test artifacts we have on hand are compatible with the Swift CI runners.

Option 1: Test prebuilt Linux libraries

this will probably Never Work, because “Linux” is too broad a term and provides too few environmental guarantees for a generic “Linux” CI runner to robustly support testing Environment-Dependent Shared Libraries (EDSLs).

Option 2: Test prebuilt macOS libraries

this is less than ideal, as EDSLs are a principally Linux-targeting feature, but the specific problem we have is that the macOS CI runners are x86\_64 runners, and any test artifacts we could possibly supply are aarch64 binaries, since that’s the hardware we have.

Option 3: Build EDSLs locally, in the CI runner

this is unattractive, as EDSLs are a bit complex to create, tag, persist, and distribute, and i’m not sure if adding infrastructure to the swift-package-manager repo specifically for distributing test EDSLs to itself is a Good Idea.

plus, i’m not sure if the SwiftPM test infrastructure supports running bash scripts from within a test case.

Option 4: Don’t test EDSLs at all

listed for completeness.

posting this here in case anyone has advice for how to tackle this type of situation. cc @hassila

---

<div class="post-metadata">

**Author:** ![Sarunas](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sarunas/32/37050_2.png) [@Sarunas](https://forums.swift.org/u/Sarunas)\
**Post date:** [March 3, 2025, 2:55pm UTC](https://forums.swift.org/t/approaches-for-testing-environment-dependent-swiftpm-behavior/78219/2 "2025-03-03T14:55:58Z")

</div>

In my opinion, the EDSL should be built as part of testing on the CI runner to guarantee compatibility. Using `.binaryTarget(name:path:)` eliminates the need for tagging, persisting, or creating checksums. The [existing integration tests](https://github.com/swiftlang/swift-package-manager/blob/main/IntegrationTests/Fixtures/BinaryTargets/TestBinary/Package.swift) already use this approach, but they appear outdated, and I'm unable to run these via `Utilities/test-toolchain`.

EDSL tests should probably be under Tests directory. I found [checkParseArtifactsPlatformCompatibility()](https://github.com/swiftlang/swift-package-manager/blob/swift-DEVELOPMENT-SNAPSHOT-2025-02-28-a/Tests/BuildTests/PluginInvocationTests.swift#L1137) which creates similar binary tool definitions. There's also [PR #8214](https://github.com/swiftlang/swift-package-manager/pull/8214) which adds tests for pre-built swift-syntax tests.

Regarding CI, the [smoketest](https://ci.swift.org/job/swift-package-manager-PR-macos-smoke-test) uses a private GitHub repo ([https://github.com/apple/swift-continuous-integration](https://github.com/apple/swift-continuous-integration)). It's unclear what's being tested and how since it spends over 4 hours [building](https://ci.swift.org/job/swift-package-manager-PR-macos-smoke-test/5292/consoleFull) the full toolchain, and the only test output with `Test Case` is for SwiftFormatTests:

```swift
--- Running tests for swiftpm ---
+ /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/swiftpm/Utilities/bootstrap test --release --swiftc-path /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/intermediate-install/macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --clang-path /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/intermediate-install/macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --cmake-path /usr/local/bin/cmake --ninja-path /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/ninja-build/ninja --build-dir /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64 --llbuild-build-dir /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/llbuild-macosx-x86_64 --verbose

Build Percentage Build Duration (sec) Build Phase
================ ==================== ===========
12.7% 1967.03 Running tests for swiftpm

```
