Avocado development tips

Interrupting test

In case you want to “pause” the running test, you can use SIGTSTP (ctrl+z) signal sent to the main avocado process. This signal is forwarded to test and it’s children processes. To resume testing you repeat the same signal.

Note: that the job/test timeouts are still enabled on stopped processes.

In tree utils

You can find handy utils in avocado.utils.debug:


Decorator can be used to print current duration of the executed function and accumulated duration of this decorated function. It’s very handy when optimizing.


from avocado.utils import debug
def your_function(...):

During the execution look for:

PERF: <function your_function at 0x29b17d0>: (0.1s, 11.3s)
PERF: <function your_function at 0x29b17d0>: (0.2s, 11.5s)


You can measure line-by-line performance by using line_profiler. You can install it using pip:

pip install line_profiler

and then simply mark the desired function with @profile (no need to import it from anywhere). Then you execute:

kernprof -l -v ./scripts/avocado run ...

and when the process finishes you’ll see the profiling information. (sometimes the binary is called kernprof.py)

Remote debug with Eclipse

Eclipse is a nice debugging frontend which allows remote debugging. It’s very simple. The only thing you need is Eclipse with pydev plugin. The simplest way is to use pip install pydevd and then you set the breakpoint by:

import pydevd
pydevd.settrace(host="$IP_ADDR_OF_ECLIPSE_MACHINE", stdoutToServer=False, stderrToServer=False, port=5678, suspend=True, trace_only_current_thread=False, overwrite_prev_trace=False, patch_multiprocessing=False)

Before you run the code, you need to start the Eclipse’s debug server. Switch to Debug perspective (you might need to open it first Window->Perspective->Open Perspective). Then start the server from Pydev->Start Debug Server.

Now whenever the pydev.settrace() code is executed, it contacts Eclipse debug server (port 8000 by default, don’t forget to open it) and you can easily continue in execution. This works on every remote machine which has access to your Eclipse’s port 8000 (you can override it).

Using Trello cards in Eclipse

Eclipse allows us to create tasks. They are pretty cool as you see the status (not started, started, current, done) and by switching tasks it automatically resumes where you previously finished (opened files, …)

Avocado is planned using Trello, which is not yet supported by Eclipse. Anyway there is a way to at least get read-only list of your commits. This guide is based on https://docs.google.com/document/d/1jvmJcCStE6QkJ0z5ASddc3fNmJwhJPOFN7X9-GLyabM/ which didn’t work well with lables and descriptions. The only difference is you need to use Query Pattern:


Setup Trello key:

  1. Create a Trello account
  2. Get (developer_key) here: https://trello.com/1/appKey/generate
  3. Get user_token from following address (replace key with your key): https://trello.com/1/authorize?key=$developer_key&name=Mylyn%20Tasks&expiration=never&response_type=token
  4. Address with your assigned tasks (task_addr) is: https://trello.com/1/members/my/cards?key=developer_key&token=$user_token Open it in web browser and you should see [] or [$list_of_cards] without any passwords.

Configure Eclipse:

  1. We’re going to need Web Templates, which are not yet upstream. We need to use incubator version.
  2. Help->Install New Software…
  3. -> Add
  4. Name: Incubator
  5. Location: http://download.eclipse.org/mylyn/incubator/3.10
  6. -> OK
  7. Select Mylyn Tasks Connector: Web Templates (Advanced) (Incubation) (use filter text to find it)
  8. Install it (Next->Agree->Next…)
  9. Restart Eclipse
  10. Open the Mylyn Team Repositories Window->Show View->Other…->Mylyn->Team Repositories
  11. Right click the Team Repositories and select New->Repository
  12. Use Task Repository -> Next
  13. Use Web Template (Advanced) -> Next
  14. In the Properties for Task Repository dialog box, enter https://trello.com
  15. In the Server field and give the repository a label (eg. Trello API).
  16. In the Additional Settings section set applicationkey = $developer_key and userkey = $user_token.
  17. In the Advanced Configuration set the Task URL to https://trello.com/c/
  18. Set New Task URL to https://trello.com
  19. Set the Query Request URL (no changes required): https://trello.com/1/members/my/cards?key=${applicationkey}&token=${userkey}
  20. For the Query Pattern enter “url”:”https://trello.com/[^/]*/[^/]*/({Id}[^”]+)({Description})”
  21. -> Finish

Create task query:

  1. Create a query by opening the Mylyn Task List.
  2. Right click the pane and select New Query.
  3. Select Trello API as the repository.
  4. -> Next
  5. Enter the name of your query.
  6. Expand the Advanced Configuration and make sure the Query Pattern is filled in
  7. Press Preview to confirm that there are no errors.
  8. Press Finish.
  9. Trello tasks assigned to you will now appear in the Mylyn Task List.

Note you can start using tasks by clicking the small bubble in front of the name. This closes all editors. Try opening some and then click the bubble again. They should get closed. When you click the bubble third time, it should resume all the open editors from before.

My usual workflow is:

  1. git checkout $branch
  2. Eclipse: select task
  3. git commit …
  4. Eclipse: unselect task
  5. git checkout $other_branch
  6. Eclipse: select another_task

This way you always have all the files present and you can easily resume your work.