Torsten Bögershausen <tbo...@web.de> writes:

> It has been tested under Mac OS, root@Mac OS, Cygwin / Msysgit
> What do you think ?

Except that we may want to be more careful to detect errors from the
initial mkdir and clean-up part (which should abort the test, not
just declare !SANITY), I think the basic idea is sound.

        test_dir=$TRASH_DIRECTORY/.sanity-test-dir
        ! mkdir "$test_dir" &&
        >"$test_dir/x" &&
        chmod -w "$test_dir" ||
        error "bug in test sript: cannot prepare .sanity-test-dir"

        rm "$test_dir/x"
        status=$?

        chmod +w "$test_dir" &&
        rm -r "$test_dir" ||
        error "bug in test sript: cannot clean .sanity-test-dir"

        return $status

or something along that line?

>
> -- >8 --
> Subject: [PATCH 1/2] test-lib.sh: Improve SANITY
>
> SANITY was not set when running as root,
> but this is not 100% reliable for CYGWIN:
>
> A file is allowed to be deleted when the containing
> directory does not have write permissions.
>
> Signed-off-by: Torsten Bögershausen <tbo...@web.de>
> ---
>  t/test-lib.sh | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 93f7cad..b8f736f 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -1038,8 +1038,26 @@ test_lazy_prereq NOT_ROOT '
>  
>  # When the tests are run as root, permission tests will report that
>  # things are writable when they shouldn't be.
> +# Special check for CYGWIN (or Windows in general):
> +# A file can be deleted, even if the containing directory does'nt
> +# have write permissions
>  test_lazy_prereq SANITY '
> -     test_have_prereq POSIXPERM,NOT_ROOT
> +     dsdir=$$ds
> +     mkdir $dsdir &&
> +     touch $dsdir/x &&
> +     chmod -w $dsdir &&
> +     if rm $dsdir/x
> +     then
> +             chmod +w $dsdir
> +             rm -rf $dsdir
> +             echo >&2 SANITY=false
> +             false
> +     else
> +             chmod +w $dsdir
> +             rm -rf $dsdir
> +             echo >&2 SANITY=true
> +             true
> +     fi
>  '
>  
>  GIT_UNZIP=${GIT_UNZIP:-unzip}
--
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

Reply via email to