Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Compilation error for ignored class

Open kurtguenther opened this issue 7 years ago • 4 comments

I have an input file that contains two protocols and one class. I would like Cuckoo to ignore the class.

Despite running cuckoo with the options --no-classes and --exclude ClassName I still get errors from Cuckoo trying to mock the class. The class contains private variables with inferred types (e.g. private let foo = true) and Cuckoo gives the error:

error: Type of instance variable frames could not be inferred. Please specify it explicitly. (/path/to/input.swift)

I would expect that Cuckoo doesn't even do these checks if it's told to ignore this class.

kurtguenther avatar Jun 28 '17 02:06 kurtguenther

This is weird, it should really ignore those declarations (either all classes or those with excluded names). This is reported to console and it ends with non-zero result code?

TadeasKriz avatar Jun 28 '17 18:06 TadeasKriz

@kurtguenther Could it be that the classname you're trying to exclude has a generic type definition?

nxtstep avatar Dec 28 '17 20:12 nxtstep

Nope, they are standard non generic classes.

kurtguenther avatar Dec 28 '17 20:12 kurtguenther

I just checked the code. The issue is that Cuckoo tokenizes by file, not by component. Therefore the file is tokenized (and the tokenizer complains to stderr about the unknown type) and after that the token is removed from the token collection.

From my standpoint I see 2 solutions: either pass the info that we wish to keep classes alone as well as excluded names (and the regex with the new version) which would make things really ugly and violate DRY quite a lot, because we're doing the checks in the mock generator as well. The other, cleaner, solution is to remove all the stderr printings from Tokenizer, make it shut up about the errors it encounters and let the mock generator report them after filtering out the tokens that don't belong with the others. I think the second solution is possible to do without any changes to the Token. If we wanted the Tokenizer to create the messages, we could create some Error? to the Token which would get printed by the mock generator after filtering the tokens. The second solution needs to iterate through the tokens one more time and I think it's a better option over doing the same filtering twice.

MatyasKriz avatar Apr 07 '18 14:04 MatyasKriz