Skip to content

Supporting running nested SPM tests - #81

Merged
MrSubidubi merged 2 commits into
zed-extensions:mainfrom
kamaal111:main
Jul 20, 2026
Merged

Supporting running nested SPM tests#81
MrSubidubi merged 2 commits into
zed-extensions:mainfrom
kamaal111:main

Conversation

@kamaal111

@kamaal111 kamaal111 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Issue
Fixes #13

Issue before this change

When working in a folder where the root folder is not a SPM package, we were getting the following error:

error: Could not find Package.swift in this directory or any of its parent directories.

This happened because swift test was being ran without a package path, so SwiftPM tried to resolve Package.swift from the workspace root.

Solution

Add --package-path $ZED_DIRNAME to swift test.

$ZED_DIRNAME points to the directory of the test file we are attempting to run. Even when that directory is not the package root, SwiftPM is able to resolve the owning Package.swift by traversing upwards to the root of the package.

This makes it possible to run tests from nested SPM packages in a folder or workspace that contains one or many separate SPM packages.

Testing instructions

mkdir testing-this
cd testing-this
swift package init --package-path Nested
zed .

If you run the tests before this change then you will see the error above. With this fix applied, the tests can be ran successfully.

@cla-bot

cla-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @kamaal111 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@kamaal111

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Jun 13, 2026
@cla-bot

cla-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

**Issue**
Fixes zed-extensions#13

**Issue before this change**

When working in a folder where the root folder is not a SPM package, we
were getting the following error:

```
error: Could not find Package.swift in this directory or any of its parent directories.
```

This happened because `swift test` was being ran without a package path,
so SwiftPM tried to resolve `Package.swift` from the workspace root.

**Solution**

Add `--package-path $ZED_DIRNAME` to `swift test`.

`$ZED_DIRNAME` points to the directory of the test file we are attempting
to run. Even when that directory is not the package root, SwiftPM is able
to resolve the owning `Package.swift` by traversing upwards to the root of
the package.

This makes it possible to run tests from nested SPM packages in a folder
or workspace that contains one or many separate SPM packages.

**Testing instructions**

```sh
mkdir testing-this
cd testing-this
swift package init --package-path Nested
zed .
```

If you run the tests before this change then you will see the error above.
With this fix applied, the tests can be ran successfully.

Signed-off-by: Kamaal Farah <kamaal.f1@gmail.com>

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice, thank you! And congratulations to your first contribution! 🎉

@MrSubidubi
MrSubidubi enabled auto-merge (squash) July 20, 2026 17:49
@MrSubidubi
MrSubidubi merged commit 909bc12 into zed-extensions:main Jul 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't handle Swift projects in a monorepo

2 participants