From df48416f43ee184345beeebaf8f63efc4a6537b6 Mon Sep 17 00:00:00 2001 From: siddhap Date: Fri, 16 Feb 2018 16:03:09 +0530 Subject: [PATCH] Ensuring upload of logs doesnt fail the task --- Tasks/VsTest/task.json | 2 +- Tasks/VsTest/task.loc.json | 2 +- Tasks/VsTest/vstest.ts | 28 +++++++++++++++++----------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Tasks/VsTest/task.json b/Tasks/VsTest/task.json index 754282078ab5..515343ed3113 100644 --- a/Tasks/VsTest/task.json +++ b/Tasks/VsTest/task.json @@ -17,7 +17,7 @@ "version": { "Major": 2, "Minor": 3, - "Patch": 23 + "Patch": 24 }, "demands": [ "vstest" diff --git a/Tasks/VsTest/task.loc.json b/Tasks/VsTest/task.loc.json index 883641ca1ee1..657a5b690eb5 100644 --- a/Tasks/VsTest/task.loc.json +++ b/Tasks/VsTest/task.loc.json @@ -17,7 +17,7 @@ "version": { "Major": 2, "Minor": 3, - "Patch": 23 + "Patch": 24 }, "demands": [ "vstest" diff --git a/Tasks/VsTest/vstest.ts b/Tasks/VsTest/vstest.ts index 50e0b3e199b8..eb57aad9da50 100644 --- a/Tasks/VsTest/vstest.ts +++ b/Tasks/VsTest/vstest.ts @@ -402,19 +402,25 @@ function uploadVstestDiagFile(): void { } function uploadFile(file: string): void { - if (utils.Helper.pathExistsAsFile(file)) { - const stats = fs.statSync(file); - tl.debug('File exists. Size: ' + stats.size + ' Bytes'); - console.log('##vso[task.uploadfile]' + file); - - const files = tl.findMatch(os.tmpdir(), ['*host.*.txt', '*datacollector.*.txt']); - if (files) { - files.forEach(file => { - tl.debug('Uploading file: ' + file); - console.log('##vso[task.uploadfile]' + file); - }); + try { + if (utils.Helper.pathExistsAsFile(file)) { + const stats = fs.statSync(file); + tl.debug('File exists. Size: ' + stats.size + ' Bytes'); + console.log('##vso[task.uploadfile]' + file); + + const files = tl.findMatch(os.tmpdir(), ['*host.*.txt', '*datacollector.*.txt']); + if (files) { + files.forEach(file => { + tl.debug('Uploading file: ' + file); + console.log('##vso[task.uploadfile]' + file); + }); + } } } + catch (err) { + utils.Helper.publishEventToCi(AreaCodes.GETVSTESTTESTSLIST, err.message, 1029, false); + tl.debug(err); + } } function discoverTestFromFilteredFilter(vsVersion: number, testCaseFilterFile: string, testCaseFilterOutput: string): string {