:param str path: The full path. :returns: str """ return os.path.relpath(path, BASEDIR) # GNAThub.Project.name assertEqual(GNAThub.Project.name(), 'Disabled') # GNAThub.Project.path assertEqual(relpath(GNAThub.Project.path()), 'disabled.gpr') # GNAThub.Project.object_dir assertEqual(relpath(GNAThub.Project.object_dir()), 'obj') assertTrue(os.path.isdir(GNAThub.Project.object_dir())) # GNAThub.Project.source_dirs source_dirs = GNAThub.Project.source_dirs() assertEqual(len(source_dirs), 1) assertIn('Disabled', source_dirs) assertEqual(relpath(source_dirs['Disabled'][0]), 'src') # GNAThub.Project.source_files source_files = GNAThub.Project.source_files() assertEqual(len(source_files), 1) assertIn('Disabled', source_files) assertEqual( sorted([os.path.basename(sfile) for sfile in source_files['Disabled']]), sorted(['f.adb', 'f.ads', 'simple.adb']))
return True return False def relpath(path): """Returns the relative path to :param:`path` from BASEDIR. :param str path: The full path. :returns: str """ return os.path.relpath(path, BASEDIR) assertTrue(os.path.isdir(GNAThub.root())) assertEqual(relpath(GNAThub.root()), os.path.join('obj', 'gnathub')) assertTrue(os.path.isdir(GNAThub.logs())) assertEqual(relpath(GNAThub.logs()), os.path.join('obj', 'gnathub', 'logs')) assertTrue(os.path.isfile(GNAThub.database())) assertEqual(relpath(GNAThub.database()), os.path.join('obj', 'gnathub', 'gnathub.db')) #DB content check # Check tool exists TOOL = 'gnatcheck' assertTrue(contains(TOOL))
def contains(tool_name): """Check that a tool exists in the database. :param tool_name: the name of the tool to check existence for :type tool_name: str :return: `True` if the tool exists, `False` otherwise :rtype: boolean """ for tool in GNAThub.Tool.list(): if tool.name == tool_name: return True return False # Check tool exists assertTrue(contains(TOOL)) tool = GNAThub.Tool(TOOL) # Check that rules were created rules = [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id] assertNotEmpty(rules) # Check that messages were recorded assertNotEmpty( [msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Purge the database GNAThub.Tool.clear_references(TOOL) # Check that messages were deleted assertEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Check that rules were deleted assertEmpty(
def contains(tool_name): """Check that a tool exists in the database. :param tool_name: the name of the tool to check existence for :type tool_name: str :return: `True` if the tool exists, `False` otherwise :rtype: boolean """ for tool in GNAThub.Tool.list(): if tool.name == tool_name: return True return False # Check tool exists assertTrue(contains(TOOL)) tool = GNAThub.Tool(TOOL) # Check that rules were created rules = [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id] assertNotEmpty(rules) # Check that messages were recorded assertNotEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Purge the database GNAThub.Tool.clear_references(TOOL) # Check that messages were deleted assertEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Check that rules were deleted assertEmpty( [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id])
"""Check that a tool exists in the database. :param tool_name: the name of the tool to check existence for :type tool_name: str :return: `True` if the tool exists, `False` otherwise :rtype: boolean """ for tool in GNAThub.Tool.list(): if tool.name == tool_name: return True return False # Check that spark2014 tool exists in the DB TOOL_NAME = 'spark2014' assertTrue(contains(TOOL_NAME)) tool = GNAThub.Tool(TOOL_NAME) # Check that rules were created in the Rules table rules = [rule.id for rule in GNAThub.Rule.list() if rule.tool_id == tool.id] assertNotEmpty(rules) assertEqual(len(rules), 12) # Check that messages were recorded in Messages table messages = GNAThub.Message.list() assertNotEmpty(messages) assertNotEmpty([msg for msg in GNAThub.Message.list() if msg.rule_id in rules]) # Check that all resources were recorded in Ressources table resources = GNAThub.Resource.list() assertNotEmpty(resources)
if tool.name == tool_name: return True return False def relpath(path): """Returns the relative path to :param:`path` from BASEDIR. :param str path: The full path. :returns: str """ return os.path.relpath(path, BASEDIR) assertTrue(os.path.isdir(GNAThub.root())) assertEqual(relpath(GNAThub.root()), os.path.join('obj', 'gnathub')) assertTrue(os.path.isdir(GNAThub.logs())) assertEqual(relpath(GNAThub.logs()), os.path.join('obj', 'gnathub', 'logs')) assertTrue(os.path.isfile(GNAThub.database())) assertEqual( relpath(GNAThub.database()), os.path.join('obj', 'gnathub', 'gnathub.db') ) #DB content check # Check tool exists TOOL = 'gnatmetric'
# The base directory for PATH comparisons BASEDIR = os.path.dirname(os.path.realpath(sys.argv[0])) def relpath(path): """Returns the relative path to :param:`path` from BASEDIR. :param str path: The full path. :returns: str """ return os.path.relpath(path, BASEDIR) assertTrue(os.path.isdir(GNAThub.root())) assertEqual(relpath(GNAThub.root()), os.path.join('obj', 'gnathub')) assertTrue(os.path.isdir(GNAThub.logs())) assertEqual(relpath(GNAThub.logs()), os.path.join('obj', 'gnathub', 'logs')) assertTrue(GNAThub.quiet()) assertFalse(GNAThub.verbose()) assertFalse(GNAThub.dry_run()) assertTrue(GNAThub.runners_only()) assertFalse(GNAThub.reporters_only()) assertTrue(os.path.isfile(GNAThub.database())) assertEqual( relpath(GNAThub.database()), os.path.join('obj', 'gnathub', 'gnathub.db')
:param str path: The full path. :returns: str """ return os.path.relpath(path, BASEDIR) # GNAThub.Project.name assertEqual(GNAThub.Project.name(), 'Disabled') # GNAThub.Project.path assertEqual(relpath(GNAThub.Project.path()), 'disabled.gpr') # GNAThub.Project.object_dir assertEqual(relpath(GNAThub.Project.object_dir()), 'obj') assertTrue(os.path.isdir(GNAThub.Project.object_dir())) # GNAThub.Project.source_dirs source_dirs = GNAThub.Project.source_dirs() assertEqual(len(source_dirs), 1) assertIn('Disabled', source_dirs) assertEqual(relpath(source_dirs['Disabled'][0]), 'src') # GNAThub.Project.source_files source_files = GNAThub.Project.source_files() assertEqual(len(source_files), 1) assertIn('Disabled', source_files) assertEqual( sorted([os.path.basename(sfile) for sfile in source_files['Disabled']]), sorted(['f.adb', 'f.ads', 'simple.adb']) )