Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kcov] Support python coverage with Bazel 6 #18616

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

rpoyner-tri
Copy link
Contributor

@rpoyner-tri rpoyner-tri commented Jan 18, 2023

To work with the updated python stubs, pre-create our test output directory, and absorb/ignore more kinds of coverage-py command lines.

Closes #18615.


This change is Reviewable

Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #18615.

\cc @williamjallen FYI. No action required.

+@jwnimmer-tri for feature review.

Reviewable status: LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, missing label for release notes (waiting on @jwnimmer-tri)

@jwnimmer-tri
Copy link
Collaborator

@drake-jenkins-bot linux-focal-gcc-bazel-experimental-coverage please

@rpoyner-tri
Copy link
Contributor Author

Needs to be tested with some coverage builds.

@drake-jenkins-bot linux-focal-clang-bazel-experimental-coverage please.
@drake-jenkins-bot linux-jammy-gcc-bazel-experimental-everything-coverage please.

Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jinx

Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, missing label for release notes (waiting on @jwnimmer-tri)

@jwnimmer-tri jwnimmer-tri added status: single reviewer ok https://drake.mit.edu/reviewable.html release notes: none This pull request should not be mentioned in the release notes labels Jan 18, 2023
Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwnimmer-tri: lgty?

Reviewable status: LGTM missing from assignee jwnimmer-tri(platform) (waiting on @jwnimmer-tri)

@jwnimmer-tri
Copy link
Collaborator

Still working its way up my stack. I haven't tested locally yet.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: 2 unresolved discussions (waiting on @rpoyner-tri)


tools/dynamic_analysis/kcoverage.py line 22 at r1 (raw file):

    parser.add_argument('verb', type=str, help='coverage.py verb')
    parser.add_argument('-a', '--append', action='store_true', default=False,
                        help='coverage.py --append')

nit These help strings seem a bit of a pain to maintain, and I am not sure that any of these help strings is that helpful, either to someone reading this source code, or a user who accidentally ended up with --help output from this on the command line somehow.

Another tactic would be to define a local ...

ignore = "Drake will ignore this coverage.py argument."

... and then do help=ignore throughout.


tools/dynamic_analysis/kcoverage.py line 26 at r1 (raw file):

                        help='coverage.py --branch')
    parser.add_argument('--rcfile', type=str, help='coverage.py rcfile')
    parser.add_argument('-o', type=str, help='coverage.py outfile')

I don't see -o in the latest coverage run --help? Ah, this is a coverage lcov option that we need to throw away. That took me a little digging to unearth.

What do you think about this alternative:

In main(), check for if sys.argv[1] != 'run' immediately, without using argparse yet. That way we can bail out for lcov immediately, and we don't need to throw away -o anymore or keep chasing any new options that non-run command lines might grow in the future.

That would also mean there's no need to return the argparse namespace object anymore; just the extras are enough.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 unresolved discussions (waiting on @rpoyner-tri)


tools/dynamic_analysis/kcoverage.py line 54 at r1 (raw file):

    args, extra = parse_command_line(sys.argv[1:])
    if args.verb != 'run':
        return

Thinking about this line a bit more, I wonder if we should err a little bit more on the side of fail-fast here?

If the first argument is lcov, then we early-return declaring victory. (Possibly the same for other coverage verbs we know to be safely ignoreable.)

If the first argument is run then we run.

But if it is something else (e.g., if argument-passing or whitespace got screwed up somewhere along the line), we could fail-fast.

To work with the updated python stubs, pre-create our test output
directory, and absorb/ignore more kinds of coverage-py command lines.
@rpoyner-tri
Copy link
Contributor Author

Previously, rpoyner-tri (Rick Poyner (rico)) wrote…

Needs to be tested with some coverage builds.

@drake-jenkins-bot linux-focal-clang-bazel-experimental-coverage please.
@drake-jenkins-bot linux-jammy-gcc-bazel-experimental-everything-coverage please.

@drake-jenkins-bot linux-focal-clang-bazel-experimental-coverage please.
@drake-jenkins-bot linux-jammy-gcc-bazel-experimental-everything-coverage please.

Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 unresolved discussions (waiting on @jwnimmer-tri and @rpoyner-tri)


tools/dynamic_analysis/kcoverage.py line 26 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I don't see -o in the latest coverage run --help? Ah, this is a coverage lcov option that we need to throw away. That took me a little digging to unearth.

What do you think about this alternative:

In main(), check for if sys.argv[1] != 'run' immediately, without using argparse yet. That way we can bail out for lcov immediately, and we don't need to throw away -o anymore or keep chasing any new options that non-run command lines might grow in the future.

That would also mean there's no need to return the argparse namespace object anymore; just the extras are enough.

Done.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: 1 unresolved discussion (waiting on @rpoyner-tri)

@rpoyner-tri rpoyner-tri merged commit b4478e1 into RobotLocomotion:master Jan 20, 2023
xuchenhan-tri pushed a commit to xuchenhan-tri/drake that referenced this pull request Feb 3, 2023
* [kcov] Support python coverage with Bazel 6

To work with the updated python stubs, pre-create our test output
directory, and absorb/ignore more kinds of coverage-py command lines.
marcoag pushed a commit to marcoag/drake that referenced this pull request Feb 6, 2023
* [kcov] Support python coverage with Bazel 6

To work with the updated python stubs, pre-create our test output
directory, and absorb/ignore more kinds of coverage-py command lines.
xuchenhan-tri pushed a commit to xuchenhan-tri/drake that referenced this pull request Feb 6, 2023
* [kcov] Support python coverage with Bazel 6

To work with the updated python stubs, pre-create our test output
directory, and absorb/ignore more kinds of coverage-py command lines.
marcoag pushed a commit to marcoag/drake that referenced this pull request Mar 8, 2023
* [kcov] Support python coverage with Bazel 6

To work with the updated python stubs, pre-create our test output
directory, and absorb/ignore more kinds of coverage-py command lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: none This pull request should not be mentioned in the release notes status: single reviewer ok https://drake.mit.edu/reviewable.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forthcoming Bazel 6 release breaks Drake's python coverage support
2 participants