Ok, today was my second day at Mozilla Messaging. Another good day. Here are some highlights:
Today, I started off my day by wanting to learn a few things:
- How to use pbranch to locally commit my Firefox patch from yesterday
- How to write tests for my patch using Mochitest
I started with the first one.
So, for the most part, Mozilla uses Mercurial as its distributed version control system. I’ve been using Git (arguably Mercurial’s main competitor) since last summer with both MarkUs and Review Board. Mercurial is something quite different. Quite different indeed.
pbranch is a tool that lets me have a patch queue. Basically, organization, and re-organization of any changes I make to the Mozilla code-base is a lot easier using something like pbranch.
So I spent a few minutes going through the pbranch tutorial. Eventually, I think I got the hang of it – basically, for my extension changes-sets, I create a new branch using hg pnew, and commit to that branch. I’ll keep committing to that, and when I’m all done, I’ll dump my patch to a Bugzilla attachment. After I pass code review, someone will merge my patch. Then I’ll remove my local branch and pull in my changes. Sweet!
Ok, so at this point, I think I got the workflow. Next, I needed to figure out how to write a Mochitest. Thankfully, there’s this tutorial.
Looking through the documentation, I was reminded of Selenium a little bit. I think it’s sort of the same idea.
So how do I write a test for my changes? Unfortunately, the documentation on how to write a Mochitest is a little thin. So I started hunting around, looking for examples to extrapolate from.
At some point, I found myself staring at this code. Wow! A full-blown API for manipulating the add-ons manager! Great! But it turns out that this is for Mozmill tests, and not Mochitests. But a quick search through MXR showed that nobody was using that add-on manager API. Argh.
Was I barking up the wrong tree here? Where the hell were the add-on manager tests?
I quickly swallowed my pride, and decided to talk to an expert. I used Mercurial’s log function to determine who had changed extensions.js the most. The name Dave Townsend came up. According to his site, he’s “Mossop” on IRC, but he wasn’t online. The log function also mentioned the name Blair McBride. On IRC, he’s “Unfocused”. He was online, but unavailable.
It was at this point that Blake told me that the Mozilla Messaging weekly meeting was going to take place. Apparently this happens every Tuesday at 9:30AM PST. So we marched over to a conference room, hooked up this super-advanced phone (the phone had a boot-up screen, and then showed the Mozilla logo…whoa!). A little while later, the meeting began. The meeting was super fast, and super efficient – especially considering the teams are spread out across the globe. One person led the meeting, and called the different teams up to give their weekly status. I also got to introduce myself to the team. I rambled off something about Thunderbird+Unity and code review, and then stumbled back to my chair. Cool times. Anyhow, teleconferencing is going to take some getting used to.
So, with the meeting over, and still no word from Unfocused, I decided to clean up my code a bit, and then posted my patch up on Bugzilla. I asked Dave Townsend for a code review, and said that if testing needs to happen, hopefully he’d let me know and advise me.
It didn’t take long for a response to come back. Apparently, there are indeed tests for the add-ons manager, and they’re right here in front of my face. Crap, I should have known. :/
So I dove into those tests…wow, there were a lot of them. And I didn’t have a clue as to how to run any of them.
Following the Mochitest instructions, I eventually tried this:
TEST_PATH=toolkit/mozapps/extensions/test/ make -C $OBJDIR mochitest-plain
(where the TEST_PATH is set to the folder of tests I want to run, and $OBJDIR is an environment variable that points to the objdir compilation folder for Firefox.)
But this only ran a single test out of the bunch, and there were hundreds in there. So what was the deal?
It turned out that the tests I wanted to run were with higher privileges than your average Mochitest test. A basic Mochitest test is run using mochitest-plain. Apparently, I needed to use mochitest-browser-chrome. Took me a good half-hour to figure that one out. :/
Anyhow, BAM, I had it – the tests were running. The bad news: I had a bunch of failing tests. The good news: the same tests failed without any of my changes. So…great…I guess.
It was at this point in the day that I was given access to the Mozilla Messaging Intranet (the internal wiki). There was plenty to read there, including something along the lines of “So you’re a new Mozilla Messaging hire”…I gave that a read. Very interesting.
Finally, I got back to testing. After digging through those add-ons manager tests, I finally found this: PAYDIRT.
But then it was home time. More tomorrow.