Skip to content
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

Moving PTR task to v2. #3650

Merged
merged 3 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions Tasks/PublishTestResults/PublishTestResults.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
"loc.description": "Publish Test Results to VSTS/TFS",
"loc.instanceNameFormat": "Publish Test Results $(testResultsFiles)",
"loc.group.displayName.advanced": "Advanced",
"loc.input.label.testRunner": "Test Result Format",
"loc.input.label.testRunner": "Test result format",
"loc.input.help.testRunner": "Format of test result files generated by your choice of test runner e.g. JUnit, VSTest, XUnit V2 and NUnit.",
"loc.input.label.testResultsFiles": "Test Results Files",
"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-.",
"loc.input.label.mergeTestResults": "Merge Test Results",
"loc.input.label.testResultsFiles": "Test results files",
"loc.input.help.testResultsFiles": "Test results files path. Supports multiple lines of minimatch patterns. [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)",
"loc.input.label.searchFolder": "Search folder",
"loc.input.help.searchFolder": "Folder to search for the test result files. Defaults to $(System.DefaultWorkingDirectory).",
"loc.input.label.mergeTestResults": "Merge test results",
"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.",
"loc.input.label.testRunTitle": "Test Run Title",
"loc.input.label.testRunTitle": "Test run title",
"loc.input.help.testRunTitle": "Provide a name for the Test Run.",
"loc.input.label.platform": "Platform",
"loc.input.help.platform": "Platform for which the tests were run.",
"loc.input.label.configuration": "Configuration",
"loc.input.help.configuration": "Configuration for which the tests were run.",
"loc.input.label.publishRunAttachments": "Upload Test Attachments",
"loc.input.help.publishRunAttachments": "Opt in/out of publishing test run level attachments."
"loc.input.label.publishRunAttachments": "Upload test results files",
"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"
}
17 changes: 0 additions & 17 deletions Tasks/PublishTestResults/make.json

This file was deleted.

2 changes: 1 addition & 1 deletion Tasks/PublishTestResults/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"homepage": "https://github.com/microsoft/vsts-tasks#readme",
"dependencies": {
"vsts-task-lib": "0.7.4"
"vsts-task-lib": "^2.0.0-preview"
}
}
43 changes: 27 additions & 16 deletions Tasks/PublishTestResults/publishtestresults.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import tl = require('vsts-task-lib/task');
import ffl = require('find-files-legacy/findfiles.legacy');
import * as tl from 'vsts-task-lib/task';

var testRunner = tl.getInput('testRunner', true);
var testResultsFiles = tl.getInput('testResultsFiles', true);
var mergeResults = tl.getInput('mergeTestResults');
var platform = tl.getInput('platform');
var config = tl.getInput('configuration');
var testRunTitle = tl.getInput('testRunTitle');
var publishRunAttachments = tl.getInput('publishRunAttachments');
const testRunner = tl.getInput('testRunner', true);
const testResultsFiles: string[] = tl.getDelimitedInput('testResultsFiles', '\n', true);
const mergeResults = tl.getInput('mergeTestResults');
const platform = tl.getInput('platform');
const config = tl.getInput('configuration');
const testRunTitle = tl.getInput('testRunTitle');
const publishRunAttachments = tl.getInput('publishRunAttachments');
let searchFolder = tl.getInput('searchFolder');

tl.debug('testRunner: ' + testRunner);
tl.debug('testResultsFiles: ' + testResultsFiles);
Expand All @@ -17,12 +17,23 @@ tl.debug('config: ' + config);
tl.debug('testRunTitle: ' + testRunTitle);
tl.debug('publishRunAttachments: ' + publishRunAttachments);

let matchingTestResultsFiles = ffl.findFiles(testResultsFiles, false, tl.getVariable('System.DefaultWorkingDirectory'));
if(!matchingTestResultsFiles || matchingTestResultsFiles.length == 0) {
tl.warning('No test result files matching ' + testResultsFiles + ' were found.');
tl.exit(0);
if (isNullOrWhitespace(searchFolder)) {
searchFolder = tl.getVariable('System.DefaultWorkingDirectory');
}
else{
let tp = new tl.TestPublisher(testRunner);
tp.publish(matchingTestResultsFiles, mergeResults, platform, config, testRunTitle, publishRunAttachments);

let matchingTestResultsFiles: string[] = tl.findMatch(searchFolder, testResultsFiles);
if (!matchingTestResultsFiles || matchingTestResultsFiles.length === 0) {
tl.warning('No test result files matching ' + testResultsFiles + ' were found.');
} else {
let tp: tl.TestPublisher = new tl.TestPublisher(testRunner);
tp.publish(matchingTestResultsFiles, mergeResults, platform, config, testRunTitle, publishRunAttachments);
}

tl.setResult(tl.TaskResult.Succeeded, '');

function isNullOrWhitespace(input: any) {
if (typeof input === 'undefined' || input === null) {
return true;
}
return input.replace(/\s/g, '').length < 1;
}
46 changes: 26 additions & 20 deletions Tasks/PublishTestResults/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
],
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Major": 2,
"Minor": 0,
"Patch": 36
"Patch": 0
},
"demands": [],
"minimumAgentVersion": "1.83.0",
"preview": "true",
"releaseNotes": "<ul><li>NUnit3 support</li><li>Support for Minimatch files pattern</li></ul>",
"minimumAgentVersion": "2.0.0",
"groups": [
{
"name": "advanced",
Expand All @@ -28,7 +30,7 @@
{
"name": "testRunner",
"type": "pickList",
"label": "Test Result Format",
"label": "Test result format",
"defaultValue": "JUnit",
"required": true,
"helpMarkDown": "Format of test result files generated by your choice of test runner e.g. JUnit, VSTest, XUnit V2 and NUnit.",
Expand All @@ -41,24 +43,36 @@
},
{
"name": "testResultsFiles",
"type": "filePath",
"label": "Test Results Files",
"defaultValue": "**/TEST-*.xml",
"type": "multiLine",
"label": "Test results files",
"defaultValue": "**\\TEST-*.xml",
"required": true,
"helpMarkDown": "Test results files path. Wildcards can be used. For example, `**/TEST-*.xml` for all xml files whose name starts with TEST-."
"helpMarkDown": "Test results files path. Supports multiple lines of minimatch patterns. [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)",
"properties": {
"rows": "3",
"resizable": "true"
}
},
{
"name": "searchFolder",
"type": "string",
"label": "Search folder",
"defaultValue": "$(System.DefaultWorkingDirectory)",
"required": false,
"helpMarkDown": "Folder to search for the test result files. Defaults to $(System.DefaultWorkingDirectory)."
},
{
"name": "mergeTestResults",
"type": "boolean",
"label": "Merge Test Results",
"label": "Merge test results",
"defaultValue": "false",
"required": false,
"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."
},
{
"name": "testRunTitle",
"type": "string",
"label": "Test Run Title",
"label": "Test run title",
"defaultValue": "",
"required": false,
"helpMarkDown": "Provide a name for the Test Run."
Expand All @@ -84,23 +98,15 @@
{
"name": "publishRunAttachments",
"type": "boolean",
"label": "Upload Test Attachments",
"label": "Upload test results files",
"defaultValue": "true",
"required": false,
"helpMarkDown": "Opt in/out of publishing test run level attachments.",
"helpMarkDown": "Opt in/out of publishing test run level attachments. If selected, test result files will be uploaded and attached to test run",
"groupName": "advanced"
}
],
"instanceNameFormat": "Publish Test Results $(testResultsFiles)",
"execution": {
"PowerShell": {
"target": "$(currentDirectory)\\PublishTestResults.ps1",
"argumentFormat": "",
"workingDirectory": "$(currentDirectory)",
"platforms": [
"windows"
]
},
"Node": {
"target": "publishtestresults.js",
"argumentFormat": ""
Expand Down
34 changes: 20 additions & 14 deletions Tasks/PublishTestResults/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
],
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Major": 2,
"Minor": 0,
"Patch": 36
"Patch": 0
},
"demands": [],
"minimumAgentVersion": "1.83.0",
"preview": "true",
"releaseNotes": "<ul><li>NUnit3 support</li><li>Support for Minimatch files pattern</li></ul>",
"minimumAgentVersion": "2.0.0",
"groups": [
{
"name": "advanced",
Expand All @@ -41,11 +43,23 @@
},
{
"name": "testResultsFiles",
"type": "filePath",
"type": "multiLine",
"label": "ms-resource:loc.input.label.testResultsFiles",
"defaultValue": "**/TEST-*.xml",
"defaultValue": "**\\TEST-*.xml",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.testResultsFiles"
"helpMarkDown": "ms-resource:loc.input.help.testResultsFiles",
"properties": {
"rows": "3",
"resizable": "true"
}
},
{
"name": "searchFolder",
"type": "string",
"label": "ms-resource:loc.input.label.searchFolder",
"defaultValue": "$(System.DefaultWorkingDirectory)",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.searchFolder"
},
{
"name": "mergeTestResults",
Expand Down Expand Up @@ -93,14 +107,6 @@
],
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
"execution": {
"PowerShell": {
"target": "$(currentDirectory)\\PublishTestResults.ps1",
"argumentFormat": "",
"workingDirectory": "$(currentDirectory)",
"platforms": [
"windows"
]
},
"Node": {
"target": "publishtestresults.js",
"argumentFormat": ""
Expand Down
4 changes: 1 addition & 3 deletions Tasks/PublishTestResults/typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/// <reference path="globals/node/index.d.ts" />
/// <reference path="globals/q/index.d.ts" />
// TODO: remove after moving to latest task lib
/// <reference path="vsts-task-lib.d.ts" />
/// <reference path="globals/q/index.d.ts" />
Loading