Auto-tools/Ramping up/B2G

From MozillaWiki
Jump to: navigation, search
Ateam.png

B2G Tips

Welcome to the wiki page of the Mozilla Automation and Tools group. This page will provide useful tips to start B2G project. Feel free to edit it if you have information to share!

Overview

Want to know about B2G and Marionette? Here are some very useful information

B2G Marionette

Marionette

Marionette combines a gecko component (the Marionette server) with a Python component (the Marionette client), which drives the tests.

How to add new methods for Marionette

  • How to turn on virtual environment? -- In path "testing/marionette/client/marionette_venv", call `. bin/activate`
  • How to turn off virtual environment? -- Call `deactivate`
  • Made changes on Marionette client side? -- The Marionette client is a Python package with which you can run Marionette tests. After making changes to Marionette client, always call `python setup.py develop` to apply the changes on client side. Remember to do it when virtual environment is on.
  • Made changes on Marionette on the server side?
 -- With Firefox webpages, in obj-ff folder, call `make -C testing/marionette`  followed by `./dist/bin/firefox-bin -p`. To kill the build, call `kill `ps ux | grep firefox-bin | grep -v grep | awk '{ print $2 }'`
 -- With physical devices, call `./build.sh` followed by `(sudo) ./flash.sh` to reflect the changes. 
 -- With emulator, call `./build.sh` followed by `(sudo) ./run-emulator.sh`. 
  • Note 1: Whenever re-flashed/restarted, always call `adb forward tcp:2828 tcp:2828`
  • Note 2: Always update the whole repo since people make changes all the time! Run `./config.sh <environment that is built for>` (unagi or emulator)
  • Note 3: Once the changes are added to gecko, but the result is still not expected. It's probably because objdir-gecko/ hasn't been updated. In this case, delete objdir-gecko/ and out/ folder, then rebuild gecko.

How to add new tests for Marionette

  • Unit tests exist in /testing/marionette/client/marionette/tests/unit folder. If you want to add a new test, create a new python file. Details see other files in the folder. Remember to make corresponding changes in tests/unit-tests.ini file.
  • How to run tests?
 -- Run single test: python runtests.py --address=localhost:2828 tests/unit/<test name.py>
 -- Run whole test suite: python runtests.py --address=localhost:2828 --type=browser tests/unit-tests.ini 

Useful hg commands

  • hg add test-file-name.py: add new file into the system.
  • hq qdiff | view -: view all the changes in the patch
  • hg diff | view -: only view the last change
  • hg qrefresh: save the version you have
  • hg qpop: pop the latest version, i.e., in-apply the patch
  • hg qpush: push my version, i.e., re-apply the patch
  • hg qseries -v: check all the patches
  • hg export qtip >~/<name>.patch: form a patch
  • hg pull -u: fully updates the current hg repository
  • hg qnew <patch-name>: create a new patch in .hg/patches folder

More information: HG commands