From 23fbfe2c75b326967aee673a67e6774a2d5f1320 Mon Sep 17 00:00:00 2001 From: Stephen <36011612+steuhs@users.noreply.github.com> Date: Mon, 18 Jun 2018 13:59:29 -0700 Subject: [PATCH 1/4] exclude test utility code from coverage testgrid Coverage testgrid uses the github attribute linguist-generated=true to exclude items. This commit is to fix the issue https://github.com/knative/serving/issues/1122. There may be side effects, because I am not sure whether other parties rely on the "linguist-generated" attribute as well and the change here may not be desired for them. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 00900bb838eb..98145cc4c032 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,4 @@ **/zz_generated.*.go linguist-generated=true /pkg/client/** linguist-generated=true +/pkg/controller/testing/** linguist-generated=true From 8696765a6bdc443511fd551f502c0ff70e3172fb Mon Sep 17 00:00:00 2001 From: Stephen <36011612+steuhs@users.noreply.github.com> Date: Mon, 18 Jun 2018 14:20:17 -0700 Subject: [PATCH 2/4] exclude test utility code from coverage testgrid This commit is a step toward fixing the issue https://github.com/knative/serving/issues/1122. We add the coverage-excluded to items we want to exclude from code coverage calculation & display --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 98145cc4c032..a9b87b6e2c9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,4 +4,4 @@ **/zz_generated.*.go linguist-generated=true /pkg/client/** linguist-generated=true -/pkg/controller/testing/** linguist-generated=true +/pkg/controller/testing/** coverage-excluded=true From 35a19592a16432c8b92849aa296d301a831830bb Mon Sep 17 00:00:00 2001 From: Stephen <36011612+steuhs@users.noreply.github.com> Date: Mon, 18 Jun 2018 15:03:06 -0700 Subject: [PATCH 3/4] exclude test utility code from coverage testgrid This commit is a step toward fixing the issue https://github.com/knative/serving/issues/1122. We add the coverage-excluded to items we want to exclude from code coverage calculation & display --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitattributes b/.gitattributes index a9b87b6e2c9a..4f9687ad108b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,4 +4,8 @@ **/zz_generated.*.go linguist-generated=true /pkg/client/** linguist-generated=true + +# coverage-excluded is an attribute used to explicitly exclude a path from being included in code +# coverage. If a path is marked as linguist-generated already, it will be implicitly excluded and +# there is no need to add the coverage-excluded attribute /pkg/controller/testing/** coverage-excluded=true From 2fa717e232203b1ad49652ee5ca6546e3129c102 Mon Sep 17 00:00:00 2001 From: Stephen <36011612+steuhs@users.noreply.github.com> Date: Mon, 18 Jun 2018 15:28:03 -0700 Subject: [PATCH 4/4] makes sure pkg/controller/testing folder is still reviewable --- pkg/controller/testing/hooks.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/controller/testing/hooks.go b/pkg/controller/testing/hooks.go index 9c3ea4486df7..b9a5541f0647 100644 --- a/pkg/controller/testing/hooks.go +++ b/pkg/controller/testing/hooks.go @@ -40,7 +40,7 @@ const ( /* CreateHookFunc is a function for handling a Create hook. Its runtime.Object -parameter will be the kubernetes resource created. The resource can be cast +parameter will be the Kubernetes resource created. The resource can be cast to its actual type like this: pod := obj.(*v1.Pod) @@ -53,7 +53,7 @@ type CreateHookFunc func(runtime.Object) HookResult /* UpdateHookFunc is a function for handling an update hook. its runtime.Object -parameter will be the kubernetes resource updated. The resource can be cast +parameter will be the Kubernetes resource updated. The resource can be cast to its actual type like this: pod := obj.(*v1.Pod)