Skip to content

Conversation

@wking
Copy link
Contributor

@wking wking commented Sep 10, 2015

The previous version of this script would never print the success
messages, because when fail == 0 was true, none of the messages
would satisfy !r.Pass. This commit shifts the logic around to handle
the following cases:

a. If the verbose flag is set, print messages for all checks, using
TAP's "ok" and "not ok" to distinguish between per-check pass/fail.
b. If the verbose flag is not set, only print the failed messages (but
still keep the "not ok" prefix).

Spun off from #170.

@vbatts
Copy link
Member

vbatts commented Sep 10, 2015

i'm not seeing the brokenness?

vbatts@valse ~/src/opencontainers/specs (fix-dco-validate-on-merges) $ gr .tools/validate.go -range 92a7451...5a654b9
 * 5a654b9 .tools: cleanup the commit entry ... PASS
 * 041eb73 travis: fix DCO validation for merges ... PASS
 * 3f62423 Merge remote-tracking branch 'origin/pr/159' ... PASS
 * 712a746 Merge remote-tracking branch 'origin/pr/163' ... PASS
 * b1510a7 Merge pull request #172 from laijs/committer ... PASS
 * d3a6069 Change the rlimit type to string instead of int ... PASS
 * 339e038 Deduplicate the field of RootfsPropagation ... PASS
vbatts@valse ~/src/opencontainers/specs (fix-dco-validate-on-merges) $ gr .tools/validate.go -v -range 92a7451...5a654b9
 * 5a654b9 .tools: cleanup the commit entry ... PASS
  - has a valid DCO
 * 041eb73 travis: fix DCO validation for merges ... PASS
  - has a valid DCO
 * 3f62423 Merge remote-tracking branch 'origin/pr/159' ... PASS
  - merge commits do not require DCO
 * 712a746 Merge remote-tracking branch 'origin/pr/163' ... PASS
  - merge commits do not require DCO
 * b1510a7 Merge pull request #172 from laijs/committer ... PASS
  - merge commits do not require DCO
 * d3a6069 Change the rlimit type to string instead of int ... PASS
  - has a valid DCO
 * 339e038 Deduplicate the field of RootfsPropagation ... PASS
  - has a valid DCO

@wking
Copy link
Contributor Author

wking commented Sep 10, 2015

On Thu, Sep 10, 2015 at 12:02:39PM -0700, Vincent Batts wrote:

i'm not seeing the brokenness?

Your post-#170 phrasing isn't broken, it's just redundant. Details in
my commit message (5282b96, rebased onto #170), but the redundancy is
(eliding some nesting):

if _, fail := vr.PassFail(); fail == 0 {

if r.Pass {
fmt.Printf(" - %s\n", r.Msg)
}
}

How would the internal if check ever not fire? That's why my
initial suggestion was to just drop the internal if, and use 1:

if _, fail := vr.PassFail(); fail == 0 {

fmt.Printf(" - %s\n", r.Msg)
}

This PR does more than just drop the check, but that's what I was
pushing back on initially.

@vbatts
Copy link
Member

vbatts commented Sep 11, 2015

not. because that if r.Pass { is inside a loop for that validate set, not the single rule that was tested. A validation set may have failures and passes.

@wking
Copy link
Contributor Author

wking commented Sep 11, 2015

On Fri, Sep 11, 2015 at 07:08:31AM -0700, Vincent Batts wrote:

not. because that if r.Pass { is inside a loop for that validate
set, not the single rule that was tested. A validation set may
have failures and passes.

In general, a set may have failures and passes, but your entire loop
is inside the if _, fail := vr.PassFail(); fail == 0 check, which
means that none of the checks in that set failed.

@vbatts
Copy link
Member

vbatts commented Sep 11, 2015

i see. I'm wrong here. If pass count is 0 then there is no need for if r.Pass.

Let's remove this beginings of TAP output. It makes the layout not logical
and is not even proper TAP

On Fri, Sep 11, 2015 at 10:35 AM, W. Trevor King [email protected]
wrote:

On Fri, Sep 11, 2015 at 07:08:31AM -0700, Vincent Batts wrote:

not. because that if r.Pass { is inside a loop for that validate
set, not the single rule that was tested. A validation set may
have failures and passes.

In general, a set may have failures and passes, but your entire loop
is inside the if _, fail := vr.PassFail(); fail == 0 check, which
means that none of the checks in that set failed.


Reply to this email directly or view it on GitHub
#174 (comment).

@wking
Copy link
Contributor Author

wking commented Sep 11, 2015

On Fri, Sep 11, 2015 at 08:28:29AM -0700, Vincent Batts wrote:

Let's remove this beginings of TAP output. It makes the layout not
logical and is not even proper TAP

Do you have a different preference for distinguishing passing checks
from fails (maybe + vs - where you always use -)? I'm fine just
converting the whole thing to valid TAP, but I'm also happy to punt
that to a follow-up PR.

The previous version of this script would always pass this check,
because when 'fail == 0' was true, all of the messages had passed.
That lead to logic like:

a. If all checks passed for the commit and the verbose flag is set,
   print all the messages (which all passed).
b. If all checks passed for the commit and the verbose flag is not set,
   don't print details about any messages (which all passed).
c. If any checks failed, print all the failed messages.

That wasn't printing successful checks when the verbose flag was true
but some checks failed.  This commit shifts the logic around to:

A. If the verbose flag is set, print messages for all checks, using
   TAP's "ok" and "not ok" to distinguish between per-check pass/fail
   [1].
B. If the verbose flag is not set, only print the failed messages (but
   still keep the "not ok" prefix).

In the non-verbose case, then (b/c) and (B) look the same (modulo my
"not ok" prefix adjustment).  And in the verbose case, I think (A) is
preferable to (a/c), because there's no reason to *not* print
successful checks when you've enabled the verbose flag.

[1]: http://testanything.org/

Signed-off-by: W. Trevor King <[email protected]>
@wking
Copy link
Contributor Author

wking commented Sep 12, 2015

On Fri, Sep 11, 2015 at 08:38:14AM -0700, W. Trevor King wrote:

Fri, Sep 11, 2015 at 08:28:29AM -0700, Vincent Batts:

Let's remove this beginings of TAP output. It makes the layout not
logical and is not even proper TAP

Do you have a different preference for distinguishing passing checks
from fails (maybe + vs - where you always use -)? I'm fine just
converting the whole thing to valid TAP, but I'm also happy to punt
that to a follow-up PR.

In the absence of feedback here, I've added a follow-up commit
(2d70cd9) that makes the verbose output valid TAP and avoids the
de-indenting for non-verbose output. I'm still happy to pull that
commit off into a follow-up PR and reroll my initial commit if you
tell me how you'd rather distingish betwee passing checks and fails.

@wking
Copy link
Contributor Author

wking commented Sep 12, 2015 via email

Using TAP [1] makes it easy to consume the output of this tool in a
variety of existing harnesses [2].

Only the verbose results are TAP compliant, mostly because folks
aren't likely to care about verbosity if they're just piping the
results into a TAP harness.  If we end up wanting the non-verbose
output to be TAP compliant, we'll have to switch to the trailing count
approach explained in the "Unknown amount and failures" section of the
spec [1], and we'll have to keep a running counter of failed checks
(instead of the current len(DefaultRules)-based approach).

[1]: http://testanything.org/tap-version-13-specification.html
[2]: http://testanything.org/consumers.html

Signed-off-by: W. Trevor King <[email protected]>
@wking
Copy link
Contributor Author

wking commented Sep 12, 2015 via email

@wking wking changed the title .tools: Fix broken !r.Pass check when 'fail == 0' .tools: Fix redundant r.Pass check when 'fail == 0' Sep 17, 2015
@crosbymichael
Copy link
Member

This was moved to a separate project out of this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants