Brightify / Cuckoo

Boilerplate-free mocking framework for Swift!
MIT License
1.67k stars 174 forks source link

Exclude is not really excluded in cuckoofile.toml #500

Open Marquis103 opened 4 months ago

Marquis103 commented 4 months ago

I'm trying to figure out how to get the exclude portion of a module to actually be ignored. I've tried multiple different ways after reading through the codebase but nothing seems to work.

E.g. In my sources if I have

sources = [
  project_name/API/**/*
]

It correctly mocks everything that's in that folder as expected.

However, if I have a file that lives in that structure e.g. project_name/API/APIAuthenticationType.swift and I want it to be ignored it's not working. It's showing that it's capturing it as a file that should be ignored, but it still mocks it. I've tried many different inputs to the exclude but none seem to work. Any thoughts?

sources = [
  Project_name/API/**/*
]

// I've tried these combinations, but to no success.
exclude = [
  "APIAuthenticationType",
  "APIAuthenticationType.swift",
  "project_name/API/APIAuthentication.swift",
  "API/APIAuthentication.swift"
]
MatyasKriz commented 4 months ago

I've tried looking into this, but there's actually a test for this inside Cuckoo which tries creating an excluded class.

What's the name of the class you want to exclude? Make sure to use that in the array, it doesn't exclude whole files at the moment.

Marquis103 commented 4 months ago

This is the actual class name. APIAuthenticationType.

From the output it's recognizing the excluded files

excluded types:
[00:24:42]: ▸ -APIAuthenticationType

But then if you look right after that it says:

Processing file: APIAuthenticationType.swift

All this is given that my input sources is:

sources = [
  project_name/API/**/*
]
MatyasKriz commented 4 months ago

Yeah, as I said it should not generate mocks from the excluded types, but it will parse the type regardless so that if it's needed for inheritance you as the user can feely use it.

Does it create the mock in the generated mocks, if so, that might be an issue worth investigating?

Marquis103 commented 4 months ago

Yep it's creating the mocks which is the problem. We don't want to generate those mocks because they cause issues with the build overall. This mock in particular is a value type that conforms to this protocol, but for some reason the mock doesn't conform to CaseIterable. So I'd rather just leave it out.

protocol AuthenticationType: RawRepresentable, Hashable, CaseIterable {}

MatyasKriz commented 4 months ago

I see, that's weird, but I'm unable to reproduce it. If you can create a sample project with this issue present I can try fixing it.

Marquis103 commented 4 months ago

Ok I can try doing that