-
Notifications
You must be signed in to change notification settings - Fork 9
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
OSOE-464: Making dotnet test output go to the build output to aid debugging, as well as printing ITestOutputHelper content #101
Changes from 41 commits
51dfe31
a997a7b
0f13926
1d5c001
d3fa27e
e3d3ec7
e371d76
2e6636d
c341ef1
03008f5
75a9726
243ff58
2ce191d
82a5323
0eeda56
a5c1a40
8597152
659dc73
6998a75
220d729
e81ce27
84141ba
5a9a831
4912bec
7827fa4
9a5b62a
7f4e3e9
829c298
1f56fac
96383e0
187e1d8
92eb9f7
3825d1e
9fa4d0b
829fa11
9795fed
e30a536
4f93303
acb5f5f
6865a0b
0fdd730
2965e67
fbdbebb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,39 +31,47 @@ $tests = dotnet sln list | | |
Select-String "\.Tests\." | | ||
Select-String -NotMatch "Lombiq.Tests.UI.csproj" | | ||
Select-String -NotMatch "Lombiq.Tests.csproj" | | ||
? { | ||
Where-Object { | ||
$result = dotnet test --no-restore --list-tests --verbosity $Verbosity $_ 2>&1 | Out-String -Width 9999 | ||
-not [string]::IsNullOrEmpty($result) -and $result.Contains("The following Tests are available") | ||
} | ||
|
||
Write-Output "Starting to execute tests from $($tests.Length) projects." | ||
|
||
foreach ($test in $tests) { | ||
# This could benefit from grouping, above the level of the potential groups created by the tests (the Lombiq UI | ||
# Testing Toolbox adds per-test groups too). However, there's no nested grouping, see | ||
# https://github.com/actions/runner/issues/1477. See the # c341ef145d2a0898c5900f64604b67b21d2ea5db commit for a | ||
# nested grouping implementation. | ||
|
||
Write-Output "Starting to execute tests from the $test project." | ||
|
||
$dotnetTestSwitches = @( | ||
'--configuration', 'Release' | ||
'--no-restore', | ||
'--no-build', | ||
'--nologo', | ||
'--logger', 'trx;LogFileName=test-results.trx' | ||
# This is for xUnit ITestOutputHelper, see https://xunit.net/docs/capturing-output. | ||
'--logger', 'console;verbosity=detailed' | ||
'--verbosity', $Verbosity | ||
sarahelsaig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$Filter ? '--filter' : '' | ||
$Filter ? $Filter : '' | ||
$test | ||
) | ||
|
||
dotnet test @dotnetTestSwitches 2>&1 >test.out | ||
# Filtering is necessary for annoying messages coming from UI testing but only under Ubuntu. There are no actual | ||
# errors. | ||
dotnet test @dotnetTestSwitches 2>&1 | | ||
Where-Object { $_ -notlike '*Connection refused [[]::ffff:127.0.0.1[]]*' -and $_ -notlike '*ChromeDriver was started successfully*' } | ||
|
||
if ($?) | ||
{ | ||
Write-Output "Test Successful: $test" | ||
Write-Output "Test successful: $test" | ||
continue | ||
} | ||
|
||
$needsGrouping = (Select-String "::group::" test.out).Length -eq 0 | ||
|
||
if ($needsGrouping) { Write-Output "::group::Test Failed: $test" } | ||
|
||
bash -c "cat test.out | grep -v 'Connection refused \[::ffff:127.0.0.1\]' | grep -v 'ChromeDriver was started successfully'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we still filter out these pointless "Connection refused" and "ChromeDriver" log lines on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know or have found a way to live-filter a streaming output, though I only have smallish experience with PS. The goal here is for the output of the tests to show up in the log continuously (to pinpoint what the last thing was before the runner was killed due to timeout). If there's a file at the end of the We could still redirect to a file and tail it and that can be filtered but going through a file doesn't seem like the best idea, and we also need to somehow know when the stream actually ended and quit the So, I don't know. It seems to me that implementing grouping around the test project if it doesn't have its custom group and letting UI tests group themselves, as well as filtering out such messages need a file. If we have a file, however, we won't have a continuous output. Do you have any suggestions by chance? BTW I'm also trying to figure out where the annoying log messages come from and disable them in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah nice, so this works like this! |
||
|
||
if ($needsGrouping) { Write-Output "::endgroup::" } | ||
Write-Output "Test failed: $test" | ||
|
||
exit 100 | ||
} |
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 had some fun experimenting around with this without avail.
But at least I had fun.