Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit b5c5467

Browse files
committed
Merge pull request #274 from Microsoft/users/achalla/PublishCCFix
Publish code coverage task fix
2 parents db044ea + 5b1ab1e commit b5c5467

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

src/agent/codecoveragepublisher.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class CodeCoveragePublisher {
3333
//-----------------------------------------------------
3434
// Publish code coverage
3535
//-----------------------------------------------------
36-
public publishCodeCoverageSummary(): Q.Promise<boolean> {
37-
var defer = Q.defer<boolean>();
36+
public publishCodeCoverageSummary(): Q.Promise<any> {
37+
var defer = Q.defer<any>();
3838
var _this = this;
3939
var summaryFile = _this.command.properties["summaryfile"];
4040

@@ -43,15 +43,15 @@ export class CodeCoveragePublisher {
4343
_this.executionContext.service.publishCodeCoverageSummary(codeCoverageData, _this.project, _this.buildId)
4444
.then(function(result) {
4545
_this.command.info("PublishCodeCoverageSummary : Code coverage summary published successfully.");
46-
defer.resolve(true);
46+
defer.resolve(null);
4747
}).fail(function(error) {
4848
_this.command.warning("PublishCodeCoverageSummary : Error occured while publishing code coverage summary. Error: " + error);
4949
defer.reject(error);
5050
});
5151
}
5252
else {
5353
_this.command.warning("PublishCodeCoverageSummary : No code coverage data found to publish.");
54-
defer.resolve(false);
54+
defer.resolve(null);
5555
}
5656
}).fail(function(err) {
5757
_this.command.warning("PublishCodeCoverageSummary : Error occured while reading code coverage summary. Error : " + err);

src/agent/commands/codecoverage.publish.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,12 @@ export class CodeCoveragePublishCommand implements cm.IAsyncCommand {
6666
}
6767

6868
var codeCoveragePublisher = new ccp.CodeCoveragePublisher(this.executionContext, this.command, reader);
69-
codeCoveragePublisher.publishCodeCoverageSummary().then(function(codeCoveragePublished) {
70-
if (codeCoveragePublished) {
71-
codeCoveragePublisher.publishCodeCoverageFiles().then(function() {
72-
defer.resolve(true);
73-
}).fail(function(error) {
74-
defer.reject(error);
75-
});
76-
}
77-
else {
78-
defer.resolve(false);
79-
}
69+
codeCoveragePublisher.publishCodeCoverageSummary().then(function() {
70+
codeCoveragePublisher.publishCodeCoverageFiles().then(function() {
71+
defer.resolve(true);
72+
}).fail(function(error) {
73+
defer.reject(error);
74+
});
8075
}).fail(function(err) {
8176
defer.reject(err);
8277
});

src/test/publishcodecoveragetests.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ describe('CodeCoveragePublisherTests', function() {
144144
var codeCoveragePublisher = new ccp.CodeCoveragePublisher(testExecutionContext, command, jacocoSummaryReader);
145145
codeCoveragePublisher.publishCodeCoverageSummary().then(function(result) {
146146
assert(testExecutionContext.service.jobsCompletedSuccessfully(), 'CodeCoveragePublish Task Failed! Details : ' + testExecutionContext.service.getRecordsString());
147-
assert(result);
148147
done();
149148
},
150149
function(err) {
@@ -187,7 +186,6 @@ describe('CodeCoveragePublisherTests', function() {
187186

188187
codeCoveragePublisher.publishCodeCoverageSummary().then(function(result) {
189188
assert(testExecutionContext.service.jobsCompletedSuccessfully(), 'CodeCoveragePublish Task Failed! Details : ' + testExecutionContext.service.getRecordsString());
190-
assert(result);
191189
done();
192190
},
193191
function(err) {
@@ -240,17 +238,18 @@ describe('CodeCoveragePublisherTests', function() {
240238
it('codecoverage.publish : publish jacoco summary when there is no code coverage data', function(done) {
241239
this.timeout(2000);
242240

243-
var properties: { [name: string]: string } = { "summaryfile": emptyJacocoSummaryFile, "codecoveragetool": "JaCoCo" };
241+
var properties: { [name: string]: string } = { "summaryfile": emptyJacocoSummaryFile, "codecoveragetool": "JaCoCo", "reportdirectory": "", "additionalcodecoveragefiles": "" };
244242
var command: cm.ITaskCommand = new tc.TestCommand(null, null, null);
245243
command.properties = properties;
246-
var jacocoSummaryReader = new csr.JacocoSummaryReader(command);
247-
testExecutionContext = new tec.TestExecutionContext(new jobInf.TestJobInfo({}));
244+
var jobInfo = new jobInf.TestJobInfo({});
245+
jobInfo.variables = { "agent.workingDirectory": __dirname, "build.buildId": "1" };
246+
testExecutionContext = new tec.TestExecutionContext(jobInfo);
248247

249248
var codeCoveragePublishCommand = new cpc.CodeCoveragePublishCommand(testExecutionContext, command);
250249
codeCoveragePublishCommand.runCommandAsync().then(function(result) {
251250
assert(testExecutionContext.service.jobsCompletedSuccessfully(), 'CodeCoveragePublish Task Failed! Details : ' + testExecutionContext.service.getRecordsString());
252-
assert(!result);
253-
assert(testExecutionContext.service.containerItems.length == 0);
251+
assert(result);
252+
assert(testExecutionContext.service.containerItems.length == 1);
254253
done();
255254
},
256255
function(err) {
@@ -261,17 +260,18 @@ describe('CodeCoveragePublisherTests', function() {
261260
it('codecoverage.publish : publish cobertura summary when there is no code coverage data', function(done) {
262261
this.timeout(2000);
263262

264-
var properties: { [name: string]: string } = { "summaryfile": emptyCoberturaSummaryFile, "codecoveragetool": "cobertura" };
263+
var properties: { [name: string]: string } = { "summaryfile": emptyCoberturaSummaryFile, "codecoveragetool": "cobertura", "reportdirectory": "", "additionalcodecoveragefiles": "" };
265264
var command: cm.ITaskCommand = new tc.TestCommand(null, null, null);
266265
command.properties = properties;
267-
var coberturaSummaryReader = new csr.CoberturaSummaryReader(command);
268-
testExecutionContext = new tec.TestExecutionContext(new jobInf.TestJobInfo({}));
266+
var jobInfo = new jobInf.TestJobInfo({});
267+
jobInfo.variables = { "agent.workingDirectory": __dirname, "build.buildId": "1" };
268+
testExecutionContext = new tec.TestExecutionContext(jobInfo);
269269

270270
var codeCoveragePublishCommand = new cpc.CodeCoveragePublishCommand(testExecutionContext, command);
271271
codeCoveragePublishCommand.runCommandAsync().then(function(result) {
272272
assert(testExecutionContext.service.jobsCompletedSuccessfully(), 'CodeCoveragePublish Task Failed! Details : ' + testExecutionContext.service.getRecordsString());
273-
assert(!result);
274-
assert(testExecutionContext.service.containerItems.length == 0);
273+
assert(result);
274+
assert(testExecutionContext.service.containerItems.length == 1);
275275
done();
276276
},
277277
function(err) {

0 commit comments

Comments
 (0)