Re: [PATCH v7 4/4] t1006: add tests for git cat-file --literally

2015-04-08 Thread Karthik Nayak


On April 9, 2015 2:04:08 AM GMT+05:30, Eric Sunshine sunsh...@sunshineco.com 
wrote:
On Wed, Apr 8, 2015 at 1:42 PM, karthik nayak karthik@gmail.com
wrote:
 On 04/08/2015 02:19 AM, Eric Sunshine wrote:
 On Sat, Apr 4, 2015 at 1:44 AM, Karthik Nayak
karthik@gmail.com
 wrote:
  Signed-off-by: Karthik Nayak karthik@gmail.com
  ---
  diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
  index ab36b1e..5b74044 100755
  --- a/t/t1006-cat-file.sh
  +++ b/t/t1006-cat-file.sh
  @@ -296,4 +308,19 @@ test_expect_success '%(deltabase) reports
packed
  delta bases' '
   }
'
 
  +bogus_type=bogus
  +bogus_sha1=$(git hash-object -t $bogus_type --literally -w
--stdin
  /dev/null)
  +
  +test_expect_success Type of broken object is correct '
  +   echo $bogus_type expect 
  +   git cat-file -t --literally $bogus_sha1 actual 
  +   test_cmp expect actual
  +'
  +
  +test_expect_success Size of broken object is correct '
  +   echo 0 expect 

 Zero is such a common fallback value when things go wrong that it
may
 not be the best choice for this test. Consequently, it might be
better
 to create the bogus object with non-zero length. Take a look at how
 'hello_length' and 'hello_sha1' are computed elsewhere in this
script
 for inspiration.

 The first part of this patch contains tests which make use of
'hello_length'
 adn 'hello_sha1', but I get what you're saying, will look into it.
Thanks.

Just to be sure we're on the same page, I wasn't suggesting re-using
'hello_size' and 'hello_sha1', but merely to use that as an example of
how to avoid hard-coding the length of your non-zero-length bogus
object. So, something like this, perhaps:

bogus_content='bogus'
bogus_size=$(strlen $bogus_content)
bogus_sha1=$(echo_without_newline $bogus_content |
git hash-object -t $bogus_type --literally -w --stdin)
...
test_expect_success Size of broken object is correct '
echo $bogus_size expect 
...
Yes, I had done exactly what you suggested here. Thanks 
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 4/4] t1006: add tests for git cat-file --literally

2015-04-08 Thread karthik nayak


On 04/08/2015 02:19 AM, Eric Sunshine wrote:

On Sat, Apr 4, 2015 at 1:44 AM, Karthik Nayak karthik@gmail.com wrote:
 Signed-off-by: Karthik Nayak karthik@gmail.com
 ---
 diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
 index ab36b1e..5b74044 100755
 --- a/t/t1006-cat-file.sh
 +++ b/t/t1006-cat-file.sh
 @@ -47,6 +47,18 @@ $content
  test_cmp expect actual
   '

 +test_expect_success Type of $type is correct using --literally '
 +   echo $type expect 
 +   git cat-file -t --literally $sha1 actual 
 +   test_cmp expect actual
 +'
 +
 +test_expect_success Size of $type is correct using --literally '
 +   echo $size expect 
 +   git cat-file -s --literally $sha1 actual 
 +   test_cmp expect actual
 +'
 +
   test -z $content ||
   test_expect_success Content of $type is correct '
  maybe_remove_timestamp $content $no_ts expect 
 @@ -296,4 +308,19 @@ test_expect_success '%(deltabase) reports packed delta 
bases' '
  }
   '

 +bogus_type=bogus
 +bogus_sha1=$(git hash-object -t $bogus_type --literally -w --stdin 
/dev/null)
 +
 +test_expect_success Type of broken object is correct '
 +   echo $bogus_type expect 
 +   git cat-file -t --literally $bogus_sha1 actual 
 +   test_cmp expect actual
 +'
 +
 +test_expect_success Size of broken object is correct '
 +   echo 0 expect 

Zero is such a common fallback value when things go wrong that it may
not be the best choice for this test. Consequently, it might be better
to create the bogus object with non-zero length. Take a look at how
'hello_length' and 'hello_sha1' are computed elsewhere in this script
for inspiration.

The first part of this patch contains tests which make use of 'hello_length'
adn 'hello_sha1', but I get what you're saying, will look into it. Thanks.


 +   git cat-file -s --literally $bogus_sha1 actual 
 +   test_cmp expect actual
 +'
 +
   test_done
 --
 2.4.0.rc1.249.g9f2ee54


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 4/4] t1006: add tests for git cat-file --literally

2015-04-08 Thread Eric Sunshine
On Wed, Apr 8, 2015 at 1:42 PM, karthik nayak karthik@gmail.com wrote:
 On 04/08/2015 02:19 AM, Eric Sunshine wrote:
 On Sat, Apr 4, 2015 at 1:44 AM, Karthik Nayak karthik@gmail.com
 wrote:
  Signed-off-by: Karthik Nayak karthik@gmail.com
  ---
  diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
  index ab36b1e..5b74044 100755
  --- a/t/t1006-cat-file.sh
  +++ b/t/t1006-cat-file.sh
  @@ -296,4 +308,19 @@ test_expect_success '%(deltabase) reports packed
  delta bases' '
   }
'
 
  +bogus_type=bogus
  +bogus_sha1=$(git hash-object -t $bogus_type --literally -w --stdin
  /dev/null)
  +
  +test_expect_success Type of broken object is correct '
  +   echo $bogus_type expect 
  +   git cat-file -t --literally $bogus_sha1 actual 
  +   test_cmp expect actual
  +'
  +
  +test_expect_success Size of broken object is correct '
  +   echo 0 expect 

 Zero is such a common fallback value when things go wrong that it may
 not be the best choice for this test. Consequently, it might be better
 to create the bogus object with non-zero length. Take a look at how
 'hello_length' and 'hello_sha1' are computed elsewhere in this script
 for inspiration.

 The first part of this patch contains tests which make use of 'hello_length'
 adn 'hello_sha1', but I get what you're saying, will look into it. Thanks.

Just to be sure we're on the same page, I wasn't suggesting re-using
'hello_size' and 'hello_sha1', but merely to use that as an example of
how to avoid hard-coding the length of your non-zero-length bogus
object. So, something like this, perhaps:

bogus_content='bogus'
bogus_size=$(strlen $bogus_content)
bogus_sha1=$(echo_without_newline $bogus_content |
git hash-object -t $bogus_type --literally -w --stdin)
...
test_expect_success Size of broken object is correct '
echo $bogus_size expect 
...
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 4/4] t1006: add tests for git cat-file --literally

2015-04-07 Thread Eric Sunshine
On Sat, Apr 4, 2015 at 1:44 AM, Karthik Nayak karthik@gmail.com wrote:
 Signed-off-by: Karthik Nayak karthik@gmail.com
 ---
 diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
 index ab36b1e..5b74044 100755
 --- a/t/t1006-cat-file.sh
 +++ b/t/t1006-cat-file.sh
 @@ -47,6 +47,18 @@ $content
 test_cmp expect actual
  '

 +test_expect_success Type of $type is correct using --literally '
 +   echo $type expect 
 +   git cat-file -t --literally $sha1 actual 
 +   test_cmp expect actual
 +'
 +
 +test_expect_success Size of $type is correct using --literally '
 +   echo $size expect 
 +   git cat-file -s --literally $sha1 actual 
 +   test_cmp expect actual
 +'
 +
  test -z $content ||
  test_expect_success Content of $type is correct '
 maybe_remove_timestamp $content $no_ts expect 
 @@ -296,4 +308,19 @@ test_expect_success '%(deltabase) reports packed delta 
 bases' '
 }
  '

 +bogus_type=bogus
 +bogus_sha1=$(git hash-object -t $bogus_type --literally -w --stdin 
 /dev/null)
 +
 +test_expect_success Type of broken object is correct '
 +   echo $bogus_type expect 
 +   git cat-file -t --literally $bogus_sha1 actual 
 +   test_cmp expect actual
 +'
 +
 +test_expect_success Size of broken object is correct '
 +   echo 0 expect 

Zero is such a common fallback value when things go wrong that it may
not be the best choice for this test. Consequently, it might be better
to create the bogus object with non-zero length. Take a look at how
'hello_length' and 'hello_sha1' are computed elsewhere in this script
for inspiration.

 +   git cat-file -s --literally $bogus_sha1 actual 
 +   test_cmp expect actual
 +'
 +
  test_done
 --
 2.4.0.rc1.249.g9f2ee54
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html