Patchwork revbranchcache: add test for when the cache is not writable

login
register
mail settings
Submitter Durham Goode
Date March 17, 2015, 9:30 p.m.
Message ID <1b5c3b4c0fd1ff44c822.1426627829@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8127/
State Superseded
Headers show

Comments

Durham Goode - March 17, 2015, 9:30 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1426627796 25200
#      Tue Mar 17 14:29:56 2015 -0700
# Node ID 1b5c3b4c0fd1ff44c8226aa1818c094174cbbc2e
# Parent  567ae53657544744155897ada91f16f8af61ad8a
revbranchcache: add test for when the cache is not writable

The revbranchecache code already handled the case when the cache file wasn't
writable, but let's add a test as well so future changes don't regress this.
Yuya Nishihara - March 18, 2015, 12:22 p.m.
On Tue, 17 Mar 2015 14:30:29 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1426627796 25200
> #      Tue Mar 17 14:29:56 2015 -0700
> # Node ID 1b5c3b4c0fd1ff44c8226aa1818c094174cbbc2e
> # Parent  567ae53657544744155897ada91f16f8af61ad8a
> revbranchcache: add test for when the cache is not writable
> 
> The revbranchecache code already handled the case when the cache file wasn't
> writable, but let's add a test as well so future changes don't regress this.
> 
> diff --git a/tests/test-branches.t b/tests/test-branches.t
> --- a/tests/test-branches.t
> +++ b/tests/test-branches.t
> @@ -547,6 +547,13 @@ revision branch cache is created when bu
>    0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
>    0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
>    0070: f8 94 c2 56 80 00 00 03                         |...V....|
> +no errors when revbranchcache is not writable
> +  $ echo >> .hg/cache/rbc-revs-v1
> +  $ chmod a-w .hg/cache/rbc-revs-v1
> +  $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
> +  couldn't write revision branch cache: [Errno 13] Permission denied: '$TESTTMP/a/.hg/cache/rbc-revs-v1'
> +  5
> +  $ chmod a+w .hg/cache/rbc-revs-v1

It would need "#if unix-permissions no-root".
Matt Mackall - March 18, 2015, 9:58 p.m.
On Tue, 2015-03-17 at 14:30 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1426627796 25200
> #      Tue Mar 17 14:29:56 2015 -0700
> # Node ID 1b5c3b4c0fd1ff44c8226aa1818c094174cbbc2e
> # Parent  567ae53657544744155897ada91f16f8af61ad8a
> revbranchcache: add test for when the cache is not writable
> 
> The revbranchecache code already handled the case when the cache file wasn't
> writable, but let's add a test as well so future changes don't regress this.
> 
> diff --git a/tests/test-branches.t b/tests/test-branches.t
> --- a/tests/test-branches.t
> +++ b/tests/test-branches.t
> @@ -547,6 +547,13 @@ revision branch cache is created when bu
>    0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
>    0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
>    0070: f8 94 c2 56 80 00 00 03                         |...V....|
> +no errors when revbranchcache is not writable

Right, no errors..

> +  $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
> +  couldn't write revision branch cache: [Errno 13] Permission denied: '$TESTTMP/a/.hg/cache/rbc-revs-v1'

Wait, what were we testing again?

I've dropped the --debug and added in the #if that Yuya mentioned,
thanks.
Durham Goode - March 18, 2015, 10:01 p.m.
On 3/18/15 2:58 PM, Matt Mackall wrote:
> On Tue, 2015-03-17 at 14:30 -0700, Durham Goode wrote:
>> # HG changeset patch
>> # User Durham Goode <durham@fb.com>
>> # Date 1426627796 25200
>> #      Tue Mar 17 14:29:56 2015 -0700
>> # Node ID 1b5c3b4c0fd1ff44c8226aa1818c094174cbbc2e
>> # Parent  567ae53657544744155897ada91f16f8af61ad8a
>> revbranchcache: add test for when the cache is not writable
>>
>> The revbranchecache code already handled the case when the cache file wasn't
>> writable, but let's add a test as well so future changes don't regress this.
>>
>> diff --git a/tests/test-branches.t b/tests/test-branches.t
>> --- a/tests/test-branches.t
>> +++ b/tests/test-branches.t
>> @@ -547,6 +547,13 @@ revision branch cache is created when bu
>>     0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
>>     0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
>>     0070: f8 94 c2 56 80 00 00 03                         |...V....|
>> +no errors when revbranchcache is not writable
> Right, no errors..
>
>> +  $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
>> +  couldn't write revision branch cache: [Errno 13] Permission denied: '$TESTTMP/a/.hg/cache/rbc-revs-v1'
> Wait, what were we testing again?
Well, I wanted to verify that the code path was actually hit.  I'm fine 
with it without the --debug though.
>
> I've dropped the --debug and added in the #if that Yuya mentioned,
> thanks.
>
If you added the #if manually, you can ignore my V2.  That was the only 
change.

Patch

diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -547,6 +547,13 @@  revision branch cache is created when bu
   0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
   0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
   0070: f8 94 c2 56 80 00 00 03                         |...V....|
+no errors when revbranchcache is not writable
+  $ echo >> .hg/cache/rbc-revs-v1
+  $ chmod a-w .hg/cache/rbc-revs-v1
+  $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
+  couldn't write revision branch cache: [Errno 13] Permission denied: '$TESTTMP/a/.hg/cache/rbc-revs-v1'
+  5
+  $ chmod a+w .hg/cache/rbc-revs-v1
 recovery from invalid cache revs file with trailing data
   $ echo >> .hg/cache/rbc-revs-v1
   $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug