|
68 | 68 | <!-- fornum task, used for test-repeat --> |
69 | 69 | <taskdef name="fornum" classname="edu.rice.cs.plt.ant.ForNumTask" classpath="lib/buildlib/plt-ant.jar" onerror="report" /> |
70 | 70 |
|
| 71 | + <!-- For code coverage report --> |
| 72 | + <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"> |
| 73 | + <classpath path="lib/jacocoant.jar"/> |
| 74 | + </taskdef> |
| 75 | + <property name="coverage-report-dir" value="coverage report"/> |
| 76 | + <property name="coverage-exec" value="jacoco.exec"/> |
| 77 | + |
71 | 78 | <!-- <extendclasspath path="lib/buildlib/junit.jar" /> --> |
72 | 79 |
|
73 | 80 | <fileset id="libs" dir="lib" includes="*.jar" /> <!-- Only include jars that are at the top level (not in buildlib) --> |
|
548 | 555 | <target name="do-test" depends="resolve-jvm-args, resolve-junit-jar"> |
549 | 556 | <echo message="Running all tests matching '${test-filter-string}' with command '${test-jvm}', using '${junit-jar}' and '${test-tools}'" /> |
550 | 557 | <extendclasspath path="${junit-jar}" /> |
| 558 | + <jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant"> |
551 | 559 | <junit haltonfailure="${test-halt}" failureproperty="test-failed" |
552 | 560 | fork="yes" forkmode="perTest" maxmemory="2G" jvm="${test-jvm}" dir="${basedir}"> |
553 | 561 | <classpath> |
|
570 | 578 | </syspropertyset> |
571 | 579 | <jvmarg line="${jvm-args} ${concjunit-bootclasspath}" /> |
572 | 580 | <formatter classname="${test-formatter-class}" usefile="${test-output-to-file}" /> |
573 | | - <batchtest> |
| 581 | + <batchtest fork="true"> |
574 | 582 | <fileset dir="classes/test"> |
575 | | - <filename name="**/*${test-filter-string}*/**" /> |
| 583 | + <filename name="**/*${test-filter-string}*/**" /> |
576 | 584 | <filename name="**/*Test.class" /> |
577 | 585 | </fileset> |
578 | 586 | </batchtest> |
579 | 587 | </junit> |
| 588 | + </jacoco:coverage> |
580 | 589 | <fail if="test-failed" message="One or more unit tests failed."/> |
| 590 | + <antcall target="generate-coverage-report" /> |
| 591 | + <delete file="${coverage-exec}"/> |
| 592 | + </target> |
| 593 | + |
| 594 | + <target name = "generate-coverage-report" xmlns:jacoco="antlib:org.jacoco.ant"> |
| 595 | + <jacoco:report> |
| 596 | + |
| 597 | + <executiondata> |
| 598 | + <file file="${coverage-exec}"/> |
| 599 | + </executiondata> |
| 600 | + |
| 601 | + <structure name="drjava"> |
| 602 | + <classfiles> |
| 603 | + <fileset dir="classes"/> |
| 604 | + </classfiles> |
| 605 | + <sourcefiles encoding="UTF-8"> |
| 606 | + <fileset dir="src"/> |
| 607 | + </sourcefiles> |
| 608 | + </structure> |
| 609 | + |
| 610 | + <html destdir="${coverage-report-dir}"/> |
| 611 | + |
| 612 | + </jacoco:report> |
581 | 613 | </target> |
582 | 614 |
|
583 | 615 |
|
|
976 | 1008 | Clean Targets |
977 | 1009 | ************* --> |
978 | 1010 |
|
979 | | - <target name="clean" depends="clean-intermediate, clean-products, clean-concjunit" |
980 | | - description="Remove all build products; the result should match the intended Subversion contents"> |
| 1011 | + <target name="clean" depends="clean-intermediate, clean-coverage-report, clean-products, clean-concjunit" description="Remove all build products; the result should match the intended Subversion contents"> |
981 | 1012 | </target> |
982 | 1013 |
|
983 | 1014 | <target name="clean-intermediate" unless="skip-clean"> |
|
986 | 1017 | <delete dir="classes" failonerror="${clean-can-fail}" /> |
987 | 1018 | <delete dir="cloverdb" failonerror="${clean-can-fail}" /> |
988 | 1019 | <delete dir="benchmarkSources" failonerror="${clean-can-fail}" /> |
989 | | - <delete dir="benchmarkResults" failonerror="${clean-can-fail}" /> |
990 | | - |
| 1020 | + <delete dir="benchmarkResults" failonerror="${clean-can-fail}" /> |
| 1021 | + |
991 | 1022 | <delete includeemptydirs="true" failonerror="${clean-can-fail}"> |
992 | 1023 | <fileset dir="testFiles"> |
993 | 1024 | <exclude name="**" /> |
|
1012 | 1043 | </delete> |
1013 | 1044 |
|
1014 | 1045 | </target> |
1015 | | - |
| 1046 | + |
| 1047 | + <target name="clean-coverage-report" unless="skip-clean"> |
| 1048 | + <delete dir="${coverage-report-dir}" failonerror="${clean-can-fail}" /> |
| 1049 | + <delete file="${coverage-exec}"/> |
| 1050 | + </target> |
| 1051 | + |
1016 | 1052 | <target name="clean-products" unless="skip-clean"> |
1017 | 1053 | <echo message="Deleting all final build products" /> |
1018 | 1054 |
|
|
0 commit comments