Skip to content
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

Closed

Conversation

Jacksondr5
Copy link
Contributor

@dnfadmin
Copy link

dnfadmin commented Jul 17, 2020

CLA assistant check
All CLA requirements met.

@Jacksondr5
Copy link
Contributor Author

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
image
Hovering over the branch icon on L245 shows that 9 of 11 branches are covered. Given that it's 7 PM on a Friday for me, I don't want to make any strong claims involving math, but those numbers don't seem right to me.

Are we able to cover lines that come after ThrowHelper statements? They look unreachable to me.

@Jacksondr5
Copy link
Contributor Author

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?

@layomia layomia added this to the 5.0.0 milestone Jul 31, 2020
};

Dictionary<T, int> dictionary;
for (int i = 1; i < 60; i++)
Copy link
Member

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,
Copy link
Member

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.

@jozkee
Copy link
Member

jozkee commented Aug 5, 2020

Hovering over the branch icon on L245 shows that 9 of 11 branches are covered. Given that it's 7 PM on a Friday for me, I don't want to make any strong claims involving math, but those numbers don't seem right to me.

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.

Are we able to cover lines that come after ThrowHelper statements? They look unreachable to me.

That code is unreachable because we throw but we still need to return in all code paths.

@Jacksondr5
Copy link
Contributor Author

Dug a bit deeper, the coverage branching issue actually seems to be a problem with coverlet.

danmoseley and others added 17 commits August 9, 2020 23:10
…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
…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
…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.
AustinWise and others added 13 commits August 9, 2020 23:11
* 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]>
@Jacksondr5
Copy link
Contributor Author

Think I messed that one up..... I'll open another

@Jacksondr5 Jacksondr5 deleted the SystemTextJson-Enum-Test-Coverage branch August 10, 2020 03:18
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.