Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 t1205-push-subdir.sh test failures #367

Open
vt-alt opened this issue Sep 4, 2023 · 7 comments
Open

2 t1205-push-subdir.sh test failures #367

vt-alt opened this issue Sep 4, 2023 · 7 comments

Comments

@vt-alt
Copy link

vt-alt commented Sep 4, 2023

2 test failures on 2.3.2:

builder@x86_64:~/RPM/BUILD/stgit-2.3.2$ make test V=1 VERBOSE=1
...
*** t1205-push-subdir.sh ***
ok 1 - Create some patches
ok 2 - Fast-forward push from a subdir
ok 3 - Modifying push from a subdir
ok 4 - Conflicting push from subdir
ok 5 - Conflicting add/unknown file in subdir
not ok 6 - Push removes current subdir
#
#          mkdir remdir &&
#          touch remdir/x.txt &&
#          stg add remdir/x.txt &&
#          stg new -m add-remdir &&
#          stg refresh &&
#          stg rm remdir/x.txt &&
#          stg new -m rm-remdir &&
#          stg refresh &&
#          stg pop &&
#          (
#              cd remdir &&
#              stg push rm-remdir
#          )
#
not ok 7 - Pop removes current subdir
#
#           stg goto add-remdir &&
#           (
#               cd remdir &&
#               stg pop add-remdir
#           )
#
# failed 2 among 7 test(s)
1..7
make[2]: *** [Makefile:66: t1205-push-subdir.sh] Error 1
@vt-alt
Copy link
Author

vt-alt commented Sep 4, 2023

Test run with actually verbose output:

builder@x86_64:~/RPM/BUILD/stgit-2.3.2/t$ make all STG_TEST_OPTS=-v STG_PROFILE=release
...
*** t1205-push-subdir.sh ***
Initialized empty Git repository in /usr/src/RPM/BUILD/stgit-2.3.2/t/trash directory.t1205-push-subdir/.git/
[master (root-commit) a03420f] empty start
 Author: A Ú Thor <author@example.com>
expecting success of 1205.1 'Create some patches':
    mkdir foo &&
    for i in 0 1 2; do
        stg new p$i -m p$i &&
        echo x$i >>x.txt &&
        echo y$i >>foo/y.txt &&
        stg add x.txt foo/y.txt &&
        stg refresh || return 1
    done &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]

> p0 (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& p0
> p0
> p1 (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& p1
> p1
> p2 (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& p2
> p2
ok 1 - Create some patches

expecting success of 1205.2 'Fast-forward push from a subdir':
    stg pop &&
    [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
    [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
    cd foo &&
    stg push &&
    cd .. &&
    [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
    [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]

- p2
> p1
> p2
ok 2 - Fast-forward push from a subdir

expecting success of 1205.3 'Modifying push from a subdir':
    stg pop &&
    [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
    [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
    stg new extra -m extra &&
    echo extra >>extra.txt &&
    stg add extra.txt &&
    stg refresh &&
    cd foo &&
    stg push &&
    cd .. &&
    [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
    [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]

- p2
> p1
> extra (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& extra
> extra
> p2
ok 3 - Modifying push from a subdir

expecting success of 1205.4 'Conflicting push from subdir':
    stg pop p1 p2 &&
    [ "$(echo $(cat x.txt))" = "x0" ] &&
    [ "$(echo $(cat foo/y.txt))" = "y0" ] &&
    cd foo &&
    conflict stg push p2 &&
    cd .. &&
    [ "$(echo $(stg status))" = "UU foo/y.txt UU x.txt" ]

- p1..p2
> extra
> p2 (conflict)
error: merge conflicts; resolve conflicts manually then refresh or undo the operation with `stg undo --hard`.
UU y.txt
UU ../x.txt
ok 4 - Conflicting push from subdir

expecting success of 1205.5 'Conflicting add/unknown file in subdir':
    stg reset --hard &&
    stg new foo -m foo &&
    mkdir d &&
    echo foo >d/test &&
    stg add d/test &&
    stg refresh &&
    stg pop &&
    mkdir -p d &&
    echo bar >d/test &&
    command_error stg push foo &&
    [ "$(stg top)" != "foo" ]

> foo (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& foo
> foo
- foo
> p2
> foo
@ p2 (rolled back)
error: `git read-tree -m -u`: error: Untracked working tree file 'd/test' would be overwritten by merge.;
command aborted (all changes rolled back)
ok 5 - Conflicting add/unknown file in subdir

expecting success of 1205.6 'Push removes current subdir':
   mkdir remdir &&
   touch remdir/x.txt &&
   stg add remdir/x.txt &&
   stg new -m add-remdir &&
   stg refresh &&
   stg rm remdir/x.txt &&
   stg new -m rm-remdir &&
   stg refresh &&
   stg pop &&
   (
       cd remdir &&
       stg push rm-remdir
   )

> add-remdir (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& add-remdir
> add-remdir
rm 'remdir/x.txt'
> rm-remdir (new)
> refresh-temp (new)
- refresh-temp
# refresh-temp
& rm-remdir
> rm-remdir
- rm-remdir
> add-remdir
> rm-remdir
error: `git update-index`: fatal: Unable to read current working directory: No such file or directory
not ok 6 - Push removes current subdir
#
#          mkdir remdir &&
#          touch remdir/x.txt &&
#          stg add remdir/x.txt &&
#          stg new -m add-remdir &&
#          stg refresh &&
#          stg rm remdir/x.txt &&
#          stg new -m rm-remdir &&
#          stg refresh &&
#          stg pop &&
#          (
#              cd remdir &&
#              stg push rm-remdir
#          )
#

expecting success of 1205.7 'Pop removes current subdir':
    stg goto add-remdir &&
    (
        cd remdir &&
        stg pop add-remdir
    )

error: index not clean; use `refresh` or `reset --hard`
not ok 7 - Pop removes current subdir
#
#           stg goto add-remdir &&
#           (
#               cd remdir &&
#               stg pop add-remdir
#           )
#

# failed 2 among 7 test(s)
1..7
make[1]: *** [Makefile:66: t1205-push-subdir.sh] Error 1

@jpgrayson
Copy link
Collaborator

I am unable to reproduce the problem with either the v2.3.2 tag or HEAD using the statically linked stg binary used in the RPM package (or with any other stg binary).

The failing test case ("6 - Push removes current subdir") is a little weird in that it cd's to a directory that will be removed by a patch and then applies (pushes) that patch, thereby taking out the current directory.

This test case is likely sensitive to both the version of git and perhaps the underlying filesystem. For reference, I just tried this using git 2.42.0 on an ext4 filesystem.

Any more detail you can provide about the environment where this test failed would be appreciated.

@vt-alt
Copy link
Author

vt-alt commented Sep 4, 2023

Our package build system builds everything on tmpfs. But I just tried to run the tests on ext4 and failures are the same. Git version:

builder@x86_64:~/RPM/BUILD/stgit-2.3.2$ git --version
git version 2.33.8

I tried to reproduce in Docker:

$ docker run --rm -it alt:sisyphus
[root@dad8373847e0 /]# apt-get update; apt-get install -y rpm-build rust-cargo git openssl-devel xmlto
[root@dad8373847e0 /]# git clone https://github.com/stacked-git/stgit
[root@dad8373847e0 stgit]# cd stgit
[root@dad8373847e0 stgit]# cargo build
[root@dad8373847e0 stgit]# make -C t
# failed 2 among 7 test(s)

@jpgrayson
Copy link
Collaborator

I was able to reproduce the behavior using the container method.

The problem does have to do with the version of git. This test works with git v2.35.0 and newer. The relevant release note from v2.35.0:

  • Many git commands that deal with working tree files try to remove a
    directory that becomes empty (i.e. "git switch" from a branch that
    has the directory to another branch that does not would attempt
    remove all files in the directory and the directory itself). This
    drops users into an unfamiliar situation if the command was run in
    a subdirectory that becomes subject to removal due to the command.
    The commands have been taught to keep an empty directory if it is
    the directory they were started in to avoid surprising users.

I suspect it would be possible to add a safety rail to StGit to account for this case where a push eliminates the current directory. But I'm not seeing this as a critical issue since it is resolved by using a somewhat more recent version of git.

That said, it looks like the context here is that you're working on packaging StGit for ALT Linux. I want to support downstream packagers of StGit, so let me know how I can best do that in this case.

@vt-alt
Copy link
Author

vt-alt commented Sep 4, 2023

Maybe you can skip the test if git is not enough version? Since I make package for ALT Linux -version of git isn't my choice, but I wish to run some tests. If I just rm t1205-push-subdir.sh there are other test failures.

@jpgrayson
Copy link
Collaborator

I have dug deeper into the exact failure path through StGit. The problem stems from the gix::Repository no longer being able to find the repository root (i.e. the .git dir) after the push removes cwd.

This problem can be mitigated by changing the original search for the repository from using "." to using the absolute current dir. With this change, t1205-push-subdir.sh succeeds.

The next issue I see is that t7000-sparse-checkout.sh fails with git<v2.37.0. This one seems to be related to changes to the semantics of git sparse-checkout. For both of these tests that fail with older versions of git, perhaps the best path might be as you suggest: disable the offending test cases when an old version of git is detected. I need to think about this more.

@vt-alt
Copy link
Author

vt-alt commented Sep 5, 2023

For the time being I will just rm these two tests for ALT. But it's definitely better to make tests skip, as maintainers of other distributions may not be very patient to debug test issues and if make test fails with obscure error the may just not run them at all.

For example you could make it like shell tests in nbdkit: https://github.com/libguestfs/nbdkit/tree/master/tests

They have (common for many tests harnesses) exit code 77 meaning test skipped. And function requires_libnbd_version in functions.sh.in which compares version and exits 77 if version does not match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants