[PATCH] test case fixes for Solaris

Danek Duvall danek.duvall at oracle.com
Thu Aug 22 18:02:42 CDT 2013


Matt Mackall wrote:

> On Wed, 2013-08-21 at 15:14 -0700, Danek Duvall wrote:
> > Seems to be "diff -u" specifically when there's no difference.  We could
> > make the rule that when you expect no difference, you use plain "diff", or
> > "cmp", or something, though of course when something goes wrong, and there
> > *is* a difference, you either get less useful output (context diffs) or no
> > output at all (cmp).  test-command-template.t uses both cmp and diff,
> > running diff only if cmp finds differences.
> 
> I'm not super-worried about the case where the test fails and we get
> weird output.

Okay.

> > I probably would gravitate towards using context diffs for no output
> > (assuming that you can write a test that checks both the command and its
> > output), or the cmp/diff combo if I can figure out that regex.  But I'm not
> > sure I'm qualified to make the decision here.
> > 
> > I'm really not sure how else to work around the lack of grep -a.
> 
> Perhaps use our inline Python support:
> 
> $ foo > bar
> >>> for line in open('bar'):
> ...     if 'baz' in line: print line

Nice; done.

> > > But even where that's done, we'll want the check-code rule to avoid
> > > creep-back.
> > > 
> > > >   - I know that GNU head and tail at some point in the past started
> > > >     disallowing args like "-8" and +8", and required the use of -n, but
> > > >     then I think backed off of that change.  So I'm not sure what the right
> > > >     thing is here.
> > > 
> > > Probably complains on some machines still.
> > 
> > Right.  So if we have to deal with both, then we need an alternative to
> > tail.  You can use "sed -n 'x,$p'" as an alternative to "tail +x", but I'm
> > not sure how to emulate the "normal" tail operation with other shell
> > commands.
> 
> Looks like the two places that are using it are legacy from before we
> had glob/regex support built into the test format.

Not sure I follow how that would allow us to pipe a set of N lines of a
command's output into a file.  In particular, I don't see how tail's use in
test-import-merge.t can be converted to that.

I'll also note that "tail -2" is already used in test-copy.t (changed to
remove -n back in 2006, apparently on request from a Sun engineer) and
hasn't caused any problems.  Plus "head" is used in numerous places without
-n.  Though I'll note that on Solaris, for some idiotic reason
/usr/bin/head supports -n, while /usr/bin/tail doesn't.  It's been that way
as far back as I can tell (1994 or so), so I suppose it's possible that for
whatever time period the GNU versions required -n, they may have only done
so for one command and not the other for similarly inscrutable reasons.

At any rate, given the rampant disuse of -n, should I just leave this
change alone and add a test to prevent it from coming back?

Thanks,
Danek


More information about the Mercurial-devel mailing list