| 1 |
# -*- Perl -*- |
| 2 |
|
| 3 |
# |
| 4 |
# This file shows how to use CxxTest with Cons |
| 5 |
# |
| 6 |
|
| 7 |
$env = new cons( CXX => ("$^O" eq 'MSWin32') ? 'cl -nologo -GX' : 'c++', |
| 8 |
CPPPATH => '..', |
| 9 |
CXXTESTGEN => '../bin/cxxtestgen' ); |
| 10 |
|
| 11 |
@tests = <*.h>; |
| 12 |
|
| 13 |
# The error printer is the most basic runner |
| 14 |
CxxTestErrorPrinter $env 'error_printer', @tests; |
| 15 |
|
| 16 |
# You can also specify which runner you want to use |
| 17 |
CxxTestRunner $env 'stdio_printer', 'StdioPrinter', @tests; |
| 18 |
|
| 19 |
# For more control, use template files |
| 20 |
CxxTestTemplate $env 'file_printer', 'file_printer.tpl', @tests; |
| 21 |
|
| 22 |
# Or, you can always separate the tests from the runner |
| 23 |
CxxTest $env 'tests.cpp', '', @tests; |
| 24 |
Program $env 'yes_no_runner', ('yes_no_runner.cpp', 'tests.cpp'); |
| 25 |
|
| 26 |
|
| 27 |
# |
| 28 |
# Here is the code used to build these files |
| 29 |
# You can use this in your own Construct files |
| 30 |
# |
| 31 |
|
| 32 |
# cons::CxxTest $env $dst, $options, @srcs |
| 33 |
# Generates a CxxTest source file, passing the specified options to cxxtestgen |
| 34 |
sub cons::CxxTest($$$@) { |
| 35 |
my ($env, $dst, $options, @srcs) = @_; |
| 36 |
Command $env $dst, @srcs, "%CXXTESTGEN -o %> ${options} %<"; |
| 37 |
} |
| 38 |
|
| 39 |
# cons::CxxTestTemplate $env $dst, $template, @srcs |
| 40 |
# Generates and builds a CxxTest runner using a template file |
| 41 |
sub cons::CxxTestTemplate($$$@) { |
| 42 |
my ($env, $dst, $template, @srcs) = @_; |
| 43 |
my $source = "${dst}.cpp"; |
| 44 |
CxxTest $env $source, "--template=${template}", ($template, @srcs); |
| 45 |
Program $env $dst, $source; |
| 46 |
} |
| 47 |
|
| 48 |
# cons::CxxTestRunner $env $dst, $runner, @srcs |
| 49 |
# Generates and builds a CxxTest runner using the --runner option |
| 50 |
sub cons::CxxTestRunner($$$@) { |
| 51 |
my ($env, $dst, $runner, @srcs) = @_; |
| 52 |
my $source = "${dst}.cpp"; |
| 53 |
CxxTest $env $source, "--runner=${runner}", @srcs; |
| 54 |
Program $env $dst, $source; |
| 55 |
} |
| 56 |
|
| 57 |
# cons::CxxTestErrorPrinter $env $dst, @srcs |
| 58 |
# Generates and builds a CxxTest ErrorPrinter |
| 59 |
sub cons::CxxTestErrorPrinter($$@) { |
| 60 |
my ($env, $dst, @srcs) = @_; |
| 61 |
CxxTestRunner $env $dst, 'ErrorPrinter', @srcs; |
| 62 |
} |
| 63 |
|
| 64 |
|