git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] archive: add test testing MIME for created archive through compression filter

From
Jeff King <peff@peff.net>
Date
Oct 11, 2021, 16:07 UTC
Message-ID
<YWRhR9IXZfU93Uok@coredump.intra.peff.net>
In-Reply-To
<xmqqlf2zd0d4.fsf@gitster.g>
On Mon, Oct 11, 2021 at 08:53:11AM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> Bagas Sanjaya <bagasdotme@gmail.com> writes:
> 
> > +test_expect_success GZIP,BZIP2,XZ 'git archive with gzip, bzip2, and xz filters creates compressed tar archive with proper MIME type' '
> > +	git config tar.tar.bz2.command "bzip2 -c" &&
> > +	git config tar.tar.xz.command "xz -c" &&
> > +	git archive --output HEAD.tar.gz --prefix=src/ HEAD &&
> 
> I think a lot more portable and robust way to test the feature is to
> configure git config tar.tar.test.command (or come up with a name for
> a suffix to be used in the test), point it at a script created in this
> test script and run git archive with output filename that would trigger
> the command.  Then, arrange the test to notice if the "test" script was
> called with expected command line arguments and standard input.
> 
> That way, you do not need to rely on prereqs and you do not have to
> resort to un-portable use of the "file" command.  After all, you are
> *not* testing if "bzip2 -c" the user happens to have on their $PATH
> produces output their "find" recognises as bzip2 compressed.

That would work. Or perhaps using something portable like "tr" to do a nonsense conversion, and verifying that we can get convert back to the original. Like say, the tests added to t5000 by 767cf4579f (archive: implement configurable tar filters, 2011-06-21).

I don't think the newly proposed test is adding anything beyond that (except checking the system "bzip2" command, but as you say, that is not useful to us, nor portable).

-Peff
Previous: Junio C HamanoNext: Bagas Sanjaya
Message 4 of 6 in “archive: add test testing MIME for created archive through compression filter”
  1. archive: add test testing MIME for created archive through compression filterBagas Sanjaya, Oct 11, 2021
  2. Junio C HamanoOct 11, 2021
  3. Junio C HamanoOct 11, 2021
  4. Jeff KingOct 11, 2021
  5. Bagas SanjayaOct 12, 2021
  6. Junio C HamanoOct 12, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.