-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Improve Code Coverage on EnumConverter #39561
Improve Code Coverage on EnumConverter #39561
Conversation
Jacksondr5
commented
Jul 17, 2020
- Helps address Help get System.Text.Json test coverage to 100% (or close to it) #32341
- Adds coverage to branch where WriteWithQuotes goes over the name cache soft limit. code
- Adds coverage to branches where a Dictionary key is a numeric enum that is not in the cache and the value is not a valid identifier. code
I looked at writing a test for the constructer soft check, but I'm not sure if it's desired. Given that the other tests that cover the cache limit serialize up to 2097152 enums, I think we would need to have a hilariously large enum literal to truly test that the constructor code doesn't throw an OutOfMemoryException. Maybe I could do something with reflection, but I wanted to check before I wrote anything. Looks like there's a bug in how the coverage reporter interprets switch statements Are we able to cover lines that come after ThrowHelper statements? They look unreachable to me. |
I believe the checks were failing due to a build problem last week that looks to be resolved now. I don't think I have permissions to re-run the builds, can someone trigger that for me? |
src/libraries/System.Text.Json/tests/Serialization/EnumConverterTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/EnumConverterTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/EnumConverterTests.cs
Outdated
Show resolved
Hide resolved
}; | ||
|
||
Dictionary<T, int> dictionary; | ||
for (int i = 1; i < 60; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to <= 64 to resemble the soft limit regardless of the amount of cached names in warm-up?
E = 1 << 4, | ||
F = 1 << 5, | ||
G = 1 << 6, | ||
H = 1 << 7, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like H
is never used by SerilizeDictionaryWhenCacheIsFull
, you should remove it here and in the other enums.
I agree, the switch expression only contains 9 cases, I don't see how the coverage reports 9/11 branches, I would expect 8/9 since I don't think we can even cover the default case. Consider open an issue in https://github.com/danielpalme/ReportGenerator.
That code is unreachable because we throw but we still need to return in all code paths. |
Dug a bit deeper, the coverage branching issue actually seems to be a problem with coverlet. |
…roid (dotnet#40027) This reverts commit 60643c36f5d4e349276e5dcce0e7fc3dc1d72f74. To investigate error on android tests. Co-authored-by: thaystg <[email protected]>
* Fix parsing of embedded .clsidmap in comhost * Update tests to use HostModel to create/embed clsidmap
* s/MscorlibBinder/CoreLibBinder/ * s/g_Mscorlib/g_CoreLib/ * Remaining mscorlib->corelib renames * Delete unreachable FNV NGen string
Co-authored-by: Adeel Mujahid <[email protected]> Co-authored-by: Jan Kotas <[email protected]>
…otnet#39182) * [browser][wasm] Initial addition of configuring request options in Browser WebAssembly * Fix key code. Not what was proposed * Add TryGetValue<TValue> and Set<TValue> as per proposal * Add missing obsolete attribute * Address review comments * Update tests to use Options and not obsolete Properties. * Implement IDictionary<string, object?> explicitly * Update tests to use Options and not obsolete Properties. * Add HttpRequestOptions source to the System.Net.Http.Unit.Tests project to fix build. * Address review comments - explicit * Fix build error cannot convert from 'string' to 'System.Net.Http.HttpRequestOptionsKey<object>' * Add tests for HttpRequestOptions * Fix test build * Add special case code for NETFRAMEWORK for API change. * #endif out of place fix * #endif out of place fix
…g to check for a specific error code. Fixes dotnet#39955 (dotnet#40019)
…ace (dotnet#40004) There is no repro for dotnet#38807 at the moment so the related tests have been enabled. Two tests have been disabled due to PNSE (see dotnet#39346). Fixes: dotnet#38807 The test run result: `Tests run: 177, Errors: 0, Failures: 0, Skipped: 0.`
This was already disabled with autotools, but I forgot to update winconfig.h as well.
* Update using-dotnet-cli.md Update the First Run section for .NET 5. * more renames * typo Co-authored-by: danmosemsft <[email protected]>
…ce operand of GT_RETURN in case when it is a single-register local variable
* Minimal fix for Issue 620 Added test case: Runtime_620.cs Added lvForceLoadNormalize * Changed conditional to "else if"
…ils (dotnet#40110) * include more details in exception if remote certificate validation fails * fix unit test linking * feedback from review * update exception message
Co-authored-by: Geoffrey Kizer <[email protected]>
append -y option and add ``` around command code
…et#40548) * [wasm][debugger][tests] Fix negative pointer tests * [wasm][debugger][tests] Fix test to correctly check the valuetype local test: `CheckUpdatedValueTypeFieldsOnResume` * [wasm][debugger][tests] Make value checks consistent - In some places we weren't checking for the `description` property - and this hid a bug where sometimes that property wasn't added (eg. for numbers) - Instead, we were working around that by "fixing it up" later - Now, we use the same checks for `Check{Number,String,*}` API, and the `CheckValue/CheckProps` API used with `TNumber` etc. - So, this commit: - fixes the checks, and the tests - and fixes the bug * [wasm][debugger] Add new `id` types, which have associated properties - these are of the form `dotnet:${scheme}:{id-args-object}` - Examples: - `dotnet:valuetype:{ containerId: 4 }` - `dotnet:valuetype:{ num: 2 }` - the `num` field is autogenerated if no id-args are provided. This gets used when valuetypes are expanded. - `this._id_table [id-string]` has associated property objects for every `id` - This might contain, for example, `klass` pointer, and base64 representation of a valuetype * [wasm][debugger] Update valuetype code to use the new `id`s * [wasm][debugger] Simplify array API in `mini-wasm-debugger.c` .. to use a single function to get details of the full array, and individual elements. * [wasm][debugger] library_mono.js: improvements to valuetype code - Allow `_new_id` to update properties for existing objectIds - Extract valuetype id assigment code to a separate function * [wasm][debugger] mini-wasm-debugger.c- extract object id lookup into a function * [wasm][debugger][tests] Rename method param to be self descriptive * [wasm][debugger][tests] Rework cfo test for getters - add some new getters to the test classes - this will become useful in subsequent commits that add support for invoking getters on valuetypes * [wasm][debugger][tests] Improve valuetype locals/method args tests - this also becomes useful in subsequent commits which enable invoking getters on valuetypes * [wasm][debugger] Add support for invoking getters on valuetypes - keep a copy of the value bytes, and the klass pointer - this allows being able to invoke getters on such a valuetype, at a later point - This allows getters like `DateTime.Date`, which has the type `DateTime` * [wasm][debugger] mono.js: fix warnings .. and replace `var` with `let`, or `const`, where appropriate. * [wasm][debugger] mono.js: _split_object_id -> _parse_object_id * [wasm][debugger] Streamline accessing exported debugger.c functions .. especially the ones that return data in `MONO.var_info`. To use: 1. `this._register_c_var_fn ('mono_wasm_get_object_properties', 'bool', [ 'number', 'bool' ]);` 2. Now, this function can be called as `this.mono_wasm_get_object_properties_info (.. )` - returns `res` which has the contents of `MONO.var_info`, after running `_fixup_name_value_objects` on it. * [wasm][debugger] Return errors from debugger.c's details functions - functions like those for getting object/vt properties, can fail, for example, if the objectId is invalid. - We now return that bool result, and that gets surfaced to the caller - This will also help to differentiate the case where the result of such a function was a failure vs just an empty result * [wasm][debugger] Small checks on inputs, and some negative tests - These tests don't actually depend on the error message, and we don't have another to way to differentiate why a command might have failed with an exception. So, right now, they will pass as long as the commands fail as expected. - Future TODO: return `error`, instead of exception details for issues in `mono.js`, like incorrect input, invalid id etc, and update these tests accordingly. * Update src/mono/mono/mini/mini-wasm-debugger.c Co-authored-by: Larry Ewing <[email protected]> * Remove description checking from TString Co-authored-by: Larry Ewing <[email protected]>
Think I messed that one up..... I'll open another |