| 88 | # Helper rule. Create a test target, using basename of first source if no target |
| 89 | # name is explicitly passed. Remembers the created target in a global variable. |
| 90 | def make_test(target_type, sources, requirements, target_name=None): |
| 91 | |
| 92 | if not target_name: |
| 93 | target_name = stem(os.path.basename(sources[0])) |
| 94 | |
| 95 | # Having periods (".") in the target name is problematic because the typed |
| 96 | # generator will strip the suffix and use the bare name for the file |
| 97 | # targets. Even though the location-prefix averts problems most times it |
| 98 | # does not prevent ambiguity issues when referring to the test targets. For |
| 99 | # example when using the XML log output. So we rename the target to remove |
| 100 | # the periods, and provide an alias for users. |
| 101 | real_name = target_name.replace(".", "~") |
| 102 | |
| 103 | project = get_manager().projects().current() |
| 104 | # The <location-prefix> forces the build system for generate paths in the |
| 105 | # form '$build_dir/array1.test/gcc/debug'. This is necessary to allow |
| 106 | # post-processing tools to work. |
| 107 | t = get_manager().targets().create_typed_target( |
| 108 | type.type_from_rule_name(target_type), project, real_name, sources, |
| 109 | requirements + ["<location-prefix>" + real_name + ".test"], [], []) |
| 110 | |
| 111 | # The alias to the real target, per period replacement above. |
| 112 | if real_name != target_name: |
| 113 | get_manager().projects().project_rules().all_names_["alias"]( |
| 114 | target_name, [t]) |
| 115 | |
| 116 | # Remember the test (for --dump-tests). A good way would be to collect all |
| 117 | # given a project. This has some technical problems: e.g. we can not call |
| 118 | # this dump from a Jamfile since projects referred by 'build-project' are |
| 119 | # not available until the whole Jamfile has been loaded. |
| 120 | __all_tests.append(t) |
| 121 | return t |
| 122 | |
| 123 | |
| 124 | # Note: passing more that one cpp file here is known to fail. Passing a cpp file |