All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>, qemu-devel@nongnu.org
Cc: "Benoît Canet" <benoit.canet@irqsave.net>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Luiz Capitulino" <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 2/4] qapi: Use an explicit input file
Date: Mon, 31 Mar 2014 13:42:44 -0600	[thread overview]
Message-ID: <5339C534.4000806@redhat.com> (raw)
In-Reply-To: <20140331191642.21034.11615.stgit@fimbulvetr.bsc.es>

[-- Attachment #1: Type: text/plain, Size: 3174 bytes --]

On 03/31/2014 01:16 PM, Lluís Vilanova wrote:
> Use an explicit input file on the command-line instead of reading from standard input
> 
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---

> +++ b/Makefile
> @@ -238,33 +238,33 @@ qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
>  qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
>  $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
>  	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
> -		$(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, \
> +		$(gen-out-type) -i "$<" -o qga/qapi-generated -p "qga-", \

I still wonder if:

-o qga/qapi-generated -p "qga-" -i "$<"

is easier to read than injecting -i up front.  But it's not something
that I will block the patch for.

> @@ -368,7 +368,8 @@ check-tests/test-qapi.py: tests/test-qapi.py
>  
>  .PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
>  $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
> -	$(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py <$^ >$*.test.out 2>$*.test.err; echo $$? >$*.test.exit, "  TEST  $*.out")
> +	$(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py "$^" >$*.test.out 2>$*.test.err; echo $$? >$*.test.exit, "  TEST  $*.out")

Why is this line still long?  Shouldn't it have been split in 1/4?  And
why is this form using an argument of the input file, instead of adding
a -i option like all the others?

> +	@sed -i -e "s|$(SRC_PATH)/||g" $*.test.err

'sed -i' is a GNU-ism, and not portable to all sed.  It's not the first
use of 'sed -i' in the code base, but most of those uses so far are for
situations that are Linux-specific where GNU sed can be assumed.

>  	@diff -q $(SRC_PATH)/$*.out $*.test.out
>  	@diff -q $(SRC_PATH)/$*.err $*.test.err

You could instead have done:

	@sed "s|$(SRC_PATH)/||g" $*.test.err \
		| diff -q $(SRC_PATH_/$*.err -

to avoid the portability question.

> +++ b/tests/qapi-schema/test-qapi.py
> @@ -12,10 +12,11 @@
>  
>  from qapi import *
>  from pprint import pprint
> +import os
>  import sys
>  
>  try:
> -    exprs = parse_schema(sys.stdin)
> +    exprs = parse_schema(sys.argv[1])

Here's where I found it inconsistent with the rest of the patch.  It
seems it would be better to either use -i everywhere, or use sys.argv[1]
everywhere.

> +++ b/tests/qapi-schema/trailing-comma-list.err
> @@ -1 +1 @@
> -<stdin>:2:36: Expected "{", "[" or string
> +tests/qapi-schema/trailing-comma-list.json:2:36: Expected "{", "[" or string

These are some long error messages; is it also worth trimming the
leading "tests/qapi-schema/" in the sed script where you massage the
data before doing the diff on expected errors?

It's too late for this to go into 2.0, but I think we're getting close
to having a solution worth using at the start of the 2.1 devel cycle.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-03-31 19:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31 19:16 [Qemu-devel] [PATCH v6 0/4] qapi: Allow modularization of QAPI schema files Lluís Vilanova
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 1/4] qapi: [trivial] Break long command lines Lluís Vilanova
2014-03-31 19:32   ` Eric Blake
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 2/4] qapi: Use an explicit input file Lluís Vilanova
2014-03-31 19:42   ` Eric Blake [this message]
2014-04-01 14:05     ` Lluís Vilanova
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 3/4] qapi: Add a primitive to include other files from a QAPI schema file Lluís Vilanova
2014-03-31 20:00   ` Eric Blake
2014-04-01 13:46     ` Lluís Vilanova
2014-04-01 14:47       ` Eric Blake
2014-04-01 16:05         ` Lluís Vilanova
2014-03-31 19:16 ` [Qemu-devel] [PATCH v6 4/4] qapi: Add tests for the "include" directive Lluís Vilanova
2014-03-31 20:17   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5339C534.4000806@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.