def make_test(target_type, sources, requirements, target_name=None): if not target_name: target_name = stem(os.path.basename(sources[0])) # Having periods (".") in the target name is problematic because the typed # generator will strip the suffix and use the bare name for the file # targets. Even though the location-prefix averts problems most times it # does not prevent ambiguity issues when referring to the test targets. For # example when using the XML log output. So we rename the target to remove # the periods, and provide an alias for users. real_name = target_name.replace(".", "~") project = get_manager().projects().current() # The <location-prefix> forces the build system for generate paths in the # form '$build_dir/array1.test/gcc/debug'. This is necessary to allow # post-processing tools to work. t = get_manager().targets().create_typed_target( type.type_from_rule_name(target_type), project, real_name, sources, requirements + ["<location-prefix>" + real_name + ".test"], [], []) # The alias to the real target, per period replacement above. if real_name != target_name: get_manager().projects().project_rules().all_names_["alias"]( target_name, [t]) # Remember the test (for --dump-tests). A good way would be to collect all # given a project. This has some technical problems: e.g. we can not call # this dump from a Jamfile since projects referred by 'build-project' are # not available until the whole Jamfile has been loaded. __all_tests.append(t) return t