Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Output definitions in Cuckoofile.toml are ignored/in conflict using CuckooPluginFile.

Open JavaAdam opened this issue 1 year ago • 8 comments

CuckooPluginFile ist overriding all output definitions by setting CUCKOO_OVERRIDE_OUTPUT to an output on the derived data directory. This leads to two unexpected behaviors:

  • When a global output is defined in the Cuckoofile.toml an error is thrown because "two global output definitions" are set.
  • Output definitions in modules are ignored at all.

So the Swift Package Manager approach is usable for very simple projects only.

JavaAdam avatar May 29 '24 11:05 JavaAdam

Hey @JavaAdam, thanks for letting me know.

I won't have access to my computer for a few more days so I can't really think of a better solution, do you have one in mind for complex projects?

MatyasKriz avatar May 30 '24 10:05 MatyasKriz

To be honest, i am not familiar with restrictions concerning the Swift Package Manager Plugin. But I would just expect, that the output definitions in Cuckoofile.toml are respected/effective. So that the developer is free to define whatever is needed for his particular project.

When it's not possible to write somewhere else than in the derived data directory, than the developer would be responsible to define correct outputs in derived data. A descriptive message in the build log would be helpful here.

JavaAdam avatar Jun 03 '24 06:06 JavaAdam

Hello @JavaAdam could you share your Cuckoofile.toml?

  • When a global output is defined in the Cuckoofile.toml an error is thrown because "two global output definitions" are set.

dr-star avatar Jun 19 '24 14:06 dr-star

Hello @dr-star. Unfortunately, I dropped the branch a while ago.

But as I remember I did something like this:

[modules.MyProject] output = "${PROJECT_DIR}/MyTarget/Tests/MyGeneratedMocks.swift"

Defining additional a global output failed with a "two global output definitions" error message.

JavaAdam avatar Jun 20 '24 06:06 JavaAdam

After trying to migrate to 2.0.9 i'm getting the exact same behaviour.

  • Setting an output to a specific folder inside a module doesn't work and creates the mock inside the derived data
  • Specifying a global output on line 1 of .toml file result in error Multiple global `output` parameters. Behavior is undefined
  • Only specifying a global output does the same error

soucolline avatar Aug 02 '24 14:08 soucolline

Same issue, which results in an error Filename "GeneratedMocks.swift used twice: ... although the two outputs I specified in the Cuckoofile.toml in my project's root (as per the Installation Instructions) are output = "ModuleATests/Resources/Mocks.swift" and output = "ModuleBTests/Resources/Mocks.swift". I guess the GeneratedMocks.swift are some default output location because the output property doesn't seem to work.< Each test module ModuleATests and ModuleBTests has the Run Build Tool Plug-ins set to CuckooPluginSingleFile (Cuckoo).

It also appears that although the Installation Instructions indicate how to set up rules for projects with multiple test modules, looking at the plugin code, the FIXME could indicate otherwise: Image

GabrielBrodersen avatar Mar 11 '25 07:03 GabrielBrodersen

Yeah, it's an unfortunate limitation of the SPM build tool, perhaps the duplicate GeneratedMocks.swift could be fixed by instead of using static GeneratedMocks.swift file we could pass a UUID like GeneratedMocks-UUID.swift.

MatyasKriz avatar Mar 14 '25 18:03 MatyasKriz

Is there a temporary solution for this issue?

adelamarre-pelm avatar Apr 10 '25 21:04 adelamarre-pelm