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")
Example #2
0
 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")
Example #3
0
    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))
                        help='desired output reports (default: all)')
    args = parser.parse_args()

    stdout_log = logging.StreamHandler(sys.stdout)
    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: