Skip to content

Commit

Permalink
Merge branch 'master' into users/nidabas/removePublishMetadataVar
Browse files Browse the repository at this point in the history
  • Loading branch information
dabasnidhi authored Nov 14, 2019
2 parents 9c0b7d5 + 20b601f commit 526128e
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"loc.input.help.configuration": "Build configuration against which the tests should be reported. If you have defined a variable for configuration in your build task, use that here.",
"loc.input.label.publishRunAttachments": "Upload test attachments",
"loc.input.help.publishRunAttachments": "Opt in/out of publishing run level attachments.",
"loc.input.label.failOnMinTestsNotRun": "Fail the task if a minimum number of tests are not run.",
"loc.input.help.failOnMinTestsNotRun": "Selecting this option will fail the task if specified minimum number of tests is not run.",
"loc.input.label.minimumExpectedTests": "Minimum # of tests",
"loc.input.help.minimumExpectedTests": "Specify the minimum # of tests that should be run for the task to succeed. Total tests executed is calculated as the sum of passed, failed and aborted tests.",
"loc.input.label.diagnosticsEnabled": "Collect advanced diagnostics in case of catastrophic failures",
"loc.input.help.diagnosticsEnabled": "Collect advanced diagnostics in case of catastrophic failures.",
"loc.input.label.collectDumpOn": "Collect process dump and attach to test run report",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VsTestV2/distributedtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class DistributedTest {

const dtaExecutionHostTool = tl.tool(path.join(__dirname, 'Modules/DTAExecutionHost.exe'));
dtaExecutionHostTool.arg(['--inputFile', inputFilePath]);
const code = await dtaExecutionHostTool.exec(<tr.IExecOptions>{ ignoreReturnCode:this.inputDataContract.ExecutionSettings.IgnoreTestFailures, env: envVars });
const code = await dtaExecutionHostTool.exec(<tr.IExecOptions>{ ignoreReturnCode:this.inputDataContract.TestReportingSettings.ExecutionStatusSettings.IgnoreTestFailures, env: envVars });

//hydra: add consolidated ci for inputs in C# layer for now
const consolidatedCiData = {
Expand Down
10 changes: 8 additions & 2 deletions Tasks/VsTestV2/inputdatacontract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface TestReportingSettings {
TestResultsDirectory : string;
TestRunSystem : string;
TestSourceSettings : TestSourceSettings;
ExecutionStatusSettings : ExecutionStatusSettings;
}

export interface TestSelectionSettings {
Expand Down Expand Up @@ -95,8 +96,7 @@ export interface ExecutionSettings {
DefaultTestBatchSize : number;
AssemblyLevelParallelism : boolean;
CodeCoverageEnabled : boolean;
PathToCustomTestAdapters : string;
IgnoreTestFailures : boolean;
PathToCustomTestAdapters : string;
ProceedAfterAbortedTestCase : boolean;
PathToCustomVsTestConsoleWrapperAssembly : string;
SettingsFile : string;
Expand All @@ -114,6 +114,12 @@ export interface TestSourceSettings {
PullRequestTargetBranchName : string;
}

export interface ExecutionStatusSettings {
IgnoreTestFailures : boolean;
MinimumExecutedTestsExpected : number;
ActionOnThresholdNotMet : string;
}

export interface DiagnosticsSettings {
Enabled : boolean;
DumpCollectionType : string;
Expand Down
19 changes: 16 additions & 3 deletions Tasks/VsTestV2/inputparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ function getTestReportingSettings(inputDataContract : idc.InputDataContract) : i

inputDataContract.TestReportingSettings.TestSourceSettings = <idc.TestSourceSettings>{};
inputDataContract.TestReportingSettings.TestSourceSettings.PullRequestTargetBranchName = tl.getVariable('System.PullRequest.TargetBranch');

inputDataContract.TestReportingSettings.ExecutionStatusSettings = <idc.ExecutionStatusSettings>{};
inputDataContract.TestReportingSettings.ExecutionStatusSettings.IgnoreTestFailures = utils.Helper.stringToBool(tl.getVariable('vstest.ignoretestfailures'));
if (utils.Helper.isNullEmptyOrUndefined(inputDataContract.TestReportingSettings.TestRunTitle)) {

let definitionName = tl.getVariable('BUILD_DEFINITIONNAME');
Expand All @@ -181,6 +182,20 @@ function getTestReportingSettings(inputDataContract : idc.InputDataContract) : i

inputDataContract.TestReportingSettings.TestRunTitle = `TestRun_${definitionName}_${buildOrReleaseName}`;
}

const actionOnThresholdNotMet = tl.getBoolInput('failOnMinTestsNotRun');
if (actionOnThresholdNotMet)
{
inputDataContract.TestReportingSettings.ExecutionStatusSettings.ActionOnThresholdNotMet = "fail";
const miniumExpectedTests = parseInt(tl.getInput('minimumExpectedTests'));
if (!isNaN(miniumExpectedTests)) {
inputDataContract.TestReportingSettings.ExecutionStatusSettings.MinimumExecutedTestsExpected = miniumExpectedTests;
console.log(tl.loc('minimumExpectedTests', inputDataContract.TestReportingSettings.ExecutionStatusSettings.MinimumExecutedTestsExpected));
} else {
throw new Error(tl.loc('invalidMinimumExpectedTests :' + tl.getInput('minimumExpectedTests')));
}
}

return inputDataContract;
}

Expand Down Expand Up @@ -346,8 +361,6 @@ function getExecutionSettings(inputDataContract : idc.InputDataContract) : idc.I
}
console.log(tl.loc('pathToCustomAdaptersInput', inputDataContract.ExecutionSettings.PathToCustomTestAdapters));

inputDataContract.ExecutionSettings.IgnoreTestFailures = utils.Helper.stringToBool(tl.getVariable('vstest.ignoretestfailures'));

inputDataContract.ExecutionSettings.ProceedAfterAbortedTestCase = false;
if (tl.getVariable('ProceedAfterAbortedTestCase') && tl.getVariable('ProceedAfterAbortedTestCase').toUpperCase() === 'TRUE') {
inputDataContract.ExecutionSettings.ProceedAfterAbortedTestCase = true;
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VsTestV2/make.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dest": "./"
},
{
"url": "https://testexecution.blob.core.windows.net/testexecution/10738269/TestAgent.zip",
"url": "https://testexecution.blob.core.windows.net/testexecution/10889838/TestAgent.zip",
"dest": "./Modules"
},
{
Expand Down
4 changes: 2 additions & 2 deletions Tasks/VsTestV2/nondistributedtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class NonDistributedTest {
const exitCode = await this.startDtaExecutionHost();
tl.debug('DtaExecutionHost finished');

if (exitCode !== 0 && !this.inputDataContract.ExecutionSettings.IgnoreTestFailures) {
if (exitCode !== 0 && !this.inputDataContract.TestReportingSettings.ExecutionStatusSettings.IgnoreTestFailures) {
tl.debug('Modules/DTAExecutionHost.exe process exited with code ' + exitCode);
tl.setResult(tl.TaskResult.Failed, tl.loc('VstestFailed'), true);
return;
Expand Down Expand Up @@ -79,7 +79,7 @@ export class NonDistributedTest {
}

const execOptions: tr.IExecOptions = <any>{
IgnoreTestFailures: this.inputDataContract.ExecutionSettings.IgnoreTestFailures,
IgnoreTestFailures: this.inputDataContract.TestReportingSettings.ExecutionStatusSettings.IgnoreTestFailures,
env: envVars,
failOnStdErr: false,
// In effect this will not be called as failOnStdErr is false
Expand Down
23 changes: 21 additions & 2 deletions Tasks/VsTestV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 160,
"Patch": 2
"Minor": 161,
"Patch": 0
},
"demands": [
"vstest"
Expand Down Expand Up @@ -407,6 +407,25 @@
"helpMarkDown": "Opt in/out of publishing run level attachments.",
"groupName": "reportingOptions"
},
{
"name": "failOnMinTestsNotRun",
"type": "boolean",
"label": "Fail the task if a minimum number of tests are not run.",
"defaultValue": "False",
"required": false,
"helpMarkDown": "Selecting this option will fail the task if specified minimum number of tests is not run.",
"groupName": "reportingOptions"
},
{
"name": "minimumExpectedTests",
"type": "string",
"label": "Minimum # of tests",
"defaultValue": "1",
"required": false,
"helpMarkDown": "Specify the minimum # of tests that should be run for the task to succeed. Total tests executed is calculated as the sum of passed, failed and aborted tests.",
"groupName": "reportingOptions",
"visibleRule": "failOnMinTestsNotRun = true"
},
{
"name": "diagnosticsEnabled",
"type": "boolean",
Expand Down
23 changes: 21 additions & 2 deletions Tasks/VsTestV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 160,
"Patch": 2
"Minor": 161,
"Patch": 0
},
"demands": [
"vstest"
Expand Down Expand Up @@ -407,6 +407,25 @@
"helpMarkDown": "ms-resource:loc.input.help.publishRunAttachments",
"groupName": "reportingOptions"
},
{
"name": "failOnMinTestsNotRun",
"type": "boolean",
"label": "ms-resource:loc.input.label.failOnMinTestsNotRun",
"defaultValue": "False",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.failOnMinTestsNotRun",
"groupName": "reportingOptions"
},
{
"name": "minimumExpectedTests",
"type": "string",
"label": "ms-resource:loc.input.label.minimumExpectedTests",
"defaultValue": "1",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.minimumExpectedTests",
"groupName": "reportingOptions",
"visibleRule": "failOnMinTestsNotRun = true"
},
{
"name": "diagnosticsEnabled",
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 526128e

Please sign in to comment.