-
-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workarounds for incomplete tool settings #500
Comments
One way would be an optional pre execute Func. |
I think that this is a good idea. We only need to make it clear that
|
@devlead Why not a setting on the |
Wouldn't need to override per say, could be more of a "patch" where you get incoming args/settings and pass them back as return value from the delegate. |
@patriksvensson, yes, it needs to be clear that this is a brute force approach. Although I wouldn't necessarily want to make this the override all the command line args from settings -- we should still use the settings, but add the raw args to augment them. |
Yes it would make sense on the tool settings class, but wouldn't want to add all arguments if it's just 1 I'm missing. |
@devlead, that's exactly my feeling as well. So right now, we pretty much all construct our command line args inside the runner, right? Or perhaps into a different type (maybe something like an |
Here's what I'm trying right now, as a way to use a non-supported switch ( public class CustomizableProcessRunner : IProcessRunner
{
private readonly IProcessRunner _inner;
private readonly Action<ProcessArgumentBuilder> _argsCustomization;
public CustomizableProcessRunner(IProcessRunner inner,
Action<ProcessArgumentBuilder> argsCustomization)
{
if (inner == null)
{
throw new ArgumentNullException("inner");
}
if (argsCustomization == null)
{
throw new ArgumentNullException("argsCustomization");
}
_inner = inner;
_argsCustomization = argsCustomization;
}
IProcess IProcessRunner.Start(FilePath filePath, ProcessSettings settings)
{
_argsCustomization(settings.Arguments);
return _inner.Start(filePath, settings);
}
}
// ... in my script:
var runner = new CustomizableProcessRunner(cc.ProcessRunner, args => args.Append("-hideskipped:All"));
new OpenCoverRunner(cc.FileSystem, cc.Environment, runner, cc.Globber)
.Run(cc, tool => tool.NUnit(unitTestAssemblies,
new NUnitSettings
{
Framework = "net-4.0",
NoLogo = true,
ResultsFile = testResultsFile,
ShadowCopy = false,
Timeout = 5000 //(ms)
}),
coverageFile,
new OpenCoverSettings()
.ExcludeByAttribute("System.CodeDom.Compiler.GeneratedCodeAttribute")
.WithFilter("+[MyProjectName*]*")
.WithFilter("-[*Test*]*")); This is just a first try, but this basic approach might have some potential to be refined and incorporated into the Tools infrastructure. |
@jrnail23 while I see what you are doing, wouldn't another property on the Settings base class called So it would become:
In general, regardless of how it it implemented, I think this is a great idea. This allows for changes to the tools, i.e. addition of some arguments to the tool, to be immediately usable within a Cake script, rather than waiting for the an update to the Tool. Great idea! 👍 |
@gep13, you're right, this is just what I did as a workaround in my script itself, without modifying Cake at all. In other words, this is something you can use right now 😄 |
@jrnail23 gotcha 👍 Sounds like we are all on the same page :-D |
Yes. I agree with @gep13. Additional arguments would be really nice. |
One of the difficulties I've run into with Cake is when using tools, often the tool author has not included support for all options/switches that are available for command line execution.
When I want to use such a switch, I either have to invoke the tool using a raw process, or I have to submit a PR to support the switch and wait until the next release to use it.
Perhaps we can build in a way to allow devs to include raw command line args (in addition to using the supported settings properties), so we can more easily work around missing settings until they get added.
I'm thinking of something along the lines of what @patriksvensson did in #470, where he added a base settings class with the tool path. In this case, I'm thinking maybe we add a property to that base class for raw command line args, and somehow force the tool runner to include the raw args.
I'm sure others can think of better solutions as well.
Ideas? Thoughts?
The text was updated successfully, but these errors were encountered: