git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Stefan Beller <sbeller@google.com>, git@vger.kernel.org
Subject: Re: [PATCH 2/2] t6500: mark tests as SHA1 reliant
Date: Sat, 29 Jul 2017 17:58:33 +0000	[thread overview]
Message-ID: <20170729175833.4idan3befldn5vgp@genre.crustytoothpaste.net> (raw)
In-Reply-To: <xmqq379gmco6.fsf@gitster.mtv.corp.google.com>

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

On Fri, Jul 28, 2017 at 03:14:49PM -0700, Junio C Hamano wrote:
> Stefan Beller <sbeller@google.com> writes:
> 
> > The first test marked relies on hard coded sha1:
> >
> > 	# We need to create two object whose sha1s start with 17
> > 	# since this is what git gc counts.  As it happens, these
> > 	# two blobs will do so.
> > 	test_commit 263 &&
> > 	test_commit 410 &&
> >
> > The next two seem to rely on state from the first one, I did not
> > investigate.
> 
> I am moderately negative on this approach, if it is meant to suggest
> the final shape of our test suite patch 1/2 started.
> 
> This script may be a good example you can use to demonstrate a much
> better approach.  As the above comment in the test shows, we want to
> create two objects whose object names begin with "17", and running
> test_commit with 263 and 410 at this point in the test was a way to
> achieve that when Git uses SHA-1 as its hash.
> 
> When we use a hash different from SHA-1, the exact strings 263 and
> 410 may change, but we should be able to find two other strings that
> has the same property (i.e. they results in objects that share the
> prefix "17").  Perhaps a better way forward for this kind of test is
> to parameterize these hardcoded constants and make it easier to use
> different values without having to change the rest of the script
> when we switch the hash function?  So perhaps have something like
> 
> 	case "$GIT_HASH_FUNCTION" in
> 	SHA-1)	
> 		TEST_17_1="263 410" ;;
> 	CORRUPT-SHA-1)	
> 		TEST_17_1="something else" ;;
>         esac

One approach I had considered taking is having a helper of some sort
that wrapped a simple key/value store.  We could pass the wrapper the
SHA-1 value (or, if necessary, an arbitrary key) and have it return the
proper value based on the given hash function.

That does have the downsides that the values may not present in the
tests themselves, and that people adding new tests will of course need
to run the test suite twice.  But it does make the tests easier to read.

Opinions on the desirability of this approach are of course welcome.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

  reply	other threads:[~2017-07-29 17:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28 17:18 [RFD PATCH 0/2] How to migrate our test infrastructure away from sha1 Stefan Beller
2017-07-28 17:18 ` [PATCH 1/2] alter hash function: expose test dependencies on sha1 Stefan Beller
2017-07-28 21:52   ` Junio C Hamano
2017-07-28 17:18 ` [PATCH 2/2] t6500: mark tests as SHA1 reliant Stefan Beller
2017-07-28 17:59   ` Junio C Hamano
2017-07-28 21:43     ` Stefan Beller
2017-07-28 22:14   ` Junio C Hamano
2017-07-29 17:58     ` brian m. carlson [this message]
2017-07-30 21:21       ` Junio C Hamano
2017-07-30 23:00         ` brian m. carlson
2017-07-30 23:24           ` brian m. carlson
2017-07-31 20:17             ` Ævar Arnfjörð Bjarmason
2017-07-31 20:30               ` Stefan Beller
2017-07-31 20:26             ` Stefan Beller
2017-07-31 23:54               ` brian m. carlson

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20170729175833.4idan3befldn5vgp@genre.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sbeller@google.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).