Skip to content

Commit 5100fd3

Browse files
author
Nitin Gurram
authored
Moving PTR task to v2. (#3650)
* Moving PTR task to v2. Command based implementation of publishing * Fixed info * UI suggestions
1 parent 3ebefa1 commit 5100fd3

File tree

11 files changed

+116
-775
lines changed

11 files changed

+116
-775
lines changed

Tasks/PublishTestResults/PublishTestResults.ps1

Lines changed: 0 additions & 104 deletions
This file was deleted.

Tasks/PublishTestResults/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
"loc.description": "Publish Test Results to VSTS/TFS",
55
"loc.instanceNameFormat": "Publish Test Results $(testResultsFiles)",
66
"loc.group.displayName.advanced": "Advanced",
7-
"loc.input.label.testRunner": "Test Result Format",
7+
"loc.input.label.testRunner": "Test result format",
88
"loc.input.help.testRunner": "Format of test result files generated by your choice of test runner e.g. JUnit, VSTest, XUnit V2 and NUnit.",
9-
"loc.input.label.testResultsFiles": "Test Results Files",
10-
"loc.input.help.testResultsFiles": "Test results files path. Wildcards can be used. For example, `**/TEST-*.xml` for all xml files whose name starts with TEST-.",
11-
"loc.input.label.mergeTestResults": "Merge Test Results",
9+
"loc.input.label.testResultsFiles": "Test results files",
10+
"loc.input.help.testResultsFiles": "Test results files path. Supports multiple lines of minimatch patterns. [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)",
11+
"loc.input.label.searchFolder": "Search folder",
12+
"loc.input.help.searchFolder": "Folder to search for the test result files. Defaults to $(System.DefaultWorkingDirectory).",
13+
"loc.input.label.mergeTestResults": "Merge test results",
1214
"loc.input.help.mergeTestResults": "To merge results from all test results files to one test run in VSTS/TFS, check this option. To create a test run for each test results file, uncheck this option.",
13-
"loc.input.label.testRunTitle": "Test Run Title",
15+
"loc.input.label.testRunTitle": "Test run title",
1416
"loc.input.help.testRunTitle": "Provide a name for the Test Run.",
1517
"loc.input.label.platform": "Platform",
1618
"loc.input.help.platform": "Platform for which the tests were run.",
1719
"loc.input.label.configuration": "Configuration",
1820
"loc.input.help.configuration": "Configuration for which the tests were run.",
19-
"loc.input.label.publishRunAttachments": "Upload Test Attachments",
20-
"loc.input.help.publishRunAttachments": "Opt in/out of publishing test run level attachments."
21+
"loc.input.label.publishRunAttachments": "Upload test results files",
22+
"loc.input.help.publishRunAttachments": "Opt in/out of publishing test run level attachments. If selected, test result files will be uploaded and attached to test run"
2123
}

Tasks/PublishTestResults/make.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

Tasks/PublishTestResults/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
},
1818
"homepage": "https://github.com/microsoft/vsts-tasks#readme",
1919
"dependencies": {
20-
"vsts-task-lib": "0.7.4"
20+
"vsts-task-lib": "^2.0.0-preview"
2121
}
2222
}
Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import tl = require('vsts-task-lib/task');
2-
import ffl = require('find-files-legacy/findfiles.legacy');
1+
import * as tl from 'vsts-task-lib/task';
32

4-
var testRunner = tl.getInput('testRunner', true);
5-
var testResultsFiles = tl.getInput('testResultsFiles', true);
6-
var mergeResults = tl.getInput('mergeTestResults');
7-
var platform = tl.getInput('platform');
8-
var config = tl.getInput('configuration');
9-
var testRunTitle = tl.getInput('testRunTitle');
10-
var publishRunAttachments = tl.getInput('publishRunAttachments');
3+
const testRunner = tl.getInput('testRunner', true);
4+
const testResultsFiles: string[] = tl.getDelimitedInput('testResultsFiles', '\n', true);
5+
const mergeResults = tl.getInput('mergeTestResults');
6+
const platform = tl.getInput('platform');
7+
const config = tl.getInput('configuration');
8+
const testRunTitle = tl.getInput('testRunTitle');
9+
const publishRunAttachments = tl.getInput('publishRunAttachments');
10+
let searchFolder = tl.getInput('searchFolder');
1111

1212
tl.debug('testRunner: ' + testRunner);
1313
tl.debug('testResultsFiles: ' + testResultsFiles);
@@ -17,12 +17,23 @@ tl.debug('config: ' + config);
1717
tl.debug('testRunTitle: ' + testRunTitle);
1818
tl.debug('publishRunAttachments: ' + publishRunAttachments);
1919

20-
let matchingTestResultsFiles = ffl.findFiles(testResultsFiles, false, tl.getVariable('System.DefaultWorkingDirectory'));
21-
if(!matchingTestResultsFiles || matchingTestResultsFiles.length == 0) {
22-
tl.warning('No test result files matching ' + testResultsFiles + ' were found.');
23-
tl.exit(0);
20+
if (isNullOrWhitespace(searchFolder)) {
21+
searchFolder = tl.getVariable('System.DefaultWorkingDirectory');
2422
}
25-
else{
26-
let tp = new tl.TestPublisher(testRunner);
27-
tp.publish(matchingTestResultsFiles, mergeResults, platform, config, testRunTitle, publishRunAttachments);
23+
24+
let matchingTestResultsFiles: string[] = tl.findMatch(searchFolder, testResultsFiles);
25+
if (!matchingTestResultsFiles || matchingTestResultsFiles.length === 0) {
26+
tl.warning('No test result files matching ' + testResultsFiles + ' were found.');
27+
} else {
28+
let tp: tl.TestPublisher = new tl.TestPublisher(testRunner);
29+
tp.publish(matchingTestResultsFiles, mergeResults, platform, config, testRunTitle, publishRunAttachments);
30+
}
31+
32+
tl.setResult(tl.TaskResult.Succeeded, '');
33+
34+
function isNullOrWhitespace(input: any) {
35+
if (typeof input === 'undefined' || input === null) {
36+
return true;
37+
}
38+
return input.replace(/\s/g, '').length < 1;
2839
}

Tasks/PublishTestResults/task.json

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
],
1212
"author": "Microsoft Corporation",
1313
"version": {
14-
"Major": 1,
14+
"Major": 2,
1515
"Minor": 0,
16-
"Patch": 36
16+
"Patch": 0
1717
},
1818
"demands": [],
19-
"minimumAgentVersion": "1.83.0",
19+
"preview": "true",
20+
"releaseNotes": "<ul><li>NUnit3 support</li><li>Support for Minimatch files pattern</li></ul>",
21+
"minimumAgentVersion": "2.0.0",
2022
"groups": [
2123
{
2224
"name": "advanced",
@@ -28,7 +30,7 @@
2830
{
2931
"name": "testRunner",
3032
"type": "pickList",
31-
"label": "Test Result Format",
33+
"label": "Test result format",
3234
"defaultValue": "JUnit",
3335
"required": true,
3436
"helpMarkDown": "Format of test result files generated by your choice of test runner e.g. JUnit, VSTest, XUnit V2 and NUnit.",
@@ -41,24 +43,36 @@
4143
},
4244
{
4345
"name": "testResultsFiles",
44-
"type": "filePath",
45-
"label": "Test Results Files",
46-
"defaultValue": "**/TEST-*.xml",
46+
"type": "multiLine",
47+
"label": "Test results files",
48+
"defaultValue": "**\\TEST-*.xml",
4749
"required": true,
48-
"helpMarkDown": "Test results files path. Wildcards can be used. For example, `**/TEST-*.xml` for all xml files whose name starts with TEST-."
50+
"helpMarkDown": "Test results files path. Supports multiple lines of minimatch patterns. [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)",
51+
"properties": {
52+
"rows": "3",
53+
"resizable": "true"
54+
}
55+
},
56+
{
57+
"name": "searchFolder",
58+
"type": "string",
59+
"label": "Search folder",
60+
"defaultValue": "$(System.DefaultWorkingDirectory)",
61+
"required": false,
62+
"helpMarkDown": "Folder to search for the test result files. Defaults to $(System.DefaultWorkingDirectory)."
4963
},
5064
{
5165
"name": "mergeTestResults",
5266
"type": "boolean",
53-
"label": "Merge Test Results",
67+
"label": "Merge test results",
5468
"defaultValue": "false",
5569
"required": false,
5670
"helpMarkDown": "To merge results from all test results files to one test run in VSTS/TFS, check this option. To create a test run for each test results file, uncheck this option."
5771
},
5872
{
5973
"name": "testRunTitle",
6074
"type": "string",
61-
"label": "Test Run Title",
75+
"label": "Test run title",
6276
"defaultValue": "",
6377
"required": false,
6478
"helpMarkDown": "Provide a name for the Test Run."
@@ -84,23 +98,15 @@
8498
{
8599
"name": "publishRunAttachments",
86100
"type": "boolean",
87-
"label": "Upload Test Attachments",
101+
"label": "Upload test results files",
88102
"defaultValue": "true",
89103
"required": false,
90-
"helpMarkDown": "Opt in/out of publishing test run level attachments.",
104+
"helpMarkDown": "Opt in/out of publishing test run level attachments. If selected, test result files will be uploaded and attached to test run",
91105
"groupName": "advanced"
92106
}
93107
],
94108
"instanceNameFormat": "Publish Test Results $(testResultsFiles)",
95109
"execution": {
96-
"PowerShell": {
97-
"target": "$(currentDirectory)\\PublishTestResults.ps1",
98-
"argumentFormat": "",
99-
"workingDirectory": "$(currentDirectory)",
100-
"platforms": [
101-
"windows"
102-
]
103-
},
104110
"Node": {
105111
"target": "publishtestresults.js",
106112
"argumentFormat": ""

Tasks/PublishTestResults/task.loc.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
],
1212
"author": "Microsoft Corporation",
1313
"version": {
14-
"Major": 1,
14+
"Major": 2,
1515
"Minor": 0,
16-
"Patch": 36
16+
"Patch": 0
1717
},
1818
"demands": [],
19-
"minimumAgentVersion": "1.83.0",
19+
"preview": "true",
20+
"releaseNotes": "<ul><li>NUnit3 support</li><li>Support for Minimatch files pattern</li></ul>",
21+
"minimumAgentVersion": "2.0.0",
2022
"groups": [
2123
{
2224
"name": "advanced",
@@ -41,11 +43,23 @@
4143
},
4244
{
4345
"name": "testResultsFiles",
44-
"type": "filePath",
46+
"type": "multiLine",
4547
"label": "ms-resource:loc.input.label.testResultsFiles",
46-
"defaultValue": "**/TEST-*.xml",
48+
"defaultValue": "**\\TEST-*.xml",
4749
"required": true,
48-
"helpMarkDown": "ms-resource:loc.input.help.testResultsFiles"
50+
"helpMarkDown": "ms-resource:loc.input.help.testResultsFiles",
51+
"properties": {
52+
"rows": "3",
53+
"resizable": "true"
54+
}
55+
},
56+
{
57+
"name": "searchFolder",
58+
"type": "string",
59+
"label": "ms-resource:loc.input.label.searchFolder",
60+
"defaultValue": "$(System.DefaultWorkingDirectory)",
61+
"required": false,
62+
"helpMarkDown": "ms-resource:loc.input.help.searchFolder"
4963
},
5064
{
5165
"name": "mergeTestResults",
@@ -93,14 +107,6 @@
93107
],
94108
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
95109
"execution": {
96-
"PowerShell": {
97-
"target": "$(currentDirectory)\\PublishTestResults.ps1",
98-
"argumentFormat": "",
99-
"workingDirectory": "$(currentDirectory)",
100-
"platforms": [
101-
"windows"
102-
]
103-
},
104110
"Node": {
105111
"target": "publishtestresults.js",
106112
"argumentFormat": ""
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
/// <reference path="globals/node/index.d.ts" />
2-
/// <reference path="globals/q/index.d.ts" />
3-
// TODO: remove after moving to latest task lib
4-
/// <reference path="vsts-task-lib.d.ts" />
2+
/// <reference path="globals/q/index.d.ts" />

0 commit comments

Comments
 (0)