This is an archive of the discontinued LLVM Phabricator instance.

[test] Improve FileCheck's numeric-expression.txt
ClosedPublic

Authored by thopre on May 12 2020, 3:44 PM.

Details

Summary

Various improvement for FileCheck's numeric-expression.txt test:

  • remove unused values in USE DEF FMT IMPL MATCH section
  • replace 14 literal for 0xe and 0xE to have example of hex literals
  • rename variable to be more self-descriptive
  • move CHECK as comment of the values being matched to help readability
  • add conversion tests
  • simplify test for use of several numeric variables by using existing variable
  • adjust position of error message check to match the alignment of the error message wrt. the output matched by the previous check

Diff Detail

Event Timeline

thopre created this revision.May 12 2020, 3:44 PM
thopre updated this revision to Diff 263553.May 12 2020, 4:01 PM

Fix format of repositionned CHECK directive

jdenny added inline comments.May 12 2020, 5:59 PM
llvm/test/FileCheck/numeric-expression.txt
52–53

Is there any reason not to replace these comments with the check directives themselves?

thopre marked an inline comment as done.May 13 2020, 7:32 AM
thopre added inline comments.
llvm/test/FileCheck/numeric-expression.txt
52–53

I hadn't think of that but having tried it now it doesn't work. For instance the VAR3+1 check will match with the CHECK-NEXT in the comment of the previous line. I could adapt the value to avoid hex values A, C and E but that seems a bit fragile. What do you think?

jdenny added inline comments.May 13 2020, 7:36 AM
llvm/test/FileCheck/numeric-expression.txt
52–53

Ah. Could you append {{.*}} to each CHECK-NEXT pattern?

rnk removed a reviewer: rnk.May 13 2020, 1:55 PM
thopre updated this revision to Diff 263855.May 13 2020, 2:23 PM
thopre marked 3 inline comments as done.

Move CHECK as comment of values being tested

llvm/test/FileCheck/numeric-expression.txt
52–53

Great idea!

thopre edited the summary of this revision. (Show Details)May 13 2020, 2:23 PM
jhenderson accepted this revision.May 14 2020, 12:04 AM

LGTM, but please wait for @jdenny to confirm. Is there any particular reason for you not to make the same improvements, re. comments inline, on the other sets of tests?

This revision is now accepted and ready to land.May 14 2020, 12:04 AM
jdenny accepted this revision.May 14 2020, 7:21 AM

LGTM, but please wait for @jdenny to confirm.

Other than the comment I just added, this much LGTM as well.

Is there any particular reason for you not to make the same improvements, re. comments inline, on the other sets of tests?

Agreed.

llvm/test/FileCheck/numeric-expression.txt
53–70

Should DEF here be EXPL as in the next block?

thopre updated this revision to Diff 263999.May 14 2020, 7:59 AM
thopre marked an inline comment as done.

Address review comments

thopre edited the summary of this revision. (Show Details)May 14 2020, 8:00 AM

LGTM, but please wait for @jdenny to confirm.

Other than the comment I just added, this much LGTM as well.

Is there any particular reason for you not to make the same improvements, re. comments inline, on the other sets of tests?

Agreed.

I went a bit further and renamed the variable as suggested by James in D60390. I've also changed {{.*}} for {{^}} which is both shorter, less demanding of the regular expression engine and make directive naturally aligned instead of having to use whitespaces at the end. Do you approve those changes?

thopre updated this revision to Diff 264002.May 14 2020, 8:20 AM

Simplify test for several variables

thopre edited the summary of this revision. (Show Details)May 14 2020, 8:20 AM
jdenny added inline comments.May 14 2020, 9:52 AM
llvm/test/FileCheck/numeric-expression.txt
156

For consistency with VAR42, should VAR4 become VAR31?

227–235

Can these checks be inlined like the others?

268–273

Can these checks be inlined?

287–294

Can these checks be inlined?

309–315

Can these checks be inlined?

Ah! I reviewed a stale diff. Give me a bit to correct.

jdenny marked an inline comment as done.May 14 2020, 9:58 AM
jdenny added inline comments.
llvm/test/FileCheck/numeric-expression.txt
156

Nevermind this.

Looks like this was the only additional change after the diff I reviewed.

thopre marked 5 inline comments as done.May 14 2020, 10:25 AM
thopre added inline comments.
llvm/test/FileCheck/numeric-expression.txt
227–235

I'm not too keen on it for 2 reasons:

  • CONFLICT2 and CONFLICT3 are both for the foobar line so would have to be interleaved with the input, after foobar.
  • having the CHECK on the same line as the input means they appear in the error message and makes the error message checking directives even longer
268–273

As above, when testing error message for CHECK directive I prefer to have them separated. Given how small is the example I don't think it's such a big deal.

287–294

Ditto.

309–315

Ditto.

jdenny accepted this revision.May 14 2020, 11:09 AM

LGTM again.

llvm/test/FileCheck/numeric-expression.txt
227–235

Thanks for explaining. It doesn't seem important enough to me to debate further. Unless @jhenderson objects, let's move on.

jhenderson accepted this revision.May 15 2020, 12:26 AM

LGTM, with a couple of nits.

llvm/test/FileCheck/numeric-expression.txt
12

I'm not sure I follow why in some cases, you've added {{^}}, but not in others. It looks like here for example, it's not needed.

17–19

Nit: throughout, in most places you've used two spaces before the start of the comment, but on this line at least, you've used 1. Probably you should be consistent. I have a marginal preference for 1, but don't mind 2 if it looks better to you.

thopre marked 4 inline comments as done.May 15 2020, 1:53 AM
thopre added inline comments.
llvm/test/FileCheck/numeric-expression.txt
12

I missed a few. Fixed now. In most cases it's not needed but adding them now means if the line is changed the test will still pass. Also it's nicer visually since it keeps everything aligned and consistent.

17–19

Sorry, I sticked to 2 because it was less work and it separates the CHECK better from the input values.

thopre updated this revision to Diff 264182.May 15 2020, 1:54 AM
thopre marked 2 inline comments as done.

Address comments

This revision was automatically updated to reflect the committed changes.