Skip to content

Testing and Running

Tal Liron edited this page Jun 6, 2017 · 9 revisions

Rōnin does not integrate specific testing frameworks, because there are just too many testing frameworks out there to choose from, and really no special support is need: what Rōnin provides instead is a generic mechanism for running tools, such as testing tools.

Let's start by explaining the mechanism, and then move on to see how it's used in testing.

Project Runs

Each project has a run dict that lets you add arbitrary commands in sequence. The key of the dict is an integer specifying the order. Runs are done only after and if the build as a whole succeeds, and additionally each run will be done only if the previous run succeeded.

A special --run CLI argument can be used to turn on a run flag. It is merely a convenience: you do not have to pay any attention to it and can have custom runs in any build. Here's an example of using it:

if ctx.build.run:
    project.run[1] = ['benchmark', 'arg1', 'arg2']
    project.run[2] = ['deploy', 'arg1', 'arg2']

You would run it like so:

./build.py --run

Phase Runs

Some sugar, run_output=, allows you to automatically add a run for the output of a phase:

Phase(project=project,
      name='build',
      executor=GccBuild(),
      inputs=glob('src/**/*.c'),
      output='example',
      run_output=1 if ctx.build.run else 0)

You can also customize the run command using run_command=. From the Java example:

Phase(project=project,
      name='jar',
      executor=Jar(manifest=input_path('MANIFEST.MF')),
      extensions=[JavaClasses(project, 'compile')],
      output='hello',
      run_output=1 if ctx.build.run else 0,
      run_command=[which('java'), '-jar', '{output}'])

Testing

A special --test CLI argument can be used to turn on a run flag. You can interpret it as you see fit, but it would often mean adding a special phase for building tests plus running a build tool.

You can support both --test and --run together, making sure that the tests run before the program run, so that it would be run only if the tests succeed. You would invoke them like so:

./build.py --test --run

For a complete example of integrating a testing framework (Check for C), see the testing example.

Clone this wiki locally