Skip to content

Getting php-git up to date #70

Open
@ghost

Description

I'd really like to get php-git updated and get a version bump - along with having a dev branch based on the latest libgit2 dev code.

To that end, what php-git needs the most right now are unit tests to ensure all the functionality it does provide is working.

While I added a unit test yesterday, it's a pretty crappy one and I will be submitting a replacement - before I start that I wanted to get feedback from other contributors/users of php-git.

For one thing, rather then writing our own tests, I'd like to use the model from libgit2
https://github.com/libgit2/libgit2/tree/v0.20.0/tests

The resources directory contains a large number of git repositories for testing. Rather then getting them from that folder, I want to copy that folder into our own - that way when changing libgit2 versions if the api has changed our copies will fail showing where the api needs to be changed.

Secondly, I want to create a php version of https://github.com/libgit2/libgit2/blob/v0.20.0/tests/clar.c. clar provides the basic functions to initialize tests. I was thinking of an abstract class with static functions like. Since php already has a unit testing process, we don't need most of the functionality of clar, just some little bits like cl_git_sandbox_init("testrepo") - for libgit2 this function will create a subdirectory in the folder where the test is running, copies the testrepo folder over from resources which is a predefined git repo, and copies the .gittree folder to .git in order to make it an active git repo.

So something like:
Clar::sandbox_init($reponame)
and
Clar::sandbox_cleanup($reponame)

Would be sufficient to create the repo and then clean up afterwards.

Thirdly, I'd rather use the libgit directory model where possible, so instead of https://github.com/libgit2/php-git/tree/develop/tests/tree

I should have placed that test under
tests/object/tree/read/
Where read.c is the libgit2 unit test file that I copied that test from.

I find this helpful in that instead of coming up with our own tests and hash id's, we can use the ones already written for libgit2

I'd also like to follow the guidelines for php:
https://qa.php.net/write-test.php
Under that standard instead of
git_tree_lookup.phpt
Which tests both the success and failure of looking up a directory, I should have written
git_tree_lookup_basic.phpt
git_tree_lookup_error.phpt

Which gives 2 tests to make it easier to determine what is wrong.

It would also be helpful if run-tests.php could be setup to post fail logs to one of the irc channels[either #libgit2 or #php-git) rather then sending e-mail to a PHP mailling list.

There are a LARGE number of tests so I don't expect them to be done right away, but if we all pitch in we can fill them in as we use php-git[ie if you are using the git_tree_lookup function and there is no unit test for it - spend 45 minutes and write a few based on the libgit2 tests. It will save you time since by doing so you can both verify that it works, and learn how it works!

Before setting up the framework, I wanted to check to see if anyone here has a different preferred way of doing things, since I'm more likely to get help if I use a framework others will enjoy, or at least tolerate.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions