Repository: aurora Updated Branches: refs/heads/master 33d7e2170 -> d884680ad
Better handling of enums and constructor-only classes in test coverage check. Reviewed at https://reviews.apache.org/r/39089/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/d884680a Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/d884680a Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/d884680a Branch: refs/heads/master Commit: d884680ad8a7c0e436c3ce4ec80272d5d459fbac Parents: 33d7e21 Author: Bill Farner <[email protected]> Authored: Wed Oct 7 09:36:08 2015 -0700 Committer: Bill Farner <[email protected]> Committed: Wed Oct 7 09:36:08 2015 -0700 ---------------------------------------------------------------------- .../aurora/build/CoverageReportCheck.groovy | 27 ++++++++++---------- config/legacy_untested_classes.txt | 12 ++++++--- 2 files changed, 22 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/d884680a/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy b/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy index b471756..da91f39 100644 --- a/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy +++ b/buildSrc/src/main/groovy/org/apache/aurora/build/CoverageReportCheck.groovy @@ -76,23 +76,22 @@ class CoverageReportCheck extends DefaultTask { def checkClassCoverage(coverageReport) { def coverageErrors = coverageReport.package.class.collect { cls -> - // javac inserts a synthetic constructor for anonymous classes, and jacoco tends to mark - // these as covered in some cases, leading to flaky behavior. We work around that by - // collecting the coverage count for each method in each class, omitting the default - // constructor for anonymous classes. Anonymous classes are identified by their name, - // which we expect to be of the form 'Something$1'. Jacoco names default constructors - // '<init>', so we filter based on that. - def isAnonymous = { c -> c.@name ==~ /.*\$\d+/ } - def methodFilter = isAnonymous(cls) ? { m -> m.@name != '<init>' } : { true } - - // Always ignore static code, it should not count as test coverage. - def matchedMethods = cls.method.findAll({ m -> m.@name != '<clinit>' }).findAll(methodFilter) + def matchedMethods = cls.method + // Ignore static code, it should not count as test coverage. + .findAll({ m -> m.@name != '<clinit>' }) + // Ignore classes that only have a constructor. This will avoid tripping for things like + // constant-only utility classes, and 'value' classes like TypeLiteral and Clazz. + .findAll({ m -> m.@name != '<init>' }) + + // Ignore enums that contain only default methods. + if (matchedMethods.collect { m -> m.@name } == ['values', 'valueOf']) { + return null + } + if (matchedMethods.isEmpty()) { - // Ignore anonymous classes that only have a constructor. This will avoid tripping for - // things like TypeLiteral and Clazz. if (cls.@name in legacyClassesWithoutCoverage) { return 'Please remove ' + cls.@name + ' from the legacyClassesWithoutCoverage list' \ - + ', this check does not apply for constructor-only anonymous classes' \ + + ', this check does not apply for constructor-only classes' \ + ' or classes with only static class initialization code.' } else { return null http://git-wip-us.apache.org/repos/asf/aurora/blob/d884680a/config/legacy_untested_classes.txt ---------------------------------------------------------------------- diff --git a/config/legacy_untested_classes.txt b/config/legacy_untested_classes.txt index 88a71df..0f1e6be 100644 --- a/config/legacy_untested_classes.txt +++ b/config/legacy_untested_classes.txt @@ -1,6 +1,9 @@ org/apache/aurora/Protobufs$1 +org/apache/aurora/auth/CapabilityValidator$AuditCheck +org/apache/aurora/auth/UnsecureAuthModule$UnsecureCapabilityValidator org/apache/aurora/auth/UnsecureAuthModule$UnsecureCapabilityValidator$1 org/apache/aurora/auth/UnsecureAuthModule$UnsecureCapabilityValidator$2 +org/apache/aurora/auth/UnsecureAuthModule$UnsecureSessionValidator org/apache/aurora/scheduler/app/SchedulerMain$1 org/apache/aurora/scheduler/app/SchedulerMain$2 org/apache/aurora/scheduler/app/SchedulerMain$3 @@ -47,7 +50,8 @@ org/apache/aurora/scheduler/http/Utilization$4 org/apache/aurora/scheduler/http/Utilization$5 org/apache/aurora/scheduler/http/Utilization$Display org/apache/aurora/scheduler/http/Utilization$DisplayMetric -org/apache/aurora/scheduler/log/Log$Stream$InvalidPositionException +org/apache/aurora/scheduler/http/api/security/FieldGetter$IdentityFieldGetter +org/apache/aurora/scheduler/http/api/security/Kerberos5Realm org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule$3 org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule$4 @@ -56,11 +60,13 @@ org/apache/aurora/scheduler/mesos/DriverFactoryImpl org/apache/aurora/scheduler/mesos/LibMesosLoadingModule org/apache/aurora/scheduler/stats/AsyncStatsModule$OfferAdapter$1 org/apache/aurora/scheduler/stats/StatsModule$3 -org/apache/aurora/scheduler/storage/log/LogStorage$RecoveryFailedException +org/apache/aurora/scheduler/stats/TaskStatCalculator +org/apache/aurora/scheduler/storage/CallOrderEnforcingStorage$State +org/apache/aurora/scheduler/storage/backup/BackupModule$LifecycleHook +org/apache/aurora/scheduler/storage/mem/MemTaskStore$Task org/apache/aurora/scheduler/storage/mem/Util org/apache/aurora/scheduler/storage/mem/Util$1 org/apache/aurora/scheduler/testing/FakeStatsProvider$3 -org/apache/aurora/scheduler/updater/UpdateConfigurationException org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$LocalClientProvider org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$TestServerService org/apache/aurora/scheduler/zookeeper/guice/client/ZooKeeperClientModule$1
