-
Notifications
You must be signed in to change notification settings - Fork 871
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
Using TestRunSystem while creating the TestRun #1637
Changes from all commits
7959339
ab4cd4c
baee89a
e3d1221
d7a3499
00463b6
f373dd6
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 |
---|---|---|
|
@@ -23,6 +23,8 @@ public sealed class ResultsCommandExtension : AgentService, IWorkerCommandExtens | |
private bool _publishRunLevelAttachments; | ||
private int _runCounter = 0; | ||
private readonly object _sync = new object(); | ||
private string _testRunSystem; | ||
private const string _testRunSystemCustomFieldName = "TestRunSystem"; | ||
|
||
public Type ExtensionType => typeof(IWorkerCommandExtension); | ||
|
||
|
@@ -198,6 +200,7 @@ private async Task PublishAllTestResultsToSingleTestRunAsync(List<string> result | |
); | ||
|
||
testRunData.Attachments = runAttachments.ToArray(); | ||
testRunData.AddCustomField(_testRunSystemCustomFieldName, _testRunSystem); | ||
|
||
TestRun testRun = await publisher.StartTestRunAsync(testRunData, _executionContext.CancellationToken); | ||
await publisher.AddResultsAsync(testRun, runResults.ToArray(), _executionContext.CancellationToken); | ||
|
@@ -229,14 +232,16 @@ private async Task PublishToNewTestRunPerTestResultFileAsync(List<string> result | |
.Select(bucket => bucket.Select(pair => pair.file).ToList()) | ||
.ToList(); | ||
|
||
bool changeTestRunTitle = resultFiles.Count > 1; | ||
|
||
foreach (var files in groupedFiles) | ||
{ | ||
// Publish separate test run for each result file that has results. | ||
var publishTasks = files.Select(async resultFile => | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
string runName = null; | ||
if (!string.IsNullOrWhiteSpace(_runTitle)) | ||
string runName = _runTitle; | ||
if (!string.IsNullOrWhiteSpace(_runTitle) && changeTestRunTitle) | ||
{ | ||
runName = GetRunTitle(); | ||
} | ||
|
@@ -248,6 +253,7 @@ private async Task PublishToNewTestRunPerTestResultFileAsync(List<string> result | |
|
||
if (testRunData != null && testRunData.Results != null && testRunData.Results.Length > 0) | ||
{ | ||
testRunData.AddCustomField(_testRunSystemCustomFieldName, _testRunSystem); | ||
TestRun testRun = await publisher.StartTestRunAsync(testRunData, _executionContext.CancellationToken); | ||
await publisher.AddResultsAsync(testRun, testRunData.Results, _executionContext.CancellationToken); | ||
await publisher.EndTestRunAsync(testRunData, testRun.Id, cancellationToken: _executionContext.CancellationToken); | ||
|
@@ -356,6 +362,12 @@ private void LoadPublishTestResultsInputs(IExecutionContext context, Dictionary< | |
_runTitle = string.Empty; | ||
} | ||
|
||
eventProperties.TryGetValue(PublishTestResultsEventProperties.TestRunSystem, out _testRunSystem); | ||
if (_testRunSystem == null) | ||
{ | ||
_testRunSystem = string.Empty; | ||
} | ||
|
||
string publishRunAttachmentsInput; | ||
eventProperties.TryGetValue(PublishTestResultsEventProperties.PublishRunAttachments, out publishRunAttachmentsInput); | ||
if (string.IsNullOrEmpty(publishRunAttachmentsInput) || !bool.TryParse(publishRunAttachmentsInput, out _publishRunLevelAttachments)) | ||
|
@@ -391,5 +403,6 @@ internal static class PublishTestResultsEventProperties | |
public static readonly string RunTitle = "runTitle"; | ||
public static readonly string PublishRunAttachments = "publishRunAttachments"; | ||
public static readonly string ResultFiles = "resultFiles"; | ||
public static readonly string TestRunSystem = "testRunSystem"; | ||
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. TestRunSystem 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 thought it would be better and consistent if I follow like other properties. 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. this is different from other as in this case this is predefined custom field. 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. Yeah, makes sense. But here it's an even property which will be coming from node. So still having it as is. But when creating the field, having the right case, as you suggested. |
||
} | ||
} |
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.
default value should be VSTS instead of empty ? check with PM once.
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.
Yeah, but that will come from the caller vsts-task-lib api call. microsoft/azure-pipelines-task-lib#373