-
Notifications
You must be signed in to change notification settings - Fork 237
(maint) Add Xunit Trait Filter #818
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
(maint) Add Xunit Trait Filter #818
Conversation
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.
LGTM
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.
LGTM!
PowerShellEditorServices.build.ps1
Outdated
function XunitTraitFilter { | ||
$TraitFilter = '' | ||
# Reference https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests | ||
if (![string]::IsNullOrEmpty($TestFilter)) { $TraitFilter = "-trait $TestFilter" } |
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.
Since $TestFilter
is type string, it is sufficient to use the more canonical if (!$TestFilter) { ... }
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.
Actually this whole function could be simplified to just:
if ($TestFilter) { "-train $TestFilter" } else { "" }
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.
if (!$TestFilter)
{
return ""
}
"-train $TestFilter"
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.
I can change it but I'm not really a fan of that kind of operation. It makes things like if ("False") { Write-Out "This is True" }
confusing. I prefer explicit checks
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.
if ($TestFilter)
is still an explicit check of "is string null or empty" and sorry but "False"
is not null or empty. I mean, underneath PS is just doing string.IsNullOrEmpty for you.
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.
Also, in the vein of please follow the coding style that already exists in the script, you will see this style:
if (-not $name)
...
if ($env:APPVEYOR) {
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.
Changed.
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.
My feeling is that it's a common convention in Python, JS and PowerShell for a reason. It can be abused, but this case is precisely the design intent. Same as return value || default
.
In PowerShell's case, calling the C# APIs is sometimes less robust; PowerShell's coercions absorb more possible bad cases with less code.
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.
LGTM other than minor style, simplification comments.
Previously when running tests all test would need to be run, however when this can take a while. This commit adds an option to add a trait filter to XUnit as per the Xunit documentation [1]. Later commits may add the actual trait attributes to the tests. [1] https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
574dcb6
to
4764566
Compare
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.
LGTM
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.
LGTM
Previously when running tests all tests would need to be run, however when developing this
can take a while. This commit adds an option to add a trait filter to XUnit
as per the Xunit documentation [1]. Later commits may add the actual trait
attributes to the tests.
[1] https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests