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
Add diagnostic message when JSON file is malformed #1655
Comments
I can take that one, but how do you suggest for it to be implemented. An analyzer seems to suit best, but you could also throw an exception during |
I was looking into this as well? how do you suggest it to be implemented? |
Seeing as the last two comments offering to pick this work up from 2019, I started working on a PR for this, should have it posted sometime tomorrow. |
* Adds proxy for ConfigReader to enable mock injection * Modifies xunit to emit diagnostic message per assembly Fixes xunit#1655
* Adds proxy for ConfigReader to enable mock injection * Modifies xunit to emit diagnostic message per assembly Fixes xunit#1655
* Adds proxy for ConfigReader to enable mock injection * Modifies xunit to emit diagnostic message per assembly Fixes xunit#1655
@bradwilson Hey, I took a look at this issue as I was thinking of taking it and the (now stalled) pr you commented on and while I think there are ways to handle this, I think it comes down to have the runner receive an exception it handles on ConfigReader.Load. Where I am unsure is it looks to me as if this method was designed to have a distinction between failing to load, but without needing to report it and failing to load due to a problem that does need the runner's attention (such as is the case with this issue). The problem is checking usage, no one seems to care about the actual bool return except the utility runner's tests. This makes the intention ambiguous: do we care about whether or not it succeeded or we care about why it failed? I do agree with the pr's author that returning a null string seems odd: it doesn't sound obvious to me what such a string would represent. How about changing the method to Alternatively, if any failure is considered an error, then I think the better approach would be to throw. In such case, who is responsible for catching? The runner? Incidentally, this approach has the advantage that little signature changes are needed because the exceptions can be bubble up to the runner. Once I have a clearer ideas on these, I could move forward and submit a pr superseding the previous one. |
I haven't really thought much about this since the previous PR, so I went back and reviewed it. I think the best thing would be to just add something like Later if users desire, we could add a switch to runners to say "treat config warnings as errors" so that it would fail the run rather than just ignore the problems. The complexity comes in because of the existing v2The two APIs today are: TestAssemblyConfiguration Load(string assemblyFileName, string configFileName = null)
TestAssemblyConfiguration Load(Stream configStream) I think we'd want to obsolete the old overloads, implemented as calls through to the new APIs, and just throw away the warnings. The new APIs would be: TestAssemblyConfiguration Load(string assemblyFileName, string configFileName, out List<string> warnings)
TestAssemblyConfiguration Load(Stream configStream, out List<string> warnings) v3In v3, we've already consolidated down to a single API: bool Load(TestAssemblyConfiguration configuration, string? assemblyFileName, string? configFileName = null) Since v3 hasn't shipped yet, so no need to do obsoletes, just convert it to this: bool Load(TestAssemblyConfiguration configuration, string? assemblyFileName, string? configFileName, out List<string> warnings) (I'm not 100% sure why I don't have a Thoughts? |
This seems fine by me. One more thing for me to at least do the v3 part: how do each runners emit warnings? Is there a standard shared way like an interface between hem to do this? |
There is one,
|
Available in v2 runners: |
Related: #1654
The text was updated successfully, but these errors were encountered: