Re: [PATCH 1/8] t2501: add various tests for removing the current working directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 21, 2021 at 9:59 AM Ævar Arnfjörð Bjarmason
<avarab@xxxxxxxxx> wrote:
>
> On Sun, Nov 21 2021, Elijah Newren via GitGitGadget wrote:
>
> > From: Elijah Newren <newren@xxxxxxxxx>
>
> > +test_expect_failure 'checkout fails if cwd needs to be removed' '
> > +     git checkout foo/bar/baz &&
> > +     test_when_finished "git clean -fdx" &&
> > +
> > +     mkdir dirORfile &&
> > +     (
> > +             cd dirORfile &&
> > +
> > +             test_must_fail git checkout fd_conflict 2>../error &&
> > +             grep "Refusing to remove the current working directory" ../error
> > +     ) &&
> > +
> > +     test_path_is_dir dirORfile
>
>
> I'd find this & the rest of this series much easier to understand if we
> started out by positively asserting the current behavior here, and
> didn't test_cmp/grep for erro r messages that don't exist anymore.

Yeah, this is my fault for my bad commit message.  I stated I was
adding tests checking for the problems of interest, making it sound
like I was testing existing behavior, but I should have stated I was
adding tests with the behavior we'd prefer to have (i.e. basically a
test-driven-development) setup.

Also, there really wouldn't need to be so many tests for describing
the existing behavior.  It's basically just `git
$OPERATION_THAT_REMOVES_CWD_AS_SIDE_EFFECT` followed by nearly any
other git command will cause the second and later commands to fail
with:

```
shell-init: error retrieving current directory: getcwd: cannot access
parent directories: No such file or directory
fatal: Unable to read current working directory: No such file or directory
```

However, we do need a lot of tests for corrected behavior, because
there are so many different codepaths we can follow which will lead to
deletion of the current working directory.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux