[ccan] [PATCH] ccanlint: enhance and streamline "output" testing lines.

Rusty Russell rusty at rustcorp.com.au
Tue Sep 29 07:48:41 AEST 2015


David Gibson <david at gibson.dropbear.id.au> writes:
> On Tue, Sep 29, 2015 at 12:32:36AM +1000, David Gibson wrote:
>> On Mon, Sep 28, 2015 at 12:48:03PM +0930, Paul 'Rusty' Russell wrote:
>> > 1) Require "" around input
>> > 2) Make them optional around output: if not there, loose match whitespace
>> > 3) Handle \n in output.
>> > 4) Document that "Given xxx" is optional.
>> 
>> Patch looks fine to me.
>
> I take that back.  With a bit more playing, noticed that if you
> *don't* put" around the input, it will silently skip the example
> expected output test.

It should detect some malformed uses.  Let's beef it up, so it errors
on any comment not otherwise recognized which starts with "// given" or
"// outputs".  (It already caught the "given" case).

diff --git a/tools/ccanlint/tests/examples_run.c b/tools/ccanlint/tests/examples_run.c
index c7d04c2..258e290 100644
--- a/tools/ccanlint/tests/examples_run.c
+++ b/tools/ccanlint/tests/examples_run.c
@@ -125,8 +125,8 @@ static char *find_expect(struct ccan_file *file,
 			return expect;
 		}
 
-		/* "Given" without "output"? */
-		if (*input) {
+		/* Other malformed line? */
+		if (!strncasecmp(p, "given") || !strncasecmp(p, "outputs")) {
 			*error = true;
 			return p;
 		}

Cheers,
Rusty.


More information about the ccan mailing list