diff --git a/Tests/L0/ANT/_suite.ts b/Tests/L0/ANT/_suite.ts index b327db6faaeb..b30c43ef6956 100644 --- a/Tests/L0/ANT/_suite.ts +++ b/Tests/L0/ANT/_suite.ts @@ -307,76 +307,75 @@ describe('ANT Suite', function() { done(err); }); }) + + it('Ant calls enable code coverage and publish code coverage when Cobertura is selected.', (done) => { + setResponseFile('antCodeCoverage.json'); + + var tr = new trm.TaskRunner('ANT'); + tr.setInput('antBuildFile', '/build/build.xml'); // Make that checkPath returns true for this filename in the response file + tr.setInput('javaHomeSelection', 'JDKVersion'); + tr.setInput('jdkVersion', 'default'); + tr.setInput('testResultsFiles', '**/TEST-*.xml'); + tr.setInput('codeCoverageTool', 'Cobertura'); + tr.setInput('classFilesDirectories', 'class1'); + + tr.run() + .then(() => { + assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\\build\\CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=Cobertura;\]/) >= 0 || tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\/build\/CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\/build\/CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=Cobertura;\]/) >= 0, 'should have called enable code coverage.'); + assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=Cobertura;summaryfile=\\build\\CCReport43F6D5EF\\coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;\]/) >= 0 || + tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=Cobertura;summaryfile=\/build\/CCReport43F6D5EF\/coverage.xml;reportdirectory=\/build\/CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); + done(); + }) + .fail((err) => { + assert.fail("task should not have failed"); + done(err); + }); + }) + + it('Ant calls enable code coverage and publish code coverage when Jacoco is selected.', (done) => { + setResponseFile('antCodeCoverage.json'); + + var tr = new trm.TaskRunner('ANT'); + tr.setInput('antBuildFile', '/build/build.xml'); // Make that checkPath returns true for this filename in the response file + tr.setInput('javaHomeSelection', 'JDKVersion'); + tr.setInput('jdkVersion', 'default'); + tr.setInput('testResultsFiles', '**/TEST-*.xml'); + tr.setInput('codeCoverageTool', 'JaCoCo'); + tr.setInput('classFilesDirectories', 'class1'); - // - // Commenting out because these are failing and hanging for awhile on OSX - // - // it('Ant calls enable code coverage and publish code coverage when Cobertura is selected.', (done) => { - // setResponseFile('antCodeCoverage.json'); - - // var tr = new trm.TaskRunner('ANT'); - // tr.setInput('antBuildFile', '/build/build.xml'); // Make that checkPath returns true for this filename in the response file - // tr.setInput('javaHomeSelection', 'JDKVersion'); - // tr.setInput('jdkVersion', 'default'); - // tr.setInput('testResultsFiles', '**/TEST-*.xml'); - // tr.setInput('codeCoverageTool', 'Cobertura'); - // tr.setInput('classFilesDirectories', 'class1'); - - // tr.run() - // .then(() => { - // assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\\build\\CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=Cobertura;\]/) >= 0, 'should have called enable code coverage.'); - // assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=Cobertura;summaryfile=\\build\\CCReport43F6D5EF\\coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); - // done(); - // }) - // .fail((err) => { - // assert.fail("task should not have failed"); - // done(err); - // }); - // }) - - // it('Ant calls enable code coverage and publish code coverage when Jacoco is selected.', (done) => { - // setResponseFile('antCodeCoverage.json'); - - // var tr = new trm.TaskRunner('ANT'); - // tr.setInput('antBuildFile', '/build/build.xml'); // Make that checkPath returns true for this filename in the response file - // tr.setInput('javaHomeSelection', 'JDKVersion'); - // tr.setInput('jdkVersion', 'default'); - // tr.setInput('testResultsFiles', '**/TEST-*.xml'); - // tr.setInput('codeCoverageTool', 'JaCoCo'); - // tr.setInput('classFilesDirectories', 'class1'); - - // tr.run() - // .then(() => { - // assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\\build\\CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=JaCoCo;\]/) >= 0, 'should have called enable code coverage.'); - // assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=\\build\\CCReport43F6D5EF\\coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); - // done(); - // }) - // .fail((err) => { - // assert.fail("task should not have failed"); - // done(err); - // }); - // }) - - // it('Ant calls enable code coverage but not publish code coverage when summary file is not generated.', (done) => { - // setResponseFile('antGood.json'); - // // antGood.json doesnt mock the stat for summary file. - // var tr = new trm.TaskRunner('ANT'); - // tr.setInput('antBuildFile', '/build/build.xml'); // Make that checkPath returns true for this filename in the response file - // tr.setInput('javaHomeSelection', 'JDKVersion'); - // tr.setInput('jdkVersion', 'default'); - // tr.setInput('testResultsFiles', '**/TEST-*.xml'); - // tr.setInput('codeCoverageTool', 'JaCoCo'); - // tr.setInput('classFilesDirectories', 'class1'); - - // tr.run() - // .then(() => { - // assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\\build\\CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=JaCoCo;\]/) >= 0, 'should have called enable code coverage.'); - // assert(tr.stdout.search(/##vso\[codecoverage.publish/) < 0, 'should have called publish code coverage.'); - // done(); - // }) - // .fail((err) => { - // assert.fail("task should not have failed"); - // done(err); - // }); - // }) + tr.run() + .then(() => { + assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\\build\\CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=JaCoCo;\]/) >= 0 || tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\/build\/CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\/build\/CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=JaCoCo;\]/) >= 0, 'should have called enable code coverage.'); + assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=\\build\\CCReport43F6D5EF\\coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;\]/) >= 0 || + tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=\/build\/CCReport43F6D5EF\/coverage.xml;reportdirectory=\/build\/CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); + done(); + }) + .fail((err) => { + assert.fail("task should not have failed"); + done(err); + }); + }) + + it('Ant calls enable code coverage but not publish code coverage when summary file is not generated.', (done) => { + setResponseFile('antGood.json'); + // antGood.json doesnt mock the stat for summary file. + var tr = new trm.TaskRunner('ANT'); + tr.setInput('antBuildFile', '/build/build.xml'); // Make that checkPath returns true for this filename in the response file + tr.setInput('javaHomeSelection', 'JDKVersion'); + tr.setInput('jdkVersion', 'default'); + tr.setInput('testResultsFiles', '**/TEST-*.xml'); + tr.setInput('codeCoverageTool', 'JaCoCo'); + tr.setInput('classFilesDirectories', 'class1'); + + tr.run() + .then(() => { + assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\\build\\CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\\build\\CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=JaCoCo;\]/) >= 0 || tr.stdout.search(/##vso\[codecoverage.enable buildfile=\/build\/build.xml;classfilesdirectories=class1;summaryfile=coverage.xml;reportdirectory=\/build\/CCReport43F6D5EF;ccreporttask=CodeCoverage_9064e1d0;reportbuildfile=\/build\/CCReportBuildA4D283EG.xml;buildtool=Ant;codecoveragetool=JaCoCo;\]/) >= 0, 'should have called enable code coverage.'); + assert(tr.stdout.search(/##vso\[codecoverage.publish/) < 0, 'should have called publish code coverage.'); + done(); + }) + .fail((err) => { + assert.fail("task should not have failed"); + done(err); + }); + }) }); \ No newline at end of file diff --git a/Tests/L0/ANT/antCodeCoverage.json b/Tests/L0/ANT/antCodeCoverage.json index 99272f4df743..ade33b114376 100644 --- a/Tests/L0/ANT/antCodeCoverage.json +++ b/Tests/L0/ANT/antCodeCoverage.json @@ -28,6 +28,9 @@ "stats": { "\\build\\CCReport43F6D5EF\\coverage.xml": { "isFile": true + }, + "/build/CCReport43F6D5EF/coverage.xml": { + "isFile": true } }, "rmRF": { @@ -46,6 +49,22 @@ "\\build\\CCReportBuildA4D283EG.xml": { "success": true, "message": "success" + }, + "/build/InstrumentedClasses": { + "success": true, + "message": "success" + }, + "/build/cobertura.ser": { + "success": true, + "message": "success" + }, + "/build/CCReport43F6D5EF": { + "success": true, + "message": "success" + }, + "/build/CCReportBuildA4D283EG.xml": { + "success": true, + "message": "success" } } } \ No newline at end of file diff --git a/Tests/L0/ANT/antFails.json b/Tests/L0/ANT/antFails.json index 8d0deff98d6c..434e5e854676 100644 --- a/Tests/L0/ANT/antFails.json +++ b/Tests/L0/ANT/antFails.json @@ -24,6 +24,10 @@ "\\build\\InstrumentedClasses": { "success": true, "message": "success" + }, + "/build/InstrumentedClasses": { + "success": true, + "message": "success" } } } \ No newline at end of file diff --git a/Tests/L0/ANT/antGood.json b/Tests/L0/ANT/antGood.json index bb9985fd2787..ba28799eafdb 100644 --- a/Tests/L0/ANT/antGood.json +++ b/Tests/L0/ANT/antGood.json @@ -42,6 +42,22 @@ "\\build\\CCReportBuildA4D283EG.xml": { "success": true, "message": "success" + }, + "/build/InstrumentedClasses": { + "success": true, + "message": "success" + }, + "/build/cobertura.ser": { + "success": true, + "message": "success" + }, + "/build/CCReport43F6D5EF": { + "success": true, + "message": "success" + }, + "/build/CCReportBuildA4D283EG.xml": { + "success": true, + "message": "success" } } } \ No newline at end of file diff --git a/Tests/L0/ANT/antVersionFails.json b/Tests/L0/ANT/antVersionFails.json index 59b4fc660ec2..f0394ab56fb9 100644 --- a/Tests/L0/ANT/antVersionFails.json +++ b/Tests/L0/ANT/antVersionFails.json @@ -21,6 +21,10 @@ "\\build\\InstrumentedClasses": { "success": true, "message": "success" + }, + "/build/InstrumentedClasses": { + "success": true, + "message": "success" } } } \ No newline at end of file diff --git a/Tests/L0/Gradle/_suite.ts b/Tests/L0/Gradle/_suite.ts index 956fd72aae1e..547cd9d9e076 100644 --- a/Tests/L0/Gradle/_suite.ts +++ b/Tests/L0/Gradle/_suite.ts @@ -437,7 +437,8 @@ describe('gradle Suite', function() { assert(tr.ran('gradlew build jacocoTestReport'), 'it should have run gradlew build'); assert(tr.invokedToolCount == 2, 'should have only run gradle 2 times'); assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=build.gradle;summaryfile=summary.xml;reportdirectory=CCReport43F6D5EF;ismultimodule=false;buildtool=Gradle;codecoveragetool=JaCoCo;\]/) >= 0, 'should have called enable code coverage.'); - assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=CCReport43F6D5EF\\summary.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); + assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=CCReport43F6D5EF\\summary.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0 || + tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=CCReport43F6D5EF\/summary.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length == 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -447,7 +448,7 @@ describe('gradle Suite', function() { done(err); }); }) - + it('Gradle with jacoco selected should call enable and publish code coverage for a multi module project.', (done) => { setResponseFile('gradleCCMultiModule.json'); @@ -467,7 +468,8 @@ describe('gradle Suite', function() { assert(tr.ran('gradlew build jacocoRootReport'), 'it should have run gradlew build'); assert(tr.invokedToolCount == 2, 'should have only run gradle 2 times'); assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=build.gradle;summaryfile=summary.xml;reportdirectory=CCReport43F6D5EF;ismultimodule=true;buildtool=Gradle;codecoveragetool=JaCoCo;\]/) >= 0, 'should have called enable code coverage.'); - assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=CCReport43F6D5EF\\summary.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); + assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=CCReport43F6D5EF\\summary.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0 || + tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=JaCoCo;summaryfile=CCReport43F6D5EF\/summary.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length == 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -477,7 +479,7 @@ describe('gradle Suite', function() { done(err); }); }) - + it('Gradle with cobertura selected should call enable and publish code coverage.', (done) => { setResponseFile('gradleCCSingleModule.json'); @@ -497,7 +499,8 @@ describe('gradle Suite', function() { assert(tr.ran('gradlew build cobertura'), 'it should have run gradlew build'); assert(tr.invokedToolCount == 2, 'should have only run gradle 2 times'); assert(tr.stdout.search(/##vso\[codecoverage.enable buildfile=build.gradle;summaryfile=coverage.xml;reportdirectory=CCReport43F6D5EF;ismultimodule=false;buildtool=Gradle;codecoveragetool=Cobertura;\]/) >= 0, 'should have called enable code coverage.'); - assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=Cobertura;summaryfile=CCReport43F6D5EF\\coverage.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); + assert(tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=Cobertura;summaryfile=CCReport43F6D5EF\\coverage.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0 || + tr.stdout.search(/##vso\[codecoverage.publish codecoveragetool=Cobertura;summaryfile=CCReport43F6D5EF\/coverage.xml;reportdirectory=CCReport43F6D5EF;\]/) >= 0, 'should have called publish code coverage.'); assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length == 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -507,7 +510,7 @@ describe('gradle Suite', function() { done(err); }); }) - + it('Gradle with jacoco selected and report generation failed should call enable but not publish code coverage.', (done) => { setResponseFile('gradleGood.json'); @@ -537,7 +540,7 @@ describe('gradle Suite', function() { done(err); }); }) - + it('Gradle with cobertura selected and report generation failed should call enable but not publish code coverage.', (done) => { setResponseFile('gradleGood.json'); diff --git a/Tests/L0/Gradle/gradleCCMultiModule.json b/Tests/L0/Gradle/gradleCCMultiModule.json index 86653a8e02b5..c2ea23f5505b 100644 --- a/Tests/L0/Gradle/gradleCCMultiModule.json +++ b/Tests/L0/Gradle/gradleCCMultiModule.json @@ -46,6 +46,12 @@ }, "CCReport43F6D5EF\\coverage.xml": { "isFile": true + }, + "CCReport43F6D5EF/summary.xml": { + "isFile": true + }, + "CCReport43F6D5EF/coverage.xml": { + "isFile": true } }, "rmRF": { diff --git a/Tests/L0/Gradle/gradleCCSingleModule.json b/Tests/L0/Gradle/gradleCCSingleModule.json index 78b096eef80f..91edcadffecb 100644 --- a/Tests/L0/Gradle/gradleCCSingleModule.json +++ b/Tests/L0/Gradle/gradleCCSingleModule.json @@ -46,6 +46,12 @@ }, "CCReport43F6D5EF\\coverage.xml": { "isFile": true + }, + "CCReport43F6D5EF/summary.xml": { + "isFile": true + }, + "CCReport43F6D5EF/coverage.xml": { + "isFile": true } }, "rmRF": {