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

Getting php-git up to date #70

Open
ghost opened this issue May 14, 2014 · 8 comments
Open

Getting php-git up to date #70

ghost opened this issue May 14, 2014 · 8 comments

Comments

@ghost
Copy link

ghost commented May 14, 2014

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.

@ghost
Copy link
Author

ghost commented May 14, 2014

Action items for the above are as follows:
1)Build Consensus on a framework
2)Create a framework to initialize and cleanup repositories for unit tests
3)Move all of 2 current unit tests into that framework
4)Determine if the run-tests.php file generated by phpize can be used to post problems to irc instead of e-mail to a PHP mail list
5) Determine appropriate notification address, libgit2 or php-git on irc? Something else?

I can do 2 and 3 once step 1 is done[where we are now]. If anyone knows about how to setup 4 it would save time.

@chobie
Copy link
Member

chobie commented May 14, 2014

2)Create a framework to initialize and cleanup repositories for unit tests
3)Move all of 2 current unit tests into that framework

agreed.

I'd like to respect Symfony coding standards for this framework. (not .phpt) It's trivial things but important.
http://symfony.com/doc/current/contributing/code/standards.html

4)Determine if the run-tests.php file generated by phpize can be used to post problems to irc instead of e-mail to a PHP mail list

https://gist.github.com/chobie/5f4728121543b8c2f475

Probably you can't send notification with run-tests.php as It made for php qa team. not generic tool. You should wrap test command if you want to send some notifications.

  1. Determine appropriate notification address, libgit2 or php-git on irc? Something else?

It should be php-git channel at freenode. Don't send any notifications to upstream channel.

@ghost
Copy link
Author

ghost commented May 14, 2014

"I'd like to respect Symfony coding standards for this framework. (not .phpt) It's trivial things but important.
http://symfony.com/doc/current/contributing/code/standards.html"

Symfony's standards don't really apply for extensions...

More accurately, the Clar class code design can certainly follow Symfony standards[which means it would need to be namespaced and all] and the php code inside the php file can also follow that design for formatting - though I don't think it should be namespaced or anything[since each script is executed independently on the command line, there isn't any real issue with conflicting function names]

But using the phpt standard, with one phpt test file per function makes it extremely easy to figure out where things break. Since it kept all the failed test info, I was able to easily check my new tree test directory on each run to find what the errors were.

I'd say that a good rule of thumb is:
If writing php code, follow the Symfony coding standard
If writing phpt code, follow Symfony coding standards on spacing, naming, etc for the php code inside the phpt file EXCEPT don't bother to namespace it. Or perhaps namespace it all as php-git/tests ? IE I don't want to have lots of deep nested namespaces like php-git/tests/object/tree/read But one overall namespace could keep it all clean.

Should the namespace be php-git/tests or libgit2/php-git/tests ?

@ghost
Copy link
Author

ghost commented May 14, 2014

Looks like run-tests.php is created by phpize. I've modified config.m4 to overwrite that when configure is executed here
#71

It will need some changes in order to point it someplace where the data can be reported. I'll check libgit2 to see how they are doing it currently.

@chobie
Copy link
Member

chobie commented May 14, 2014

ah sorry, less explanations. Will you port clar like testing library, right? I think it should have follow some coding standards. Sometimes people get confused when writing variable names. as PHP has several coding rules.

  • writing php code, follow Symfony coding standards on spacing, naming, etc for the php code inside the phpt file EXCEPT don't bother to namespace it.
  • writing c code, follow PECL coding standards.

I think we don't need namespace for Testing framework as it only use for internal test cases.
Git2 is better namespace if we choose the namespace. (we used Git2 namespace previous version)

@chobie
Copy link
Member

chobie commented May 14, 2014

Looks like run-tests.php is created by phpize. I've modified config.m4 to overwrite that when configure is executed here

woot, I don't know that option. it looks nice

@ghost
Copy link
Author

ghost commented May 14, 2014

checking the github api, it looks like issues can be created anonymously in public projects - and there is an irc service that can be enabled per repo to post notifications to a server/channel.

Later this week I'll look into modifying the custom run-tests.php and have it post failure reports to the php-git issue tracker[preferably with a tag or marker so they can be filtered out of "real" open issues]. With that setup, then you can update the repo settings to post notices to irc.

Or something completely different if some more of the people I e-mailed come by and build consensus on an alternate.

I just need 'something' in place because I have to build tests anyway for my own usage and I'd rather they get into the platform so it can be updated and I can be assured that future changes either won't break things I am doing, or if they do break things I'll at least know /why/.

@chobie
Copy link
Member

chobie commented May 15, 2014

Oops, I've missed this comment.
I've setup endpoint. Please check #71 ?

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

1 participant