<div dir="ltr">Hi,<br><div><br>Using FileCheck, I have not found a way to make a group of CHECK-DAG directives match multiple occurrences of a string. For example, I naively thought the following would match successfully:<br><br>```<br>$ cat checks.txt <br>// CHECK: start<br>// CHECK-DAG: foo<br>// CHECK-DAG: foo<br>// CHECK-DAG: bar<br>// CHECK-NEXT: end<br><br>$ cat input.txt <br>start<br>foo<br>bar<br>foo<br>end<br><br>$ FileCheck --input-file=input.txt checks.txt<br>checks.txt:5:16: error: CHECK-NEXT: is not on the line after the previous match<br>// CHECK-NEXT: end<br> ^<br>input.txt:5:1: note: 'next' match was here<br>end<br>^<br>input.txt:3:4: note: previous match ended here<br>bar<br> ^<br>input.txt:4:1: note: non-matching line after previous match is here<br>foo<br>^<br>```<br><br></div><div>The trouble is that both "CHECK-DAG: foo" directives match the first "foo".<br><br></div><div>I'd like this ability for testing a parallel program that outputs a series of non-unique strings in non-deterministic order. Am I trying to push FileCheck beyond its intended domain? Is there some existing feature for this purpose that I've overlooked? If not, I see two potential solutions:<br><br></div><div>1. In a CHECK-DAG group, don't let the matches for patterns overlap.<br><br></div><div>2. Add a new CHECK-DAG-N directive, where N is some integer, to express that a pattern must have N non-overlapping matches.<br><br>An advantage of #1 that the intuitive way (at least in my mind) of expressing multiple
occurrences of a string, as in the example above, would work. An advantage of #2 is that existing CHECK-DAG functionality would not change, and so there should be no chance of impacting existing well formed tests.<br><br></div><div>To understand the issue better, I've prototyped #2. It still needs test cases and documentation, so it's not ready for a formal patch review. If people like the idea, I'll polish it up.<br><br></div><div>Thanks.<br><br></div><div>Joel<br></div></div>