Repository navigation
Conversation
Test targets follow SwiftPM naming, one per tested target: the framework tests live in MockoloFrameworkTests at the default path, making room for a MockoloTests target for the executable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
generate() takes dependencySourceFiles: declarations parsed from these files resolve inherited types of the source protocols but are never mocked and never replace a source declaration. When several dependency files declare the same name, the earliest file in the list wins. The existing import merges in generate() now use Dictionary.merge too, to match the new block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mockolo --config reads a JSON5 file describing the run. It can set sources (directories and files, relative to the config file) and destination, so --destination is no longer required when the config sets it. --sourcedirs, --filelist or --sourcefiles replace sources and --destination overrides destination. Unknown keys, wrong types, null values and missing paths fail with the config path and the key path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The config file can set module and dependencies, a map from module name to source directories and files. Dependency declarations resolve inherited types of the sources but are never mocked; modules are read in name order and the CLI source options leave them unchanged. module is reserved for module-qualified lookup. Empty module names are errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he config The config file can set annotation, header, macro, concurrencyLimit and loggingLevel. The CLI value overrides the config's, which overrides the default. A loggingLevel outside 0 to 3 in the config is an error even when --logging-level overrides it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The config file can set mockFinal, enableArgsHistory, mockAll, allowSetCallCount, disableCombineDefaultValues and useTemplateFunc. Either the CLI flag or the config value turns each one on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s to the config The config file can set customImports, testableImports, excludeImports and excludeSuffixes. The CLI list replaces the config's list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The config file can set mockfiles, parent mock files and directories relative to the config file, checked and expanded like sources. --mockfiles or --mock-filelist on the command line replaces the config's list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I recommend checking the diff commit by commit for easier review. The first commit renaming the test target is arguably not the scope of this PR but adding a new test target begged for using the default naming conventions for the tests. Let me know what you think and I'm happy to adjust / split. |
|
@sidepelican gentle ping if you have time to review. Please let me know what to change / how do you like it. |
|
I lost my maintainer access to mockolo after Uber recently updated its 2FA requirements. I’ve also had less time to spend on mockolo maintenance lately. Given @farkasseb ’s recent contributions, I think they’d make a great maintainer. Could you consider adding them to the team as well? |
| import ArgumentParser | ||
| import Foundation | ||
|
|
||
| enum ConfigSchema { |
There was a problem hiding this comment.
ConfigSchema seems to be used only for decoding, and it feels like more code than we need here.
Could we simplify this by using decoder.decode(Config.self, from: data) directly?
There was a problem hiding this comment.
I used it to catch unknown keys, so typos fail loudly (and also to catch explicit nulls, which I could drop since every key is optional anyway). A plain decode(Config.self, from:) ignores unknown keys. I could drop ConfigSchema and keep just that check implemented differently, maybe comparing top-level keys. I'm not 100% sure if that's better but happy to go either direction. What's your suggestion?
There was a problem hiding this comment.
I’d suggest dropping ConfigSchema and decoding Config directly.
Catching unknown keys feels like a nice-to-have here, but I’d prioritize keeping the implementation simple and stick with the default JSONDecoder behavior that Swift developers are familiar with.
There was a problem hiding this comment.
Done! I kept a small DecodingError → ValidationError mapping, let me know if that should also be cut. It's making the error message much nicer and more informative so I'd keep it but up to you.
Drop ConfigSchema and decode Config with JSONDecoder, as suggested in review. Unknown keys are now ignored and null counts as absent. A DecodingError becomes a ValidationError that names the config file, the key path when the decoder gives one, and the decoder's message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sidepelican
left a comment
There was a problem hiding this comment.
LGTM, thank you!
But I don't have any permissions now ... 😥
|
Hi @rudro, could you help with the mockolo maintainer access request at #368 (comment) ? Thanks! |
Summary
Adds the config file agreed in #363: one JSON5 file per run, with paths relative to the file. It accepts every key below:
true.dependenciesare keyed by module name, but types still resolve by name alone.--dependency-sourcedirsfrom Add dependency sources for cross-module inheritance #363 is dropped.generate()gainsdependencySourceFiles:.Tests/MockoloFrameworkTests/, and the newTests/MockoloTests/runs the built binary.Blast Radius: additive. Existing command lines behave as before. Linux toolchains older than 6.0 read strict JSON only.
🤖 Generated with Claude Code