Skip to content

Instantly share code, notes, and snippets.

@a-seskunas
Last active September 21, 2024 20:18
Show Gist options
  • Save a-seskunas/f0b624dd75a54bc7dee658123acc6b23 to your computer and use it in GitHub Desktop.
Save a-seskunas/f0b624dd75a54bc7dee658123acc6b23 to your computer and use it in GitHub Desktop.
Final Report


Final Report - GSoC More and Better Tests

Author - Adam Seskunas
Project - LibreOffice - The Document Foundation
Mentors - Hossein Nourikhah, Xisco Fauli

The goal of this project was to write more and better tests for the LibreOffice open source project. The first part of the project focused on porting tests from Java to C++. These Java tests are in some cases 20 years old, can be poorly documented and hard to debug when they fail. Porting these tests to C++ will ensure that they will continue to be run in the CI pipeline, preventing regressions from entering the code base.

The second part of the project consisted of writing tests from scratch, from the LibreOffice Missing Unit tests wiki. The Missing Unit tests wiki consists of links to fixed bugs on the ticketing system(bugzilla) used by LibreOffice. An example of one such bug report can be found here tdf#120629. The goal was to focus on writing tests for import/export bug fixes. Writing these tests will prevent these especially problematic bugs from being reintroduce to the code base.

Summary of work done

As mentioned above, the first part of the project involved porting some tests from Java over to C++. I started working on the test suite in framework/qa/complex/CheckXTile.java. This ended up being a fairly straightforward task as the test suite was self contained. The patch for this conversion can be found here.

Port framework/qa/complex/XTitle/CheckXTile.java to Cppunit

Next I moved on to a more challenging area, framework/qa/complex/checkdispatchapi.java. This test suite was originally written in 2006, had been lightly updated and contained lots of commented out code. I split the port into two patches both of which still need some work. After spending a considerable amount of time working on the ports, and getting blocked by several issues, my mentors suggested that I should move on to another area of code, and try to come back to these patches later.

framework/qa/complex/dispatches/checkdispatchapi.java to CppUnit
port currently enabled tests in checkdispatchapi.java

At the suggestion of my mentor Xisco, I started to work on porting some tests in dbaccess/qa/complex/dbaccess. As the folder name suggests, these are database connectivity tests, and as such rely on a test database. So before porting any tests, the test database setup and test suite had to be moved over from Java to C++. This involved setting up some makefiles and database connections in LibreOffice, tasks I had never done before. All went well, I learned a great deal and the patch was eventually merged here.

Port CRMDatabase to Cppunit

Now that the test database had been set up, it was time to port some actual tests over. Finding an appropriate test suit, I moved the suite over to C++ and the patch can be found here.

Port dbaccess complex/DataSource.java to extras/dataSource.cxx to Cppunit

After getting a database test suite merged, I moved on to the second part of the project and began to port some tests from the Missing Unit Tests Wiki. It was here that I ran into lots of issues due to my use of Fedora. After missing too much time dealing with building issues, my mentor Hossein suggested that I switch to using Ubuntu for as my OS. This was the correct decision and although switching operating systems in the middle of a project is not ideal, it helped immensely as all of the building issues I had previously experienced were resolved. And so I was able to write many tests, a list of all the relevant commits are shown below.

tdf#71749 Add Unit Tests
tdf#135709 - Add Unit Test
tdf#122452 - Add Unit Test
tdf#135710 - Add Unit test
tdf#56738 Add Unit test
tdf#128460 Add Unit Test
tdf#131288 Add Unit test
tdf#127048 Add Unit test
tdf#160301 - Add Unit test
tdf#89731 Add Unit test
tdf#120629 Add Unit test
tdf#61309 Add Unit test
tdf#54862 Add Unit test
tdf#61000 Add Unit test
Move testTdf160301 from ww8export to ww8import

I learned a great deal about the process of taking a bug report/bug fix, reverting the fix, testing for the bug and eventually writing a test for said bug. In fact, writing the test was often the easiest part of the process. At the suggestion of my mentor Hossein, I’ve written some documentation about this process. My hope is that this can be used by future contributors to the project to help write tests from the MissingUnitTest Wiki. Writing a test from the MissingUnitTest Wiki is a great way to get introduced to contributing to LibreOffice, and so I hope that this documentation can help increase the amount of people that contribute to the project. The documentation can be found here.

Writing a test from the MissingUnitTest Wiki

Future Works

Conclusion

I’m excited to have participated in Google Summer of Code and and I’m proud of everything that I have accomplished along the way. Looking back to the work I did at the beginning of the project, its clear to me that I’ve learned a lot, and I consider that a huge success. The tests that I have written for this project are a meaningful and lasting contribution to LibreOffice that will help keep many regressions out of the code base in the future.

I’d like to finish by thanking my mentors Hossein and Xisco. I couldn’t have accomplished all that I did without your help and guidance. Thanks for taking the time to meet with me every week, and having patience with me during code reviews. I’ve learned so much, I couldn’t have done it without you guys. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment