-
Notifications
You must be signed in to change notification settings - Fork 15
Common Test Task
The ct task is a method of running the Common Test Framework on a the project. You should be familiar with the common test framework to use this task.
This task allows you to setup 'configurations' and run those configurations individually. It also allows specify a given configuration and echo a command line that will allow you to run that configuration directly with the ct_run application. This is useful when you want to do do things like step through a debugger or add additional options that are not available in the options sinan exposes.
To run ct
you must have setup some named ct
entry (more about that follows)
in the sinan.config
and call Sinan with that ct entry.
$> sinan ct -t my_entry
To get the command line for running common test echoed you should do the following:
$> sinan ct -t my_entry --echo
In this case Sinan does not do any configuration for you outside of setting up the proper code paths. Sinan does however give you several variables that you can use in your options (at least those options that contain directory specifications).
These exist to help you configure your tests. It is suggested that you put all output under the 'build_dir' and no in your project itself. Otherwise sinan clean will be unable to clean the project correctly. However, this is completely up to you.
These are the variables available in your configuration options.
Project Dir
This is the project directory. This should be the same as CWD, since Sinan sets the projec directory to be the current directory.
$project_dir$
Build Root
The build root points to the top level of the build directory. This usually
points $project_dir$/_build
. You shouldn't put too much at this level directory,
because you can have multiple releases that may step on each other.
$build_root$
Build Dir
Build dir points to the build output directory, that is the release directory where all build output ends up.
$build_dir$
Release Name
This is simply the name of the currently active release.
$release_name$
Release Version
This is the currently set version of the release.
$release_vsn$
Apps Dir
This points to the 'lib' dir of the release directory. This is equivalent to
$apps_dir$/lib
.
$apps_dir$
Release Dir
This points to the directory containing the release metadata. It is equivalent
to $build_dir$/releases/$release_vsn$
$release_dir$
Home Dir
This is simply the user's home directory.
$home_dir$
Application Directory
Lets say we had an application called foo. The variable $foo_dir$
would point
to the root directory of that application. So in this model the ebin directory
of foo would look like '$foo_dir$/ebin'.
$<app_name>_dir$
Application Version
The is similar to $<app_name>_dir$
except contains the version of the
application instead of its dir. So for our foo example if we wanted the version
of foo we would do $foo_vsn$
.
Sinan give you the ability to have multiple common test configurations. The configurations are are specified as follows.
{ct_config, [{config_name(), terms()}]}.
Lets say we had a configuration call alternate in our bar release. We might configure it as follows.
{ct_config, [{alternate, [{dir, \"$foo_dir$/test\"}]}]}.
To run that configuration you would simple call this from the command line
$> sinan ct -t alternate
You could also have specified more then one configuration.
{ct_config, [{alternate, [{dir, \"$foo_dir$/test\"}]}
{main, [{dir, \"$foo_dir$/test\"}]}.
then you could do one of the following.
$> sinan ct -t alternate
or
$> sinan ct -t main
If you don't want to specify the -t all the time you may, at your option, specify a config option to give the default test to run. You may do that with the following directive.
{ct_default, TestName::atom()}.
So if we wanted the main spec to be the default we would do:
{ct_default, main}.
and then run the test as
$> sinan ct
This would then run the common test task with the main
test spec. NOTE you
must have either a default specified or a name specified in the -t option.
These are exactly the same options taken by ct:run/1. Look there for the common test documentation.
{dir, TestDirs} % Variables Supported
{suite, Suites}
{group, Groups}
{testcase, Cases}
{spec, TestSpecs}
{label, Label}
{config, CfgFiles} % Variables Supported
{userconfig, UserConfig} % Variables Supported
{allow_user_terms, Bool}
{logdir, LogDir} % Variables Supported
{silent_connections, Conns}
{stylesheet, CSSFile} % Variables Supported
{cover, CoverSpecFile} % Variables Supported
{step, StepOpts}
{event_handler, EventHandlers}
{include, InclDirs} % Variables Supported
{auto_compile, Bool}
{create_priv_dir, CreatePrivDir}
{multiply_timetraps, M}
{scale_timetraps, Bool}
{repeat, N}
{duration, DurTime}
{until, StopTime}
{force_stop, Bool}
{decrypt, DecryptKeyOrFile} % Variables Supported
{refresh_logs, LogDir} % Variables Supported
{logopts, LogOpts}
{basic_html, Bool}
{ct_hooks, CTHs}
{enable_builtin_hooks, Bool}