Re: [PATCH v2 4/6] tests: Add linter check for pipe placement style

2018-09-19 Thread Matthew DeVore
On Mon, Sep 17, 2018 at 5:34 PM Eric Sunshine  wrote:
>
> On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore  wrote:
> > tests: Add linter check for pipe placement style
>
> Until now, the various "lint" checks have been for genuine portability
> problems (except perhaps 'test-lint-duplicates'). This new lint check
> makes style violations worthy of failing "make test". Is the indeed
> the direction we want to go? (Genuine question. I can formulate
> arguments for either side.)
>
> > ---
> > diff --git a/t/Makefile b/t/Makefile
> > @@ -101,6 +101,16 @@ test-lint-filenames:
> > +test-lint-pipes:
> > +   @# Do not use \ to join lines when the next line starts with a
> > +   @# pipe. Instead, end the prior line with the pipe, and allow that 
> > to
> > +   @# join the lines implicitly.
> > +   @bad="$$(${PERL_PATH} -n0e 'm/(\n[^\n|]+\\\n[\t ]+\|[^\n]*)/ and \
> > + print qq{$$ARGV:$$1\n\n}' $(T))"; \
> > +   test -z "$$bad" || { \
> > +   printf >&2 "pipe at start of line in file(s):\n%s\n" 
> > "$$bad"; \
> > +   exit 1; }
>
> If we're going in the direction of linting style violations, then
> maybe generalize this by calling it "test-lint-style" rather than
> "test-lint-pipes", and perhaps move the body of the test to a new
> script check-shell-style.pl (or something), much as portability
> violations are housed in check-non-portable-shell.pl.

I agree with moving this code to a separate file. I also notice that
there is logic in a file called t/chainlint.sed which normalizes
scripts for the purpose of lint checks (e.g. it removes heredocs) and
I ought to be re-using this logic in order to make the new lint check
robust.

I think I'd like to shelve this particular commit and come back to it
once I have the time and I'm more familiar with the code base. It is
not critical to this patchset.


Re: [PATCH v2 4/6] tests: Add linter check for pipe placement style

2018-09-17 Thread Eric Sunshine
On Mon, Sep 17, 2018 at 6:25 PM Matthew DeVore  wrote:
> tests: Add linter check for pipe placement style

Until now, the various "lint" checks have been for genuine portability
problems (except perhaps 'test-lint-duplicates'). This new lint check
makes style violations worthy of failing "make test". Is the indeed
the direction we want to go? (Genuine question. I can formulate
arguments for either side.)

> ---
> diff --git a/t/Makefile b/t/Makefile
> @@ -101,6 +101,16 @@ test-lint-filenames:
> +test-lint-pipes:
> +   @# Do not use \ to join lines when the next line starts with a
> +   @# pipe. Instead, end the prior line with the pipe, and allow that to
> +   @# join the lines implicitly.
> +   @bad="$$(${PERL_PATH} -n0e 'm/(\n[^\n|]+\\\n[\t ]+\|[^\n]*)/ and \
> + print qq{$$ARGV:$$1\n\n}' $(T))"; \
> +   test -z "$$bad" || { \
> +   printf >&2 "pipe at start of line in file(s):\n%s\n" "$$bad"; 
> \
> +   exit 1; }

If we're going in the direction of linting style violations, then
maybe generalize this by calling it "test-lint-style" rather than
"test-lint-pipes", and perhaps move the body of the test to a new
script check-shell-style.pl (or something), much as portability
violations are housed in check-non-portable-shell.pl.