BarredEwe / Prefire

🔥 A library based on SwiftUI Preview, for easy generation: Playbook view, Snapshot and Accessibility tests
Apache License 2.0
296 stars 19 forks source link

Fixed the source search for the PrefireTestsPlugin #36

Closed BarredEwe closed 7 months ago

BarredEwe commented 9 months ago

Short description 📝

Nested swift packages could be affected if they were inside the source directory.

Solution 📦

The search for files in the directory has been removed. Instead, file paths are passed directly from plugins.

This removes problems with file search and, it improves performance (since you don't need to process all files)

woutergoossens commented 9 months ago

For me this fix is working. Any issues with the tests? So we can merge this?

BarredEwe commented 9 months ago

For me this fix is working. Any issues with the tests? So we can merge this?

I have to add some tests for these changes and macro preview support.

woutergoossens commented 8 months ago

Ok thanks! When do you think you will have time to finish this PR? As I need this PR first to be able to update to the latest version.

Thanks!

woutergoossens commented 8 months ago

Any update?

BarredEwe commented 7 months ago

Any update?

I've almost finished it, I'll try to post it soon

woutergoossens commented 7 months ago

@BarredEwe I updated to the latest version but we get this issue now

... LONG LIST OF ALL THE SWIFT FILES IN OUR PRESENTATION PACKAGE...
    ➜ Template path: /Users/gowo/Development/Argenta/mobile-ios/Presentation/Tests/PresentationPreviewTests/PreviewTests.stencil
    ➜ Generated test path: /Users/gowo/Library/Developer/Xcode/DerivedData/Presentation-gkbvpnlvzvzfoefbirrgyrkvqkzi/SourcePackages/plugins/presentation.output/PresentationPreviewTests/PrefireTestsPlugin/Genera*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'too many arguments (4220) -- limit is 4096'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018ff12ccc __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018f9fa788 objc_exception_throw + 60
    2   Foundation                          0x000000019103ca08 -[NSConcreteTask launchWithDictionary:error:] + 4164
    3   prefire                             0x00000001027dcc60 $s7prefire20GenerateTestsCommandO3runyyAA09GeneratedC7OptionsVKFZTf4nd_n + 488
    4   prefire                             0x00000001027ddaa8 $s7prefire7PrefireV5TestsV3runyyKF + 812
    5   prefire                             0x00000001027ddea0 $s7prefire7PrefireV5TestsV14ArgumentParser15ParsableCommandAafGP3runyyKFTW + 52
    6   prefire                             0x0000000102802f6c $s14ArgumentParser20AsyncParsableCommandPAAE4mainyyYaFZTY0_ + 376
    7   prefire                             0x00000001027e45c1 $sIetH_yts5Error_pIegHrzo_TR10async_MainTf3npf_nTQ0_ + 1
    8   libswift_Concurrency.dylib          0x00000002564b3149 _ZL22completeTaskAndReleasePN5swift12AsyncContextEPNS_10SwiftErrorE + 1

So to many files and we get this :( How can we fix it?

Screenshot 2024-04-11 at 09 21 14
BarredEwe commented 7 months ago

@woutergoossens I have removed the output of sources. Could you try the new release?

woutergoossens commented 7 months ago

@woutergoossens I have removed the output of sources. Could you try the new release?

@BarredEwe

Thanks but that didn't fix it. It's passing all the files as arguments

Screenshot 2024-04-11 at 10 37 05

LONG LIST OF FILES..

Screenshot 2024-04-11 at 10 37 10
woutergoossens commented 7 months ago
let sources = (target as? SwiftSourceModuleTarget)?.sourceFiles.filter { $0.type == .source }.map(\.path.string)
arguments.append(contentsOf: sources ?? [target.directory.string])

I think this is causing the issue..

Found a solution => https://github.com/FlineDev/BartyCrouch/pull/150/files Extracting the files to a plist file and use that..

BarredEwe commented 7 months ago

@woutergoossens Could you try this? https://github.com/BarredEwe/Prefire/pull/46