-
Notifications
You must be signed in to change notification settings - Fork 31
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
Unit test conversion and TGD modernization (WIP) #260
Unit test conversion and TGD modernization (WIP) #260
Conversation
Takes care of the CodeQL warnings from #15
Takes care of 2 inspections VS was throwing
Replaces GetArray Using framework naming convention for methods that return boolean status and have out parameters that are non-null on success There's another use of the old method, but I have to stare at it a bit more to see what it's really doing. Might need to discuss that one when we chat.
…o convert-tests-to-constraint-model Interim merge for #15 There's more to be done, but I'm going to get back to test conversion for a bit, now that several of the loudest issues are addressed
github wants this re-pushed after switch to advanced
Takes care of the CodeQL warnings from #15
Takes care of 2 inspections VS was throwing
Use null propagation Private members that can or should be readonly Reduce allocations, garbage, and enumerations with this List Add TryGetArray<T> Using framework naming convention for methods that return boolean status and have out parameters that are non-null on success There's another use of the old method, but I have to stare at it a bit more to see what it's really doing. Might need to discuss that one when we chat.
Convert ColorSchemeTests to Constraint model Get10By10View can be static
Also allows the list to be readonly
Unrolled a ton of test cases Expanded scope of tests significantly
Combine both GetCode tests into a single unrolled method Unroll some more tests Add more cases to some tests
Most assertions removed because, if the IsAbsolute assertion passes, they are redundant to the IsAbsolute test cases.
…nto convert-tests-to-constraint-model * 19-convert-postests-to-constraint-model: More coverage. Bugs revealed. Add test for method that wasn't covered. Revealed a bug That was accidentally committed a while back. Remove it. Convert the rest but ignore them, because they're redundant Remove this test, as it's solely a Terminal.Gui test Remove redundant test Convert this case That's not valid Fix nullability context in PosExtensions Remove redundant test Finish unrolling and expanding IsAnchorEnd tests Remove redundant tests More refactoring New tests revealed this bug Significant refactor Global usings Add a couple of handy helper types for tests to cut down on boilerplate Still work in progress. Revealed several bugs through increased test coverage. #19
I just did a bunch of work on the PosTests fixture. Coverage was increased significantly, and it revealed several bugs, most of which are noted in PosExtensions.cs or in output of tests marked Ignore (visible in test results, while allowing the fixture to "pass" for now). The current state of that is merged to this branch. I have not yet fixed them, as I wanted to call attention in case that raises any alarms/thoughts on your end. Some of them are the fault of Terminal.Gui itself, but I'm pretty sure we can work around them without much work. |
Thanks. This is awesome work. I have done a bit of manual testing and everything seems working in the editor and all the tests pass so I have merged. Feel free to continue working on this branch or create a new one. The diff was getting a bit unwieldy so I thought it was best to merge in. I looked into the Pos issue and I have created a new bug in Terminal.Gui itself. I have had to do some of this 'unpacking' of PosCombine 0 before but really it shouldn't be a thing for so simple a method: |
Yeah, I'm cool with treating this branch as safe to merge. I do individual work items on separate branches (one per issue, for the most part), and then merge them into this one, when done, if you ever want to look at more bite-sized chunks (or you can at least still see where they merged in, even if I've deleted the branch spec by the time you see it. Those of course show up in the history here, basically looking like a squashed copy of all the commits on each branch into this one. I'll keep noting in the commits and annotating in code, when I find bugs and such, unless they're simple and non-impacting, in which case I'm likely to just go ahead and take care of it in the moment, like how I went ahead and put the nullable context However, there were a couple of changes over the past few merges that are a bit bigger than nullability context:
I think we should do a workaround and fix for that, for a couple of reasons, regardless of if it gets fixed in Terminal.Gui. Most importantly, if it's a generic Pos, which is the only kind Terminal.Gui actually exposes publicly, any one of the IsWhateverTypeOfPos() methods will return true, if it's null. But, also, TGD has a bug in that it treats Pos types created from a literal value as absolute and zero, but then has inconsistent behavior because those methods all just return true, which breaks that assumption. Also, I think it would be good for Terminal.Gui to actually expose the sub-classes of Pos, because they're useful to be able to identify by their type, rather than having to do what TGD already has to do, which is that string comparison of the type name. If that's "fixed" in Terminal.Gui, we wouldn't have to do that any more, which would be great. I really don't see or understand the reason for those being internal classes, over there. It creates a potential problem with inheritance, anyway, if someone were to inherit from Pos. Also, if TG exposed those types publicly, many of those extension methods would actually just plain no longer be necessary, since they're essentially a workaround for that design detail. The only reason I didn't go ahead and do the fix to the part we have control over, on the TGD end (it would be suuuuper simple), is because that could have subtle effects in the UI, if any code paths actually do reach that stuff, at runtime, and I just wanted to make you aware of it before I touched anything, in case some report were to come in related to it. I have a pretty strong feeling it does hit them, sometimes, because I've had cases when using TGD where a position mysteriously turns into another type of position, if something didn't work out quite right. Now that I've seen where that most likely comes from, I'm pretty sure fixing the null handling will, at minimum, reduce the instance of that, or at least bubble the underlying problem up to something more obvious that can be addressed, if that's not the root of it. Alrighty. Enough rambling for now. 😅 |
Any ideas @dodexahedron? I can't see anything that looks like it would change the CI except Well that also is not responsible because removing it did nothing (see on test branch) https://github.com/gui-cs/TerminalGuiDesigner/actions/runs/7857029886/job/21440440937 |
Moving this to an issue: #288 |
This is a work-in-progress for conversion of unit tests for TGD to NUnit 4.0, as well as expansion, improvement, and modernization of various tests.
This also includes some preliminary incidental modernization work on TGD itself, primarily aimed at eliminating some reflection, and some redundant operations.
See https://github.com/dodexahedron/TerminalGuiDesigner for current activity