Mxx_ru 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +26 -26
- data/NEWS +107 -107
- data/README +21 -21
- data/Rakefile +56 -59
- data/examples/exe_and_lib/prj.rb +11 -11
- data/examples/exe_and_lib/say.rb +7 -7
- data/examples/exe_dll_lib/inout.rb +18 -18
- data/examples/exe_dll_lib/prj.rb +11 -11
- data/examples/exe_dll_lib/say.rb +9 -9
- data/examples/exe_dll_lib_2/build.rb +10 -10
- data/examples/exe_dll_lib_2/inout/prj.rb +16 -16
- data/examples/exe_dll_lib_2/main/prj.rb +9 -9
- data/examples/exe_dll_lib_2/say/prj.rb +8 -8
- data/examples/simple_exe/prj.rb +7 -7
- data/lib/mxx_ru/abstract_target.rb +335 -335
- data/lib/mxx_ru/binary_library.rb +106 -106
- data/lib/mxx_ru/binary_target.rb +173 -173
- data/lib/mxx_ru/binary_unittest.rb +143 -143
- data/lib/mxx_ru/compat.rb +33 -33
- data/lib/mxx_ru/cpp.rb +38 -38
- data/lib/mxx_ru/cpp/analyzer.rb +237 -237
- data/lib/mxx_ru/cpp/composite.rb +118 -118
- data/lib/mxx_ru/cpp/detect_toolset.rb +122 -122
- data/lib/mxx_ru/cpp/mode.rb +90 -90
- data/lib/mxx_ru/cpp/obj_placement.rb +330 -330
- data/lib/mxx_ru/cpp/obj_placements/custom_subdir.rb +155 -155
- data/lib/mxx_ru/cpp/qt.rb +366 -366
- data/lib/mxx_ru/cpp/rucodegen.rb +157 -157
- data/lib/mxx_ru/cpp/source_file.rb +79 -79
- data/lib/mxx_ru/cpp/target.rb +1523 -1523
- data/lib/mxx_ru/cpp/toolset.rb +1087 -1087
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_5.rb +53 -53
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +460 -460
- data/lib/mxx_ru/cpp/toolsets/c89_etk_nsk.rb +59 -59
- data/lib/mxx_ru/cpp/toolsets/c89_nsk.rb +59 -59
- data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +277 -277
- data/lib/mxx_ru/cpp/toolsets/gcc_cygwin.rb +58 -58
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +420 -424
- data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +64 -64
- data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +150 -150
- data/lib/mxx_ru/cpp/toolsets/gcc_sparc_solaris.rb +91 -91
- data/lib/mxx_ru/cpp/toolsets/gcc_unix_family.rb +103 -84
- data/lib/mxx_ru/cpp/toolsets/vc7.rb +62 -62
- data/lib/mxx_ru/cpp/toolsets/vc8.rb +455 -455
- data/lib/mxx_ru/cpp/toolsets/vc_family.rb +448 -448
- data/lib/mxx_ru/ex.rb +165 -165
- data/lib/mxx_ru/makestyle_generator.rb +146 -146
- data/lib/mxx_ru/textfile_unittest.rb +303 -303
- data/lib/mxx_ru/util.rb +340 -340
- data/tests/c/pcre/chartables.c +183 -183
- data/tests/c/pcre/config.h +99 -99
- data/tests/c/pcre/dftables.c +167 -167
- data/tests/c/pcre/get.c +349 -349
- data/tests/c/pcre/internal.h +677 -677
- data/tests/c/pcre/maketables.c +140 -140
- data/tests/c/pcre/pcre.c +8304 -8304
- data/tests/c/pcre/pcre.h +193 -193
- data/tests/c/pcre/pcre.rb +14 -14
- data/tests/c/pcre/pcredemo.c +316 -316
- data/tests/c/pcre/pcregrep.c +642 -642
- data/tests/c/pcre/pcreposix.c +305 -305
- data/tests/c/pcre/pcreposix.h +88 -88
- data/tests/c/pcre/pcretest.c +1483 -1483
- data/tests/c/pcre/perltest +211 -211
- data/tests/c/pcre/printint.c +360 -360
- data/tests/c/pcre/study.c +472 -472
- data/tests/cpp/cpp_sources_glob/build.rb +7 -7
- data/tests/cpp/cpp_sources_glob/some/module/prj.rb +10 -10
- data/tests/cpp/cpp_sources_glob/tc_cpp_sources_glob.rb +18 -18
- data/tests/cpp/mswin_res_dll/build.rb +14 -14
- data/tests/cpp/mswin_res_dll/dll.cpp +17 -17
- data/tests/cpp/mswin_res_dll/dll.rb +29 -29
- data/tests/cpp/mswin_res_dll/dll.rc +48 -48
- data/tests/cpp/mswin_res_dll/h/dll.hpp +8 -8
- data/tests/cpp/mswin_res_dll/h/res.h +3 -3
- data/tests/cpp/mswin_res_dll/main.cpp +13 -13
- data/tests/cpp/mswin_res_dll/main.rb +19 -19
- data/tests/cpp/mswin_res_dll/tc_mswin_res_dll.rb +18 -18
- data/tests/cpp/mswin_res_exe/build.rb +23 -23
- data/tests/cpp/mswin_res_exe/h/res.h +3 -3
- data/tests/cpp/mswin_res_exe/main.cpp +17 -17
- data/tests/cpp/mswin_res_exe/main.rc +48 -48
- data/tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb +18 -18
- data/tests/cpp/rucodegen.embedded/host_config.cpp +32 -32
- data/tests/cpp/rucodegen.embedded/impl/conn_params.cpp +7 -7
- data/tests/cpp/rucodegen.embedded/impl/conn_params.rb +14 -14
- data/tests/cpp/rucodegen.embedded/impl/h/conn_params.hpp +10 -10
- data/tests/cpp/rucodegen.embedded/prj.rb +16 -16
- data/tests/cpp/rucodegen.embedded/tc_rucodegen.rb +18 -18
- data/tests/cpp/rucodegen/host_config.cpp +20 -20
- data/tests/cpp/rucodegen/host_config.rb +14 -14
- data/tests/cpp/rucodegen/impl/conn_params.cpp +7 -7
- data/tests/cpp/rucodegen/impl/conn_params.rb +14 -14
- data/tests/cpp/rucodegen/impl/h/conn_params.hpp +10 -10
- data/tests/cpp/rucodegen/prj.rb +16 -16
- data/tests/cpp/rucodegen/tc_rucodegen.rb +18 -18
- data/tests/cpp/textfile_unittest/build.rb +8 -8
- data/tests/cpp/textfile_unittest/etalons/out_1.txt +1 -1
- data/tests/cpp/textfile_unittest/etalons/out_128.txt +128 -128
- data/tests/cpp/textfile_unittest/main.cpp +89 -89
- data/tests/cpp/textfile_unittest/prj.rb +8 -8
- data/tests/cpp/textfile_unittest/prj.ut.rb +18 -18
- data/tests/cpp/textfile_unittest/tc_textfile_unittest.rb +18 -18
- data/tests/cpp/toolset_name.rb +6 -6
- data/tests/cpp/vc_cleanup/prj_dll_no_implib.rb +10 -10
- data/tests/cpp/vc_cleanup/prj_dll_no_implib_simple_target_root.rb +11 -11
- data/tests/cpp/vc_cleanup/prj_dll_with_implib.rb +11 -11
- data/tests/cpp/vc_cleanup/prj_dll_with_implib_simple_target_root.rb +14 -14
- data/tests/cpp/vc_cleanup/prj_exe_no_implib.rb +10 -10
- data/tests/cpp/vc_cleanup/prj_exe_no_implib_simple_target_root.rb +11 -11
- data/tests/cpp/vc_cleanup/prj_lib.rb +10 -10
- data/tests/cpp/vc_cleanup/prj_lib_with_simple_target_root.rb +11 -11
- data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +23 -23
- data/tests/mxx_ru/binary_library/tc_binary_library.rb +57 -57
- data/tests/mxx_ru/binary_library/tc_binary_target_lib_methods.rb +114 -114
- data/tests/mxx_ru/change_default_value/ignoring_by_build_root/build.rb +8 -8
- data/tests/mxx_ru/change_default_value/ignoring_by_build_root/child_1.rb +5 -5
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/build.rb +7 -7
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_1.rb +5 -5
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_2.rb +5 -5
- data/tests/mxx_ru/change_default_value/ok/build.rb +8 -8
- data/tests/mxx_ru/change_default_value/ok/child_1.rb +8 -8
- data/tests/mxx_ru/lib_path/build.rb +8 -8
- data/tests/mxx_ru/lib_path/bye.rb +8 -8
- data/tests/mxx_ru/lib_path/hi.rb +8 -8
- data/tests/mxx_ru/lib_path/main.rb +12 -12
- data/tests/mxx_ru/lib_path/tc_lib_path.rb +18 -18
- data/tests/mxx_ru/obj_placements/tc_custom_subdir.rb +58 -58
- data/tests/mxx_ru/opt_lib_ext/build.rb +7 -7
- data/tests/mxx_ru/opt_lib_ext/hi.rb +7 -7
- data/tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb +18 -18
- data/tests/mxx_ru/opt_lib_ext/test-no-ext.rb +9 -9
- data/tests/mxx_ru/opt_lib_ext/test-with-ext.rb +13 -13
- data/tests/mxx_ru/plural_form_methods/tc.rb +72 -72
- data/tests/mxx_ru/qt_gen/tc_uic_result_subdir.rb +76 -76
- data/tests/mxx_ru/target_ext/prj_dll.rb +8 -8
- data/tests/mxx_ru/target_ext/prj_exe.rb +8 -8
- data/tests/mxx_ru/target_ext/prj_lib.rb +8 -8
- data/tests/mxx_ru/target_ext/tc_target_ext.rb +24 -24
- data/tests/mxx_ru/tc_makestyle_generator.rb +117 -117
- data/tests/mxx_ru/vc8/tc_actual_manifest.rb +230 -230
- data/tests/mxx_ru/vc8/tc_append_mt_commands.rb +104 -104
- data/tests/mxx_ru/vc8/tc_default_manifest.rb +17 -17
- data/tests/mxx_ru/vc8/tc_define_manifest.rb +173 -173
- data/tests/mxx_ru/vc8/tc_drop_default_manifest.rb +16 -16
- data/tests/mxx_ru/vc8/tc_invalid_params.rb +81 -81
- data/tests/mxx_ru/vc8/ts_vc8.rb +10 -10
- data/tests/qt/aclock/aclock.cpp +148 -148
- data/tests/qt/aclock/aclock.h +45 -45
- data/tests/qt/aclock/main.cpp +28 -28
- data/tests/qt/aclock/prj.rb +21 -21
- data/tests/qt/iconview/main.cpp +76 -76
- data/tests/qt/iconview/prj.rb +21 -21
- data/tests/qt/toplevel/main.cpp +9 -9
- data/tests/qt/toplevel/options.ui +587 -587
- data/tests/qt/toplevel/prj.rb +22 -22
- data/tests/test_with_compilation.rb +110 -110
- data/tests/unix/lib_linking_mode/a_shared.rb +7 -7
- data/tests/unix/lib_linking_mode/a_static.rb +7 -7
- data/tests/unix/lib_linking_mode/etalon/shared.txt +2 -2
- data/tests/unix/lib_linking_mode/etalon/static.txt +2 -2
- data/tests/unix/lib_linking_mode/main_conflict.rb +12 -12
- data/tests/unix/lib_linking_mode/main_conflict_2.rb +11 -11
- data/tests/unix/lib_linking_mode/main_shared.rb +9 -9
- data/tests/unix/lib_linking_mode/main_shared.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/main_shared_2.rb +10 -10
- data/tests/unix/lib_linking_mode/main_shared_2.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/main_static.rb +9 -9
- data/tests/unix/lib_linking_mode/main_static.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/main_static_2.rb +10 -10
- data/tests/unix/lib_linking_mode/main_static_2.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/tc_conflicted_build.rb +18 -18
- data/tests/unix/lib_linking_mode/tc_normal_build.rb +18 -18
- data/tests/unix/lib_order/a.cpp +4 -0
- data/tests/unix/lib_order/a.hpp +1 -0
- data/tests/unix/lib_order/a.rb +8 -0
- data/tests/unix/lib_order/b.cpp +10 -0
- data/tests/unix/lib_order/b.hpp +1 -0
- data/tests/unix/lib_order/b.rb +8 -0
- data/tests/unix/lib_order/build.rb +9 -0
- data/tests/unix/lib_order/c.cpp +12 -0
- data/tests/unix/lib_order/c.hpp +2 -0
- data/tests/unix/lib_order/c.rb +8 -0
- data/tests/unix/lib_order/d.cpp +7 -0
- data/tests/unix/lib_order/d.hpp +1 -0
- data/tests/unix/lib_order/d.rb +8 -0
- data/tests/unix/lib_order/main.cpp +7 -0
- data/tests/unix/lib_order/main.rb +14 -0
- data/tests/unix/lib_order/tc_normal_build.rb +16 -0
- metadata +342 -319
@@ -1,303 +1,303 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
|
-
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
5
|
-
# All rights reserved.
|
6
|
-
#
|
7
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
8
|
-
# are permitted provided that the following conditions are met:
|
9
|
-
#
|
10
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer.
|
12
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
# 3. The name of the author may not be used to endorse or promote products derived
|
16
|
-
# from this software without specific prior written permission.
|
17
|
-
#
|
18
|
-
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
19
|
-
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
-
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
21
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
-
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
23
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
26
|
-
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
-
#++
|
28
|
-
|
29
|
-
require 'mxx_ru/ex'
|
30
|
-
require 'mxx_ru/abstract_target'
|
31
|
-
|
32
|
-
module MxxRu
|
33
|
-
|
34
|
-
# The class of a target, which is binary unit-test application, which create
|
35
|
-
# one or many text files.
|
36
|
-
#
|
37
|
-
# Given target performs a build of application, and then runs it and compares
|
38
|
-
# results with files which contains correct results.
|
39
|
-
#
|
40
|
-
# The basic idea consists in the presence of project file, which controls the
|
41
|
-
# build of unit-test application. In that project file, target object is
|
42
|
-
# created, inherited from MxxRu::BinaryTarget. To start unit-test it's
|
43
|
-
# necessary to create one more file, where target object of
|
44
|
-
# MxxRu::TextfileUnittestTarget class is created.
|
45
|
-
# For example:
|
46
|
-
#
|
47
|
-
# Unit-test application build file:
|
48
|
-
# MxxRu::setup_target(
|
49
|
-
# MxxRu::Cpp::ExeTarget.new( "test/pack/prj.rb" ) {
|
50
|
-
# ...
|
51
|
-
# }
|
52
|
-
# )
|
53
|
-
#
|
54
|
-
# File to run unit-test:
|
55
|
-
# MxxRu::setup_target(
|
56
|
-
# MxxRu::TextfileUnittestTarget.new(
|
57
|
-
# "test/pack/pack.ut.rb",
|
58
|
-
# "test/pack/prj.rb" ) {
|
59
|
-
#
|
60
|
-
# launch( "--loops 16 --out test/pack/out/16.txt",
|
61
|
-
# [ pair( "test/pack/out/16.txt",
|
62
|
-
# "test/pack/out/etalon/16.txt" ) ] )
|
63
|
-
#
|
64
|
-
# launch( "--loops 32 --out test/pack/out/32.txt",
|
65
|
-
# [ pair( "test/pack/out/32.txt",
|
66
|
-
# "test/pack/out/etalon/32.txt" ) ] )
|
67
|
-
# }
|
68
|
-
# )
|
69
|
-
#
|
70
|
-
# File which is using that unit-test.
|
71
|
-
# MxxRu::setup_target(
|
72
|
-
# MxxRu::Cpp::CompositeTarget.new( MxxRu::BUILD_ROOT ) {
|
73
|
-
# required_prj( "some/project/prj.rb" )
|
74
|
-
# required_prj( "test/pack/prj.ut.rb" )
|
75
|
-
# }
|
76
|
-
# )
|
77
|
-
#
|
78
|
-
class TextfileUnittestTarget < AbstractTarget
|
79
|
-
|
80
|
-
# Exception, thrown if one subordinated project generated more
|
81
|
-
# than one result name.
|
82
|
-
class MustBeOneTargetNameEx < Ex
|
83
|
-
# [_a_names_] Names generated.
|
84
|
-
def initialize( a_names )
|
85
|
-
super( "Only one name expected in [#{a_names.join(';')}]" )
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# For compatibility with previous versions.
|
90
|
-
Must_be_one_target_name_ex = MustBeOneTargetNameEx
|
91
|
-
|
92
|
-
# Exception, thrown if files are not equal.
|
93
|
-
class FileMismatchEx < BuildEx
|
94
|
-
# [_a_cmdline_] Command string of test application.
|
95
|
-
# [_a_produced_] Name of file generated.
|
96
|
-
# [_a_etalon_] Name of file containing correct results.
|
97
|
-
# [_a_line_num_] String number where first mismatch was detected.
|
98
|
-
# [_a_produced_line_] String of generated file. Nil if EOF is reached.
|
99
|
-
# [_a_etalon_line_] String of correct file. Nil if EOF is reached.
|
100
|
-
def initialize( a_cmdline,
|
101
|
-
a_produced, a_etalon,
|
102
|
-
a_line_num,
|
103
|
-
a_produced_line, a_etalon_line )
|
104
|
-
a_produced_line = "<EOF>" if !a_produced_line
|
105
|
-
a_etalon_line = "<EOF>" if !a_etalon_line
|
106
|
-
|
107
|
-
super( a_cmdline, "Mismatch found in line #{a_line_num}. " +
|
108
|
-
"Line in '#{a_produced}' is '#{a_produced_line}'. " +
|
109
|
-
"Line in '#{a_etalon}' is '#{a_etalon_line}'" )
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# For compatibility with previous versions.
|
114
|
-
File_mismatch_ex = FileMismatchEx
|
115
|
-
|
116
|
-
# Description of single pair of values compared.
|
117
|
-
class Pair
|
118
|
-
# Name of file generated.
|
119
|
-
attr_reader :produced
|
120
|
-
# Name of correct file.
|
121
|
-
attr_reader :etalon
|
122
|
-
|
123
|
-
# Constructor.
|
124
|
-
def initialize( a_produced, a_etalon )
|
125
|
-
@produced = a_produced
|
126
|
-
@etalon = a_etalon
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# A single run of test application description.
|
131
|
-
class Launch
|
132
|
-
# Command line parameters.
|
133
|
-
# Empty string if no parameters.
|
134
|
-
attr_reader :cmdline
|
135
|
-
# Files list to compare after application executed.
|
136
|
-
# Should be Array of Pair.
|
137
|
-
attr_reader :pairs
|
138
|
-
|
139
|
-
# Constructor.
|
140
|
-
def initialize( a_cmdline, a_pairs )
|
141
|
-
@cmdline = a_cmdline
|
142
|
-
@pairs = a_pairs
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# Target, responsible for build of unit-test application.
|
147
|
-
attr_reader :mxx_target_project
|
148
|
-
# True if build method was already executed.
|
149
|
-
attr_reader :mxx_build_state
|
150
|
-
# Description of test application runs.
|
151
|
-
# Array of Launch.
|
152
|
-
attr_reader :mxx_launches
|
153
|
-
|
154
|
-
# Constructor.
|
155
|
-
#
|
156
|
-
# [_a_alias_] Self alias.
|
157
|
-
# [_a_target_project_] Project, responsible for build of unit-test application.
|
158
|
-
def initialize( a_alias, a_target_project, &block )
|
159
|
-
super( a_alias )
|
160
|
-
|
161
|
-
@mxx_build_state = nil
|
162
|
-
|
163
|
-
@mxx_target_project = required_prj( a_target_project )
|
164
|
-
|
165
|
-
@mxx_launches = Array.new
|
166
|
-
|
167
|
-
instance_eval( &block ) if block
|
168
|
-
end
|
169
|
-
|
170
|
-
# Create description of file pairs to compare.
|
171
|
-
#
|
172
|
-
# [_a_produced_] Name of generated file.
|
173
|
-
# [_a_etalon_] Name of correct file.
|
174
|
-
def pair( a_produced, a_etalon )
|
175
|
-
return Pair.new( a_produced, a_etalon )
|
176
|
-
end
|
177
|
-
|
178
|
-
# Add description of sequental run of test application.
|
179
|
-
#
|
180
|
-
# [_a_cmdline_] Command line parameters. May be empty string of nil
|
181
|
-
# if no parameters required.
|
182
|
-
# [_a_pairs_] A list of pairs of file names to compare. Should be Array of
|
183
|
-
# values returned by pair() method.
|
184
|
-
#
|
185
|
-
# Comparation will be performed in order they are defined in _a_pairs_.
|
186
|
-
# Comparation is interrupted on first mismatch.
|
187
|
-
def launch( a_cmdline, a_pairs )
|
188
|
-
a_cmdline = "" if !a_cmdline
|
189
|
-
@mxx_launches << Launch.new( a_cmdline, a_pairs )
|
190
|
-
end
|
191
|
-
|
192
|
-
# Build subordinated project and run it.
|
193
|
-
#
|
194
|
-
# If unit-test application returns exit code not equal to 0, exception is
|
195
|
-
# thrown.
|
196
|
-
def build
|
197
|
-
if !@mxx_build_state
|
198
|
-
@mxx_target_project.build
|
199
|
-
|
200
|
-
# Determining the name of application, which should be run.
|
201
|
-
full_names = @mxx_target_project.mxx_full_targets_names
|
202
|
-
if 1 != full_names.size
|
203
|
-
raise MustBeOneTargetNameEx.new( full_names )
|
204
|
-
end
|
205
|
-
|
206
|
-
# No execution of commands in dry-run mode.
|
207
|
-
if !MxxRu::Util::Mode.instance.is_dry_run
|
208
|
-
puts "running unit test: #{full_names[0]}..."
|
209
|
-
do_all_launches( full_names[ 0 ] )
|
210
|
-
end
|
211
|
-
|
212
|
-
@mxx_build_state = TargetState.new( TargetState::REBUILT )
|
213
|
-
end
|
214
|
-
|
215
|
-
return @mxx_build_state
|
216
|
-
end
|
217
|
-
|
218
|
-
# Cleanup the project.
|
219
|
-
#
|
220
|
-
# Executes clean method from subordinated project.
|
221
|
-
# Deletes all files, defined as result files of unit-test application.
|
222
|
-
def clean
|
223
|
-
@mxx_target_project.clean
|
224
|
-
|
225
|
-
@mxx_launches.each { |launch|
|
226
|
-
launch.pairs.each { |pair|
|
227
|
-
Util.delete_file( pair.produced )
|
228
|
-
}
|
229
|
-
}
|
230
|
-
end
|
231
|
-
|
232
|
-
# Reset build status.
|
233
|
-
def reset
|
234
|
-
@mxx_target_project.reset
|
235
|
-
@mxx_build_state = nil
|
236
|
-
end
|
237
|
-
|
238
|
-
protected
|
239
|
-
# Perform all defined runs of test application.
|
240
|
-
# This method should not be executed in dry-run mode.
|
241
|
-
def do_all_launches( a_file_to_exec )
|
242
|
-
# On mswin32 platform if file name is in unix format and
|
243
|
-
# redirection of input/output is set, some problems with
|
244
|
-
# execution would occur.
|
245
|
-
native_file_name = Util::native_pathname( a_file_to_exec )
|
246
|
-
|
247
|
-
@mxx_launches.each { |launch|
|
248
|
-
cmdline = native_file_name + " " + launch.cmdline
|
249
|
-
puts "\tlaunching '#{cmdline}'..."
|
250
|
-
if !system( cmdline )
|
251
|
-
puts "\n\nunit test '#{cmdline}' FAILED! #{$?}"
|
252
|
-
raise BuildEx.new( cmdline, $? )
|
253
|
-
end
|
254
|
-
|
255
|
-
# Execution of application was successful.
|
256
|
-
# Let's compare files.
|
257
|
-
launch.pairs.each { |pair|
|
258
|
-
puts "\t\tcomparing '#{pair.produced}' and '#{pair.etalon}'"
|
259
|
-
do_file_compare( cmdline, pair.produced, pair.etalon )
|
260
|
-
}
|
261
|
-
}
|
262
|
-
end
|
263
|
-
|
264
|
-
# Perform comparation of two files.
|
265
|
-
# If they are not identical, FileMismatchEx exception is thrown.
|
266
|
-
# If some system exceptions would occur (absence of file for example),
|
267
|
-
# BuildEx ewxception will be thrown.
|
268
|
-
def do_file_compare( a_cmdline, a_produced, a_etalon )
|
269
|
-
begin
|
270
|
-
produced_file = File.new( a_produced, "r" )
|
271
|
-
etalon_file = File.new( a_etalon, "r" )
|
272
|
-
|
273
|
-
line_num = 1
|
274
|
-
while true
|
275
|
-
l1 = produced_file.gets
|
276
|
-
l1.chop! if l1
|
277
|
-
l2 = etalon_file.gets
|
278
|
-
l2.chop! if l2
|
279
|
-
|
280
|
-
if l1 != l2
|
281
|
-
raise FileMismatchEx.new( a_cmdline,
|
282
|
-
a_produced, a_etalon, line_num,
|
283
|
-
l1, l2 )
|
284
|
-
else
|
285
|
-
line_num += 1
|
286
|
-
if !l1
|
287
|
-
break
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
rescue Exception => ex
|
293
|
-
raise BuildEx.new( a_cmdline,
|
294
|
-
"Error during comparing files " +
|
295
|
-
"'#{a_produced}', '#{a_etalon}': #{ex}" )
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
# For compatibility with previous versions.
|
301
|
-
Textfile_unittest_target = TextfileUnittestTarget
|
302
|
-
|
303
|
-
end # module MxxRu
|
1
|
+
#--
|
2
|
+
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
|
+
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
+
# Copyright (c) 2006, The Mxx_ru Project
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
8
|
+
# are permitted provided that the following conditions are met:
|
9
|
+
#
|
10
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
# 3. The name of the author may not be used to endorse or promote products derived
|
16
|
+
# from this software without specific prior written permission.
|
17
|
+
#
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
19
|
+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
+
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
21
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
23
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
26
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
#++
|
28
|
+
|
29
|
+
require 'mxx_ru/ex'
|
30
|
+
require 'mxx_ru/abstract_target'
|
31
|
+
|
32
|
+
module MxxRu
|
33
|
+
|
34
|
+
# The class of a target, which is binary unit-test application, which create
|
35
|
+
# one or many text files.
|
36
|
+
#
|
37
|
+
# Given target performs a build of application, and then runs it and compares
|
38
|
+
# results with files which contains correct results.
|
39
|
+
#
|
40
|
+
# The basic idea consists in the presence of project file, which controls the
|
41
|
+
# build of unit-test application. In that project file, target object is
|
42
|
+
# created, inherited from MxxRu::BinaryTarget. To start unit-test it's
|
43
|
+
# necessary to create one more file, where target object of
|
44
|
+
# MxxRu::TextfileUnittestTarget class is created.
|
45
|
+
# For example:
|
46
|
+
#
|
47
|
+
# Unit-test application build file:
|
48
|
+
# MxxRu::setup_target(
|
49
|
+
# MxxRu::Cpp::ExeTarget.new( "test/pack/prj.rb" ) {
|
50
|
+
# ...
|
51
|
+
# }
|
52
|
+
# )
|
53
|
+
#
|
54
|
+
# File to run unit-test:
|
55
|
+
# MxxRu::setup_target(
|
56
|
+
# MxxRu::TextfileUnittestTarget.new(
|
57
|
+
# "test/pack/pack.ut.rb",
|
58
|
+
# "test/pack/prj.rb" ) {
|
59
|
+
#
|
60
|
+
# launch( "--loops 16 --out test/pack/out/16.txt",
|
61
|
+
# [ pair( "test/pack/out/16.txt",
|
62
|
+
# "test/pack/out/etalon/16.txt" ) ] )
|
63
|
+
#
|
64
|
+
# launch( "--loops 32 --out test/pack/out/32.txt",
|
65
|
+
# [ pair( "test/pack/out/32.txt",
|
66
|
+
# "test/pack/out/etalon/32.txt" ) ] )
|
67
|
+
# }
|
68
|
+
# )
|
69
|
+
#
|
70
|
+
# File which is using that unit-test.
|
71
|
+
# MxxRu::setup_target(
|
72
|
+
# MxxRu::Cpp::CompositeTarget.new( MxxRu::BUILD_ROOT ) {
|
73
|
+
# required_prj( "some/project/prj.rb" )
|
74
|
+
# required_prj( "test/pack/prj.ut.rb" )
|
75
|
+
# }
|
76
|
+
# )
|
77
|
+
#
|
78
|
+
class TextfileUnittestTarget < AbstractTarget
|
79
|
+
|
80
|
+
# Exception, thrown if one subordinated project generated more
|
81
|
+
# than one result name.
|
82
|
+
class MustBeOneTargetNameEx < Ex
|
83
|
+
# [_a_names_] Names generated.
|
84
|
+
def initialize( a_names )
|
85
|
+
super( "Only one name expected in [#{a_names.join(';')}]" )
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# For compatibility with previous versions.
|
90
|
+
Must_be_one_target_name_ex = MustBeOneTargetNameEx
|
91
|
+
|
92
|
+
# Exception, thrown if files are not equal.
|
93
|
+
class FileMismatchEx < BuildEx
|
94
|
+
# [_a_cmdline_] Command string of test application.
|
95
|
+
# [_a_produced_] Name of file generated.
|
96
|
+
# [_a_etalon_] Name of file containing correct results.
|
97
|
+
# [_a_line_num_] String number where first mismatch was detected.
|
98
|
+
# [_a_produced_line_] String of generated file. Nil if EOF is reached.
|
99
|
+
# [_a_etalon_line_] String of correct file. Nil if EOF is reached.
|
100
|
+
def initialize( a_cmdline,
|
101
|
+
a_produced, a_etalon,
|
102
|
+
a_line_num,
|
103
|
+
a_produced_line, a_etalon_line )
|
104
|
+
a_produced_line = "<EOF>" if !a_produced_line
|
105
|
+
a_etalon_line = "<EOF>" if !a_etalon_line
|
106
|
+
|
107
|
+
super( a_cmdline, "Mismatch found in line #{a_line_num}. " +
|
108
|
+
"Line in '#{a_produced}' is '#{a_produced_line}'. " +
|
109
|
+
"Line in '#{a_etalon}' is '#{a_etalon_line}'" )
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# For compatibility with previous versions.
|
114
|
+
File_mismatch_ex = FileMismatchEx
|
115
|
+
|
116
|
+
# Description of single pair of values compared.
|
117
|
+
class Pair
|
118
|
+
# Name of file generated.
|
119
|
+
attr_reader :produced
|
120
|
+
# Name of correct file.
|
121
|
+
attr_reader :etalon
|
122
|
+
|
123
|
+
# Constructor.
|
124
|
+
def initialize( a_produced, a_etalon )
|
125
|
+
@produced = a_produced
|
126
|
+
@etalon = a_etalon
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# A single run of test application description.
|
131
|
+
class Launch
|
132
|
+
# Command line parameters.
|
133
|
+
# Empty string if no parameters.
|
134
|
+
attr_reader :cmdline
|
135
|
+
# Files list to compare after application executed.
|
136
|
+
# Should be Array of Pair.
|
137
|
+
attr_reader :pairs
|
138
|
+
|
139
|
+
# Constructor.
|
140
|
+
def initialize( a_cmdline, a_pairs )
|
141
|
+
@cmdline = a_cmdline
|
142
|
+
@pairs = a_pairs
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Target, responsible for build of unit-test application.
|
147
|
+
attr_reader :mxx_target_project
|
148
|
+
# True if build method was already executed.
|
149
|
+
attr_reader :mxx_build_state
|
150
|
+
# Description of test application runs.
|
151
|
+
# Array of Launch.
|
152
|
+
attr_reader :mxx_launches
|
153
|
+
|
154
|
+
# Constructor.
|
155
|
+
#
|
156
|
+
# [_a_alias_] Self alias.
|
157
|
+
# [_a_target_project_] Project, responsible for build of unit-test application.
|
158
|
+
def initialize( a_alias, a_target_project, &block )
|
159
|
+
super( a_alias )
|
160
|
+
|
161
|
+
@mxx_build_state = nil
|
162
|
+
|
163
|
+
@mxx_target_project = required_prj( a_target_project )
|
164
|
+
|
165
|
+
@mxx_launches = Array.new
|
166
|
+
|
167
|
+
instance_eval( &block ) if block
|
168
|
+
end
|
169
|
+
|
170
|
+
# Create description of file pairs to compare.
|
171
|
+
#
|
172
|
+
# [_a_produced_] Name of generated file.
|
173
|
+
# [_a_etalon_] Name of correct file.
|
174
|
+
def pair( a_produced, a_etalon )
|
175
|
+
return Pair.new( a_produced, a_etalon )
|
176
|
+
end
|
177
|
+
|
178
|
+
# Add description of sequental run of test application.
|
179
|
+
#
|
180
|
+
# [_a_cmdline_] Command line parameters. May be empty string of nil
|
181
|
+
# if no parameters required.
|
182
|
+
# [_a_pairs_] A list of pairs of file names to compare. Should be Array of
|
183
|
+
# values returned by pair() method.
|
184
|
+
#
|
185
|
+
# Comparation will be performed in order they are defined in _a_pairs_.
|
186
|
+
# Comparation is interrupted on first mismatch.
|
187
|
+
def launch( a_cmdline, a_pairs )
|
188
|
+
a_cmdline = "" if !a_cmdline
|
189
|
+
@mxx_launches << Launch.new( a_cmdline, a_pairs )
|
190
|
+
end
|
191
|
+
|
192
|
+
# Build subordinated project and run it.
|
193
|
+
#
|
194
|
+
# If unit-test application returns exit code not equal to 0, exception is
|
195
|
+
# thrown.
|
196
|
+
def build
|
197
|
+
if !@mxx_build_state
|
198
|
+
@mxx_target_project.build
|
199
|
+
|
200
|
+
# Determining the name of application, which should be run.
|
201
|
+
full_names = @mxx_target_project.mxx_full_targets_names
|
202
|
+
if 1 != full_names.size
|
203
|
+
raise MustBeOneTargetNameEx.new( full_names )
|
204
|
+
end
|
205
|
+
|
206
|
+
# No execution of commands in dry-run mode.
|
207
|
+
if !MxxRu::Util::Mode.instance.is_dry_run
|
208
|
+
puts "running unit test: #{full_names[0]}..."
|
209
|
+
do_all_launches( full_names[ 0 ] )
|
210
|
+
end
|
211
|
+
|
212
|
+
@mxx_build_state = TargetState.new( TargetState::REBUILT )
|
213
|
+
end
|
214
|
+
|
215
|
+
return @mxx_build_state
|
216
|
+
end
|
217
|
+
|
218
|
+
# Cleanup the project.
|
219
|
+
#
|
220
|
+
# Executes clean method from subordinated project.
|
221
|
+
# Deletes all files, defined as result files of unit-test application.
|
222
|
+
def clean
|
223
|
+
@mxx_target_project.clean
|
224
|
+
|
225
|
+
@mxx_launches.each { |launch|
|
226
|
+
launch.pairs.each { |pair|
|
227
|
+
Util.delete_file( pair.produced )
|
228
|
+
}
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
# Reset build status.
|
233
|
+
def reset
|
234
|
+
@mxx_target_project.reset
|
235
|
+
@mxx_build_state = nil
|
236
|
+
end
|
237
|
+
|
238
|
+
protected
|
239
|
+
# Perform all defined runs of test application.
|
240
|
+
# This method should not be executed in dry-run mode.
|
241
|
+
def do_all_launches( a_file_to_exec )
|
242
|
+
# On mswin32 platform if file name is in unix format and
|
243
|
+
# redirection of input/output is set, some problems with
|
244
|
+
# execution would occur.
|
245
|
+
native_file_name = Util::native_pathname( a_file_to_exec )
|
246
|
+
|
247
|
+
@mxx_launches.each { |launch|
|
248
|
+
cmdline = native_file_name + " " + launch.cmdline
|
249
|
+
puts "\tlaunching '#{cmdline}'..."
|
250
|
+
if !system( cmdline )
|
251
|
+
puts "\n\nunit test '#{cmdline}' FAILED! #{$?}"
|
252
|
+
raise BuildEx.new( cmdline, $? )
|
253
|
+
end
|
254
|
+
|
255
|
+
# Execution of application was successful.
|
256
|
+
# Let's compare files.
|
257
|
+
launch.pairs.each { |pair|
|
258
|
+
puts "\t\tcomparing '#{pair.produced}' and '#{pair.etalon}'"
|
259
|
+
do_file_compare( cmdline, pair.produced, pair.etalon )
|
260
|
+
}
|
261
|
+
}
|
262
|
+
end
|
263
|
+
|
264
|
+
# Perform comparation of two files.
|
265
|
+
# If they are not identical, FileMismatchEx exception is thrown.
|
266
|
+
# If some system exceptions would occur (absence of file for example),
|
267
|
+
# BuildEx ewxception will be thrown.
|
268
|
+
def do_file_compare( a_cmdline, a_produced, a_etalon )
|
269
|
+
begin
|
270
|
+
produced_file = File.new( a_produced, "r" )
|
271
|
+
etalon_file = File.new( a_etalon, "r" )
|
272
|
+
|
273
|
+
line_num = 1
|
274
|
+
while true
|
275
|
+
l1 = produced_file.gets
|
276
|
+
l1.chop! if l1
|
277
|
+
l2 = etalon_file.gets
|
278
|
+
l2.chop! if l2
|
279
|
+
|
280
|
+
if l1 != l2
|
281
|
+
raise FileMismatchEx.new( a_cmdline,
|
282
|
+
a_produced, a_etalon, line_num,
|
283
|
+
l1, l2 )
|
284
|
+
else
|
285
|
+
line_num += 1
|
286
|
+
if !l1
|
287
|
+
break
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
rescue Exception => ex
|
293
|
+
raise BuildEx.new( a_cmdline,
|
294
|
+
"Error during comparing files " +
|
295
|
+
"'#{a_produced}', '#{a_etalon}': #{ex}" )
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
# For compatibility with previous versions.
|
301
|
+
Textfile_unittest_target = TextfileUnittestTarget
|
302
|
+
|
303
|
+
end # module MxxRu
|