Skip to content

Commit 859861b

Browse files
authored
Merge pull request #4820 from Microsoft/users/lukillgo/publishccnofail
#1039811: PublishCodeCoverageResults: don't fail unless the checkbox …
2 parents 907095e + bdf92f2 commit 859861b

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

Tasks/PublishCodeCoverageResults/publishcodecoverageresults.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,36 @@ async function run() {
2222
var resolvedSummaryFile: string = resolvePathToSingleItem(workingDirectory, summaryFileLocation);
2323
if (failIfCoverageIsEmpty && await ccUtil.isCodeCoverageFileEmpty(resolvedSummaryFile, codeCoverageTool)) {
2424
throw tl.loc('NoCodeCoverage');
25-
}
26-
27-
// Resolve the report directory.
28-
// It may contain wildcards allowing the path to change between builds, such as for:
29-
// $(System.DefaultWorkingDirectory)\artifacts***$(Configuration)\testresults\coverage
30-
var resolvedReportDirectory: string = resolvePathToSingleItem(workingDirectory, reportDirectory);
25+
} else if (!tl.exist(resolvedSummaryFile)) {
26+
tl.warning(tl.loc('NoCodeCoverage'));
27+
} else {
28+
// Resolve the report directory.
29+
// It may contain wildcards allowing the path to change between builds, such as for:
30+
// $(System.DefaultWorkingDirectory)\artifacts***$(Configuration)\testresults\coverage
31+
var resolvedReportDirectory: string = resolvePathToSingleItem(workingDirectory, reportDirectory);
3132

32-
// Get any 'Additional Files' to publish as build artifacts
33-
if (additionalFiles) {
34-
// Does the 'Additional Files' value contain wildcards?
35-
if (containsWildcard(additionalFiles)) {
36-
// Resolve matches of the 'Additional Files' pattern
37-
var additionalFileMatches: string[] = tl.findMatch(
38-
workingDirectory,
39-
additionalFiles,
40-
{ followSymbolicLinks: false, followSpecifiedSymbolicLink: false },
41-
{ matchBase: true });
42-
tl.debug(tl.loc('FoundNMatchesForPattern', additionalFileMatches.length, additionalFiles));
33+
// Get any 'Additional Files' to publish as build artifacts
34+
if (additionalFiles) {
35+
// Does the 'Additional Files' value contain wildcards?
36+
if (containsWildcard(additionalFiles)) {
37+
// Resolve matches of the 'Additional Files' pattern
38+
var additionalFileMatches: string[] = tl.findMatch(
39+
workingDirectory,
40+
additionalFiles,
41+
{ followSymbolicLinks: false, followSpecifiedSymbolicLink: false },
42+
{ matchBase: true });
43+
tl.debug(tl.loc('FoundNMatchesForPattern', additionalFileMatches.length, additionalFiles));
44+
}
45+
else {
46+
// Use the specific additional file (no wildcards)
47+
var additionalFileMatches: string[] = [additionalFiles];
48+
}
4349
}
44-
else {
45-
// Use the specific additional file (no wildcards)
46-
var additionalFileMatches: string[] = [additionalFiles];
47-
}
48-
}
4950

50-
// Publish code coverage data
51-
var ccPublisher = new tl.CodeCoveragePublisher();
52-
ccPublisher.publish(codeCoverageTool, resolvedSummaryFile, resolvedReportDirectory, additionalFileMatches);
51+
// Publish code coverage data
52+
var ccPublisher = new tl.CodeCoveragePublisher();
53+
ccPublisher.publish(codeCoverageTool, resolvedSummaryFile, resolvedReportDirectory, additionalFileMatches);
54+
}
5355
}
5456
catch (err) {
5557
tl.setResult(tl.TaskResult.Failed, err);

Tasks/PublishCodeCoverageResults/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"author": "Microsoft Corporation",
1616
"version": {
1717
"Major": 1,
18-
"Minor": 117,
18+
"Minor": 121,
1919
"Patch": 0
2020
},
2121
"demands": [],

Tasks/PublishCodeCoverageResults/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"author": "Microsoft Corporation",
1616
"version": {
1717
"Major": 1,
18-
"Minor": 117,
18+
"Minor": 121,
1919
"Patch": 0
2020
},
2121
"demands": [],

Tests-Legacy/L0/PublishCodeCoverageResults/publishCCResponses.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"/someDir/someFile1"
99
]
1010
},
11+
"exist": {
12+
"/user/admin/summary.xml": true
13+
},
1114
"findMatch": {
1215
"/some/*pattern": [
1316
"some/path/one",

0 commit comments

Comments
 (0)