Skip to content

Commit

Permalink
Moving PTR task to v2. Command based implementation of publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitin Gurram committed Feb 20, 2017
1 parent 433d778 commit e477a4e
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 763 deletions.
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 @@ -7,7 +7,9 @@
"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.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 assemblies. 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",
Expand Down
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;
}
34 changes: 20 additions & 14 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 @@ -41,11 +43,23 @@
},
{
"name": "testResultsFiles",
"type": "filePath",
"type": "multiLine",
"label": "Test Results Files",
"defaultValue": "**/TEST-*.xml",
"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 assemblies. Defaults to $(System.DefaultWorkingDirectory)."
},
{
"name": "mergeTestResults",
Expand Down Expand Up @@ -93,14 +107,6 @@
],
"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

0 comments on commit e477a4e

Please sign in to comment.