Re: [PATCH 5/5] t/t5520: test --[no-]autostash with pull.rebase=true

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

 



Hi Eric,

On Thu, Mar 31, 2016 at 2:01 AM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> One other possibility would be to make this all table-driven by
> collecting all of the above state information into a table and then
> feeding that into a function (either as its argument list or via
> stdin). For instance:
>
>     test_autostash <<\-EOF
>     ok,--rebase,rebase.autostash=true
>     ok,--rebase --autostash,rebase.autostash=true
>     ok,--rebase --autostash,rebase.autostash=false
>     ok,--rebase --autostash,rebase.autostash=
>     err,--rebase --no-autostash,rebase.autostash=true
>     err,--rebase --no-autostash,rebase.autostash=false
>     err,--rebase --no-autostash,rebase.autostash=
>     ok,--autostash,pull.rebase=true
>     err,--no-autostash,pull.rebase=true
>    EOF
>
> The function would loop over the input, split each line apart by
> setting IFS=, and then run the test based upon the state information.
> "ok" means autostash is expected to succeed, and err means it is
> expected to fail. The function would want to specially recognize the
> "foo.bar=" in the last argument in order to invoke test_unconfig()
> rather than test_config().

I tried out this method also. Below is the script that I wrote for this:

---

test_autostash () {
    OLDIFS=$IFS
    IFS=',    ='
    while read -r expect cmd config_variable value
    do
        test_expect_success "$cmd, $config_variable=$value" '
            if [ "$value" = "" ]; then
                test_unconfig $config_variable
            else
                test_config $config_variable $value
            fi &&

            git reset --hard before-rebase &&
            echo dirty >new_file &&
            git add new_file &&

            if [ $expect = "ok" ]; then
                git pull '$cmd' . copy &&
                echo test_cmp_rev HEAD^ copy &&
                test "$(cat new_file)" = dirty &&
                test "$(cat file)" = "modified again"
            else
                test_must_fail git pull '$cmd' . copy 2>err &&
                test_i18ngrep "uncommitted changes." err
            fi
        '
    done
    IFS=$OLDIFS
}


test_autostash <<-\EOF
    ok,--rebase,rebase.autostash=true
    ok,--rebase --autostash,rebase.autostash=true
    ok,--rebase --autostash,rebase.autostash=false
    ok,--rebase --autostash,rebase.autostash=
    err,--rebase --no-autostash,rebase.autostash=true
    err,--rebase --no-autostash,rebase.autostash=false
    err,--rebase --no-autostash,rebase.autostash=
    ok,--autostash,pull.rebase=true
    err,--no-autostash,pull.rebase=true
    EOF


---

Things worked out perfectly.

Unfortunately there was a strange behaviour that I noticed
and frankly I don't understand why it happened.

In test_autostash() there's a line

    echo test_cmp_rev HEAD^ copy &&

Originally it should have been

    test_cmp_rev HEAD^ copy &&

but this raise following error while testing

    ./t5520-pull.sh: 684: eval: diff -u: not found

I'm not able to understand why putting an "echo" before
test_cmp didn't raise the above error. This looks quite
strange. Any thoughts?

Though the above code works perfectly and can be used in
place of previous tests. Only problem remains is tests titles.
Currently with this script, test titles will be:

ok 21 - --rebase, rebase.autostash=true
ok 22 - --rebase --autostash, rebase.autostash=true
ok 23 - --rebase --autostash, rebase.autostash=false
ok 24 - --rebase --autostash, rebase.autostash=
ok 25 - --rebase --no-autostash, rebase.autostash=true
ok 26 - --rebase --no-autostash, rebase.autostash=false
ok 27 - --rebase --no-autostash, rebase.autostash=
ok 28 - --autostash, pull.rebase=true
ok 29 - --no-autostash, pull.rebase=true

Any thoughts/suggestions on them?

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



[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]