def test_yaml(self): """nesting/nesting.yaml""" codebase, configuration = config.load("./tests/nesting/nesting.yaml", self.rootdir) state = finder.find(self.rootdir, codebase, configuration) mapper = PlatformMapper(codebase) setmap = mapper.walk(state) self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap")
def test_db(self): """include/include-db.yaml""" codebase, configuration = config.load( "./tests/include/include-db.yaml", self.rootdir) state = finder.find(self.rootdir, codebase, configuration) mapper = walkers.PlatformMapper(codebase) setmap = mapper.walk(state) self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap")
def test_yaml(self): """commented_directive/commented_directive.yaml""" codebase, configuration = config.load( "./tests/commented_directive/commented_directive.yaml", self.rootdir) state = finder.find(self.rootdir, codebase, configuration) mapper = PlatformMapper(codebase) setmap = mapper.walk(state) node_count = 1 for fn in state.get_filenames(): node_count += self.count_children_nodes(state.get_tree(fn).root) self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap") self.assertEqual(node_count, 6, "Incorrect number of nodes in tree: {}".format(node_count))
stdout_log.setFormatter(logging.Formatter('[%(levelname)-8s] %(message)s')) logging.getLogger("codebasin").addHandler(stdout_log) logging.getLogger("codebasin").setLevel( max(1, logging.WARNING - 10 * (args.verbose - args.quiet))) rootdir = os.path.realpath(args.rootdir) # Load the configuration file into a dict if not util.ensure_yaml(args.config_file): logging.getLogger("codebasin").error( "Configuration file does not have YAML file extension.") sys.exit(1) codebase, configuration = config.load(args.config_file, rootdir) # Parse the source tree, and determine source line associations. # The trees and associations are housed in state. state = finder.find(rootdir, codebase, configuration) # Count lines for platforms platform_mapper = walkers.PlatformMapper(codebase) setmap = platform_mapper.walk(state) output_prefix = os.path.realpath(guess_project_name(args.config_file)) # Print summary report if report_enabled("summary"): summary = report.summary(setmap) if summary is not None: print(summary) # Print clustering report if report_enabled("clustering"):
# Run CBI configured as-if: # - codebase contains a single file (the file being preprocessed) # - configuration contains a single platform (corresponding to flags) file_path = os.path.realpath(args.filename) codebase = {"files": [file_path], "platforms": ["cli"]} configuration = { "cli": [{ "file": file_path, "defines": args.defines, "include_paths": args.include_paths, "include_files": args.include_files }] } state = finder.find(os.getcwd(), codebase, configuration, summarize_only=args.summarize) platform = Platform("cli", os.getcwd()) for path in args.include_paths: platform.add_include_path(path) for definition in args.defines: macro = macro_from_definition_string(definition) platform.define(macro.name, macro) source_tree = state.get_tree(file_path) node_associations = state.get_map(file_path) if args.passthrough: source_printer = SourcePrinter(source_tree) source_printer.walk() else: