aboutsummaryrefslogtreecommitdiff
path: root/test/cxxtest/sample/Construct
blob: b8019616a9084453315342c064be5e5f0a3dc13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- Perl -*-

#
# This file shows how to use CxxTest with Cons
#

$env = new cons( CXX => ("$^O" eq 'MSWin32') ? 'cl -nologo -GX' : 'c++',
		 CPPPATH => '..',
	         CXXTESTGEN => 'perl -w ../cxxtestgen.pl' );

@tests = <*.h>;

# The error printer is the most basic runner
CxxTestErrorPrinter $env 'error_printer', @tests;

# You can also specify which runner you want to use
CxxTestRunner       $env 'stdio_printer', 'StdioPrinter', @tests;

# For more control, use template files
CxxTestTemplate     $env 'file_printer', 'file_printer.tpl', @tests;

# Or, you can always separate the tests from the runner
CxxTest             $env 'tests.cpp', '', @tests;
Program             $env 'yes_no_runner', ('yes_no_runner.cpp', 'tests.cpp');


#
# Here is the code used to build these files
# You can use this in your own Construct files
#

# cons::CxxTest $env $dst, $options, @srcs
# Generates a CxxTest source file, passing the specified options to cxxtestgen
sub cons::CxxTest($$$@) {
  my ($env, $dst, $options, @srcs) = @_;
  Command $env $dst, @srcs, "%CXXTESTGEN -o %> ${options} %<";
}

# cons::CxxTestTemplate $env $dst, $template, @srcs
# Generates and builds a CxxTest runner using a template file
sub cons::CxxTestTemplate($$$@) {
  my ($env, $dst, $template, @srcs) = @_;
  my $source = "${dst}.cpp";
  CxxTest $env $source, "--template=${template}", ($template, @srcs);
  Program $env $dst, $source;
}

# cons::CxxTestRunner $env $dst, $runner, @srcs
# Generates and builds a CxxTest runner using the --runner option
sub cons::CxxTestRunner($$$@) {
  my ($env, $dst, $runner, @srcs) = @_;
  my $source = "${dst}.cpp";
  CxxTest $env $source, "--runner=${runner}", @srcs;
  Program $env $dst, $source;
}

# cons::CxxTestErrorPrinter $env $dst, @srcs
# Generates and builds a CxxTest ErrorPrinter
sub cons::CxxTestErrorPrinter($$@) {
  my ($env, $dst, @srcs) = @_;
  CxxTestRunner $env $dst, 'ErrorPrinter', @srcs;
}