Dear developers of Chamilo 2,

As some of you might have noticed some tests and a build script have appeared in the codebase of chamilo 2. The build script is based on phing and since all of you probably use a command prompt , installing phing is just a matter of opening a terminal and typing :

sudo pear channel-discover pear.phing.info

sudo pear install phing/phing


Once this is done you can benefit from the build script by calling some of its targets.

The first target you will probably have to call is :

sudo phing install-dependencies

Which will use the PEAR installer to install some code analysis tools on your machine. You can then call other targets to run those tools on the project :

phing phpunit

is probably the most important. This one runs the testsuite and tells you about the tests which fails. Everybody hates to pull broken code from the repository so please run this one before pushing and check that you haven't broken anything. Right now there are about 5600 tests (in order to check every class is loadable) and it takes about 5 minutes to run the 5600 tests. I know it's long but it's much shorter than the time needed to fix the bugs afterwards.


The other interestings targets are :

phing pdepend

runs a dependency analysis of the code (and produce an xml report), the dependency analysis gives us good indicators about the design of the code like the couplings of classes (which classes does one depends on), the package cycles (A depends on B which depends on C which depends on A), and the balance between abstractness and instability (the concrete classes should know the abstract classes not the opposite). Basically all those indicators wil help us to know how much the code is hard to change (http://www.artima.com/weblogs/viewpost.jsp?thread=210575).

phing phpcpd

runs a tools which tries to detect copy/paste code and generate an xml report. No need to explain why copy/paste is crap.


phing phpunit-coverage

runs the tests and produces 2 reports. The first one informs us about the failures and successes and the second one about code coverage (what part of the codebase is covered by tests).

Those 3 targets are huge time consumers. You can run them locally but be prepared to wait. The real good news is that those targets are actually run every 2 hours on a server which publies the results on a website (the url will probably change but I'll inform you) :

http://ec2-79-125-76-236.eu-west-1.compute.amazonaws.com:8080/job/Chamilo2/

On this website the most important graph is of course the tests results graph. (the build will be considered as failed as long as one test doesn't pass).

Trough this site you can easily access the Open Tasks (all the "TODO" and "FIXME" left in the code), the duplicate code (based on the result of phing phpcpd), the code coverage (based on the result of phing phpunit-coverage) and , when a build is successful, a code browser which lets you navigate the code and shows information based on different reports : code coverage, CRAP index, style violations, ...)

it's a lot of information but right know we should really focus on keeping the builds successful so please run "phing phpunit" before pushing your commits, I'll try to add more tests soon - feel free to add your own ;) .

If you want to improve the quality but do not know where to begin, I suggest you to have a look at the duplicated code or the open tasks.

I'm really convinced that we all like to produce good code and I hope this tool will make that goal easier.

Regards,

Systho.

PS : Sorry for my english, it is not my mother tongue.






_______________________________________________
Dev mailing list
Dev@lists.chamilo.org
http://lists.chamilo.org/listinfo/dev

Reply via email to