[go] cmd/dist: add -cover flag

15 views
Skip to first unread message

Than McIntosh (Gerrit)

unread,
Mar 25, 2022, 1:39:37 PM3/25/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Than McIntosh has uploaded this change for review.

View Change

cmd/dist: add -cover flag

DO NOT SUBMIT

Add a "-cover" flag to the dist command, to enable collecting
code coverage from the equivalent of all.bash. Add a new
"cover.bash" script modeled after "race.bash".

Note:
- this patch still needs work, specifically cover.bash code
to set GOCOVERDIR, collect profiles afterwards

Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
---
M src/cmd/dist/test.go
A src/cover.bash
2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index a540a2a..1186d30 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -33,6 +33,7 @@
flag.BoolVar(&noRebuild, "no-rebuild", false, "overrides -rebuild (historical dreg)")
flag.BoolVar(&t.keepGoing, "k", false, "keep going even when error occurred")
flag.BoolVar(&t.race, "race", false, "run in race builder mode (different set of tests)")
+ flag.BoolVar(&t.cover, "cover", false, "run in coverage testing mode")
flag.BoolVar(&t.compileOnly, "compile-only", false, "compile tests, but don't run them. This is for some builders. Not all dist tests respect this flag, but most do.")
flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners")
flag.StringVar(&t.runRxStr, "run", os.Getenv("GOTESTONLY"),
@@ -49,6 +50,7 @@
// tester executes cmdtest.
type tester struct {
race bool
+ cover bool
listMode bool
rebuild bool
failed bool
@@ -404,6 +406,9 @@
if t.race {
args = append(args, "-race")
}
+ if t.cover {
+ args = append(args, "-cover")
+ }
if t.compileOnly {
args = append(args, "-run=^$")
}
@@ -525,7 +530,7 @@
})
}

- if t.race {
+ if t.race || t.cover {
return
}

@@ -1624,7 +1629,7 @@
// a single argument.
// It returns an empty string if a pre-built binary should not be used.
func (t *tester) prebuiltGoPackageTestBinary() string {
- if len(stdMatches) != 1 || t.race || t.compileOnly || os.Getenv("GO_BUILDER_NAME") == "" {
+ if len(stdMatches) != 1 || t.race || t.cover || t.compileOnly || os.Getenv("GO_BUILDER_NAME") == "" {
return ""
}
pkg := stdMatches[0]
diff --git a/src/cover.bash b/src/cover.bash
new file mode 100644
index 0000000..ffdd7b6
--- /dev/null
+++ b/src/cover.bash
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+# Copyright 2013 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+set -e
+
+if [ ! -f make.bash ]; then
+ echo 'cover.bash must be run from $GOROOT/src' 1>&2
+ exit 1
+fi
+. ./make.bash --no-banner
+go install -cover cmd std
+# TODOs:
+# - fix hard-coded dist test rebuild of tools
+# - set GOCOVERDIR prior to run below
+go tool dist test -cover

To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
Gerrit-Change-Number: 395897
Gerrit-PatchSet: 1
Gerrit-Owner: Than McIntosh <th...@google.com>
Gerrit-MessageType: newchange

Than McIntosh (Gerrit)

unread,
Apr 20, 2022, 7:03:20 AM4/20/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Than McIntosh uploaded patch set #3 to this change.

View Change

cmd/dist: add -cover flag

DO NOT SUBMIT

Add a "-cover" flag to the dist command, to enable collecting
code coverage from the equivalent of all.bash. Add a new
"cover.bash" script modeled after "race.bash".

Note:
- this patch still needs work, specifically cover.bash code
to set GOCOVERDIR, collect profiles afterwards

Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
---
M src/cmd/dist/test.go
A src/cover.bash
2 files changed, 43 insertions(+), 2 deletions(-)

To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
Gerrit-Change-Number: 395897
Gerrit-PatchSet: 3
Gerrit-Owner: Than McIntosh <th...@google.com>
Gerrit-MessageType: newpatchset

Than McIntosh (Gerrit)

unread,
Apr 20, 2022, 7:07:51 AM4/20/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Patch set 4:Run-TryBot +1

View Change

    To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
    Gerrit-Change-Number: 395897
    Gerrit-PatchSet: 4
    Gerrit-Owner: Than McIntosh <th...@google.com>
    Gerrit-Reviewer: Than McIntosh <th...@google.com>
    Gerrit-Comment-Date: Wed, 20 Apr 2022 11:07:47 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Than McIntosh (Gerrit)

    unread,
    Apr 20, 2022, 8:10:25 AM4/20/22
    to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

    Patch set 5:Run-TryBot +1

    View Change

      To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
      Gerrit-Change-Number: 395897
      Gerrit-PatchSet: 5
      Gerrit-Owner: Than McIntosh <th...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Than McIntosh <th...@google.com>
      Gerrit-Comment-Date: Wed, 20 Apr 2022 12:10:22 +0000

      Than McIntosh (Gerrit)

      unread,
      Apr 20, 2022, 9:56:36 AM4/20/22
      to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

      Patch set 7:Run-TryBot +1

      View Change

        To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
        Gerrit-Change-Number: 395897
        Gerrit-PatchSet: 7
        Gerrit-Owner: Than McIntosh <th...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-Comment-Date: Wed, 20 Apr 2022 13:56:32 +0000

        Than McIntosh (Gerrit)

        unread,
        Apr 20, 2022, 2:00:06 PM4/20/22
        to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

        Patch set 10:Run-TryBot +1

        View Change

          To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
          Gerrit-Change-Number: 395897
          Gerrit-PatchSet: 10
          Gerrit-Owner: Than McIntosh <th...@google.com>
          Gerrit-Reviewer: Gopher Robot <go...@golang.org>
          Gerrit-Reviewer: Than McIntosh <th...@google.com>
          Gerrit-Comment-Date: Wed, 20 Apr 2022 18:00:02 +0000

          Than McIntosh (Gerrit)

          unread,
          Apr 20, 2022, 8:36:28 PM4/20/22
          to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

          Patch set 11:Run-TryBot +1

          View Change

            To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            Gerrit-Change-Number: 395897
            Gerrit-PatchSet: 11
            Gerrit-Owner: Than McIntosh <th...@google.com>
            Gerrit-Reviewer: Gopher Robot <go...@golang.org>
            Gerrit-Reviewer: Than McIntosh <th...@google.com>
            Gerrit-Comment-Date: Thu, 21 Apr 2022 00:36:23 +0000

            Than McIntosh (Gerrit)

            unread,
            Apr 22, 2022, 2:44:54 PM4/22/22
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

            Than McIntosh uploaded patch set #16 to this change.

            View Change

            cmd/dist: add -cover flag

            DO NOT SUBMIT

            Add a "-cover" flag to the dist command, to enable collecting
            code coverage from the equivalent of all.bash. Add a new
            "cover.bash" script modeled after "race.bash".

            Note:
            - this patch still needs work, specifically cover.bash code
            to set GOCOVERDIR, collect profiles afterwards

            Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            ---
            M src/cmd/dist/test.go
            A src/cover.bash
            2 files changed, 43 insertions(+), 2 deletions(-)

            To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            Gerrit-Change-Number: 395897
            Gerrit-PatchSet: 16
            Gerrit-Owner: Than McIntosh <th...@google.com>
            Gerrit-Reviewer: Gopher Robot <go...@golang.org>
            Gerrit-Reviewer: Than McIntosh <th...@google.com>
            Gerrit-MessageType: newpatchset

            Than McIntosh (Gerrit)

            unread,
            Apr 22, 2022, 2:50:54 PM4/22/22
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

            Than McIntosh uploaded patch set #17 to this change.

            View Change

            cmd/dist: add -cover flag

            DO NOT SUBMIT

            Add a "-cover" flag to the dist command, to enable collecting
            code coverage from the equivalent of all.bash. Add a new
            "cover.bash" script modeled after "race.bash".

            Note:
            - this patch still needs work, specifically cover.bash code
            to set GOCOVERDIR, collect profiles afterwards

            Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            ---
            M src/cmd/dist/test.go
            A src/cover.bash
            2 files changed, 43 insertions(+), 2 deletions(-)

            To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            Gerrit-Change-Number: 395897
            Gerrit-PatchSet: 17

            Than McIntosh (Gerrit)

            unread,
            Apr 22, 2022, 2:52:50 PM4/22/22
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

            Than McIntosh uploaded patch set #18 to this change.

            View Change

            cmd/dist: add -cover flag

            DO NOT SUBMIT

            Add a "-cover" flag to the dist command, to enable collecting
            code coverage from the equivalent of all.bash. Add a new
            "cover.bash" script modeled after "race.bash".

            Note:
            - this patch still needs work, specifically cover.bash code
            to set GOCOVERDIR, collect profiles afterwards

            Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            ---
            M src/cmd/dist/test.go
            A src/cover.bash
            2 files changed, 43 insertions(+), 2 deletions(-)

            To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
            Gerrit-Change-Number: 395897
            Gerrit-PatchSet: 18

            Than McIntosh (Gerrit)

            unread,
            Apr 22, 2022, 2:53:56 PM4/22/22
            to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

            Patch set 18:Run-TryBot +1

            View Change

              To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

              Gerrit-Project: go
              Gerrit-Branch: master
              Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
              Gerrit-Change-Number: 395897
              Gerrit-PatchSet: 18
              Gerrit-Owner: Than McIntosh <th...@google.com>
              Gerrit-Reviewer: Gopher Robot <go...@golang.org>
              Gerrit-Reviewer: Than McIntosh <th...@google.com>
              Gerrit-Comment-Date: Fri, 22 Apr 2022 18:53:53 +0000

              Than McIntosh (Gerrit)

              unread,
              Apr 22, 2022, 3:27:29 PM4/22/22
              to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

              Patch set 19:Run-TryBot +1

              View Change

                To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                Gerrit-Change-Number: 395897
                Gerrit-PatchSet: 19
                Gerrit-Owner: Than McIntosh <th...@google.com>
                Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                Gerrit-Reviewer: Than McIntosh <th...@google.com>
                Gerrit-Comment-Date: Fri, 22 Apr 2022 19:27:27 +0000

                Than McIntosh (Gerrit)

                unread,
                Apr 27, 2022, 11:20:51 AM4/27/22
                to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                Patch set 22:Run-TryBot +1

                View Change

                  To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

                  Gerrit-Project: go
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                  Gerrit-Change-Number: 395897
                  Gerrit-PatchSet: 22
                  Gerrit-Owner: Than McIntosh <th...@google.com>
                  Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                  Gerrit-Reviewer: Than McIntosh <th...@google.com>
                  Gerrit-Comment-Date: Wed, 27 Apr 2022 15:20:47 +0000

                  Than McIntosh (Gerrit)

                  unread,
                  Apr 28, 2022, 10:36:13 AM4/28/22
                  to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                  Patch set 23:Run-TryBot +1

                  View Change

                    To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                    Gerrit-Change-Number: 395897
                    Gerrit-PatchSet: 23
                    Gerrit-Owner: Than McIntosh <th...@google.com>
                    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                    Gerrit-Reviewer: Than McIntosh <th...@google.com>
                    Gerrit-Comment-Date: Thu, 28 Apr 2022 14:36:10 +0000

                    Than McIntosh (Gerrit)

                    unread,
                    May 6, 2022, 11:26:48 AM5/6/22
                    to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                    Patch set 34:Run-TryBot +1

                    View Change

                      To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                      Gerrit-Change-Number: 395897
                      Gerrit-PatchSet: 34
                      Gerrit-Owner: Than McIntosh <th...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      Gerrit-Reviewer: Than McIntosh <th...@google.com>
                      Gerrit-Comment-Date: Fri, 06 May 2022 15:26:44 +0000

                      Than McIntosh (Gerrit)

                      unread,
                      May 9, 2022, 1:59:22 PM5/9/22
                      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

                      Attention is currently required from: Than McIntosh.

                      Than McIntosh uploaded patch set #36 to this change.

                      View Change

                      cmd/dist: add -cover flag

                      DO NOT SUBMIT

                      Add a "-cover" flag to the dist command, to enable collecting
                      code coverage from the equivalent of all.bash. Add a new
                      "cover.bash" script modeled after "race.bash".

                      Note:
                      - this patch still needs work, specifically cover.bash code
                      to set GOCOVERDIR, collect profiles afterwards

                      Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                      ---
                      M src/cmd/dist/test.go
                      A src/cover.bash
                      2 files changed, 45 insertions(+), 2 deletions(-)

                      To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                      Gerrit-Change-Number: 395897
                      Gerrit-PatchSet: 36
                      Gerrit-Owner: Than McIntosh <th...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      Gerrit-Reviewer: Than McIntosh <th...@google.com>
                      Gerrit-Attention: Than McIntosh <th...@google.com>
                      Gerrit-MessageType: newpatchset

                      Than McIntosh (Gerrit)

                      unread,
                      May 16, 2022, 2:25:50 PM5/16/22
                      to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                      Patch set 38:Run-TryBot +1

                      View Change

                      1 comment:

                      • Patchset:

                      To view, visit change 395897. To unsubscribe, or for help writing mail filters, visit settings.

                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I3b185fa87b32b48addc65a84c9a7f5c1c03b9a14
                      Gerrit-Change-Number: 395897
                      Gerrit-PatchSet: 38
                      Gerrit-Owner: Than McIntosh <th...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      Gerrit-Reviewer: Than McIntosh <th...@google.com>
                      Gerrit-Comment-Date: Mon, 16 May 2022 18:25:46 +0000
                      Gerrit-HasComments: Yes
                      Gerrit-Has-Labels: Yes
                      Gerrit-MessageType: comment
                      Reply all
                      Reply to author
                      Forward
                      0 new messages