Adding unit tests to plugins?

18 görüntüleme
İlk okunmamış mesaja atla

Nathan Henrie

okunmadı,
24 Ağu 2022 16:58:0824.08.2022
alıcı Quicksilver

Hello,

I’ve been banging my head on the wall trying to add unit tests to the plugin template.

Starting with a freshly cookiecutter-ed plugin, File -> New -> Target... -> Unit Testing Bundle, see that Target to be Tested is None and can’t be changed to the plugin.

I think the problem might be that the resulting binary is of Mach-O type bundle instead of executable, whereas the XCode unit testing stuff seems to want an executable as the TEST_HOST. I tried changing TEST_HOST (and Bundle Loader) manually to to the binary as well as to the Quicksilver executable with no success.

Tried using the GitHub search to see if any of the plugins on the QS org have existing unit tests but didn’t find any, but I’m not sure how well that search worked.

Do any of you know of an existing QS plugin that has unit tests?

Nate

Nathan Henrie

okunmadı,
25 Ağu 2022 16:12:1225.08.2022
alıcı Quicksilver

Well, some progress —

By setting Bundle Loader, linking to QSCore, and changing the mach-O type from Bundle to Framework or Static Library, everything compiles, links, and the tests run.

Any ideas why I would need to change to a static library?

All of the build settings regarding stripping debug and swift symbols are set to off.

Xcode gives me errors about missing symbols:

  Assertions: System: Failed to load the test bundle. If you believe this error represents a bug, please attach the result bundle at /Users/n8henrie/Library/Developer/Xcode/DerivedData/QSasdf-dtdzxwslxbegikancingpnsvllhj/Logs/Test/Test-QSasdf-2022.08.25_14-08-54--0600.xcresult. (Underlying Error: The bundle “QSasdf Unit Tests” couldn’t be loaded. The bundle couldn’t be loaded. Try reinstalling the bundle. dlopen(/tmp/QS/build/Debug/QSasdf Unit Tests.xctest/Contents/MacOS/QSasdf Unit Tests, 0x0109): Symbol not found: (_$s6QSasdf0A11SwiftActionCACycfC)
  Referenced from: '/private/tmp/QS/build/Debug/QSasdf Unit Tests.xctest/Contents/MacOS/QSasdf Unit Tests'
  Expected in: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/xctest')

But those symbols seem to be present in the binary:

$ nm QSasdf | grep 11SwiftActionCACycfC
0000000000009034 T _$s6QSasdf0A11SwiftActionCACycfC

Is there some reason this would need to be set as a static lib instead of a “bundle”? It looks like the (somewhat dated) Apple dev documentation on plugins recommends a bundle.

Thanks for any ideas.

Nate

Nathan Henrie

okunmadı,
11 Eyl 2022 17:21:5011.09.2022
alıcı Quicksilver

I worked around by:

  • Adding the unit tests target to the .swift file
  • Adding the core Quicksilver frameworks to linked libraries in the unit tests’ build phases
  • Leaving everything as a bundle

If anyone wants to check it out, you should be able to run:

$ cookiecutter 'https://github.com/quicksilver/plugin_template' --checkout swift

and afterwards should be able to run the tests and see several actions for text objects that come up when searching for “swift”.

Please let me know if anyone can give it a shot! Will also start an issue.

Nate

Patrick Robertson

okunmadı,
26 Eyl 2022 07:22:3826.09.2022
alıcı quicksilver-...@googlegroups.com
Cool, this is great to have! So we can start creating plugins in Swift! 🎉


-- 
You received this message because you are subscribed to the Google Groups "Quicksilver - Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quicksilver---deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quicksilver---development/CAOMt5FBvQFPT2zn%2B6fZS5Ay3f0Pa3e2OOCJ6KLKKVO7AOAXkuA%40mail.gmail.com.

Tümünü yanıtla
Yazarı yanıtla
Yönlendir
0 yeni ileti