GSoC-2k16 Coding period - Week 2

Submitted by rakesh on Wed, 06/08/2016 - 23:18

Hey all. Last week, we created PHP Library for finding the Lowest Common ancestor from a Directed Acyclic Graph and the code for that library can be find over github. Before moving forward, Let me explain about my project:

We are working on a project to solve merge conflicts which may occur while merging content from two workspaces. In case two different users tries to modify and update the same file on server(Base), It'd get confused about which changes are to be kept; From user A or user B. In that case, user would be prompted to solve these conflicts manually. If there is no merge conflicts, the system would automatically look for the base file in the graph(LCA in our case) and compare both User A's changes and User B's changes with the base file and automatically update the new file according to the changes. More information about the project can be found on the GSoC's Project Page. Again, Don't forget to checkout the article which sums up my community bonding period for Google summer of code.

The first task as per the plan is to locate the base file which is the Lowest common ancestor in a graph. We created the PHP Library to find LCA in first week of coding period. Please refer to this article for more information about how we created the PHP Library

 This week's task was to write Tests for that library. To be honest, this was the first time when I was asked to write tests to justify if my code would be actually able to handle different cases. Even during my Internship(as a Drupal developer), I was never asked to write tests. I remember studying about writing tests while completing drupal ladder and community bonding period as well but everything I studied was somewhat different than what I had to implement in my test cases. I was really very nervous and confused about if I'd be able to complete this week's task. 

Again, This is the part where your mentors comes and play the most important role. My mentors Andrei Jechiu, Dick Olsson, Tim Millwood gave me really great guidance, blogs and some already written code to study how I can start with my task for the second week.  If you are looking for some guidance, I'd definitely recommend what I was suggested(For beginner level).

If you are new to Drupal or any other open source project, make sure you know and understand the problem really well before you start coding. Once you understand the problem and it's solution, it becomes very easy for you to code it. 

I started my task with the installation of PHPUnit Framework on my system. The next task was to write a PHPunit.xml.dist configuration file which allows you to run any number of test cases together. There are multiple options available for PHPunit configuration file to configure PHPUnit's core functionality. 

The final step of this task was to write the unit test for LowestCommonAncestor Class which we created last week. We created a basic graph and a test file with multiple tests for this graph. We checked for the Lowest common ancestor of multiple pair of nodes and we assured that the code we wrote for our LCA class was fine when it passed all test. We will continue writing tests with every code we write, my mentors says. I have uploaded my code over github and it can be seen in the LCA repository. However, it has not been merged into the main branch as there are a few things I need to take care of before it can be merged like removing unused references, following camel case naming conventions and a few more mistakes.We will continue adding multiple type of graphs and keep checking if our code fails any tests or not. 

We have created our test cases against a basic graph with 21 nodes. The graph we used is:

The graph we used

The test cases can be seen in the code we've written.

There are total 5 stages of my project:

  • Creating PHP Library to find LCA
  • Creating PHP Library to perform a 3 way merge algorithm.
  • Making these PHP Libraries to work with Drupal Modules.
  • Adding additional functionalities like automatic execution of algorithm we implemented in step 2.
  • A java script on-screen 3 pane code editor allowing users to compare and edit codes from local, base and remote files in case of conflict.

For the 3rd Week, we will be working on creating graphical representations of graphs we will be using for implementations and tests. I will be improving the already written code and tests so they could be merged as early as possible. Other this, we might start our work with phase2 i.e, Creating PHP library to perform a 3 way merge algorithm. 

That'd be it for now. Let me know if you have any questions, suggestions or feedback. Happy coding to all :D