-
Notifications
You must be signed in to change notification settings - Fork 191
Investigate UT failures happening on Linux/mac in CI build #198
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
Comments
The For this code specifiying the URI of a newly created repo (without issues): $issues = Get-GitHubIssue -Uri $Uri
@($issues).count PowerShell 5 will return 0, but PowerShell 7 will return 1. I suggest removing the array sub-expression operator around |
If you want to be consistent and run the unit tests on PowerShell 7 for Windows, Linux and Mac, change your |
Thanks so much @X-Guardian! It hadn't occurred to me that the difference was due to PoSh 7 vs <7. I've been able to repro the UT failures on my Windows machine with PoSh 7 and I'm now making the fixes. That difference in behavior between array handling in 7 is quite interesting. I don't want to switch the CI to only using Again -- thanks for taking the time to investigate and respond! |
… UT's on all platforms) (#199) Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x. There's a slight difference in behavior for how those two treat arrays. The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array: https://github.com./microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648 `...` https://github.com./microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670 Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously). I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side. https://github.com./microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685 I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise. With this change, we should now be passing CI on all OS platforms and across PowerShell 4+. Resolves #198
We have recently disabled UT's for Linux and Mac in the CI build because there have been unexpected failures during execution that don't appear to happen when run locally (at least for Linux). I'd like to get those re-enabled for full coverage, but they've been disabled in the short term to ensure that we can get real value out of the CI build since Windows is running cleanly right now.
The text was updated successfully, but these errors were encountered: