def run_test(label, slug, main, helper, recursive, projects=[], units=[], projects_warned=[], expected_cov_list=[]): """ Produce a coverage report for the given parameters and check the emitted warnings. :param str label: Label for this test. :param str slug: Unique short string for this test (used to create directories). :param ProjectConfig main: Configuration for the "main" project. :param ProjectConfig helper: Configuration for the "helper" project. :param bool recursive: Whether to not pass --no-subprojects. :param list[str] projects: List of projects to pass with --projects. :param list[str] units: List of units to pass with --units. :param list[str] projects_warned: List of projects for which we expected warnings. :param expected_cov: List of expected coverage reports. """ thistest.log('== [{}] {} =='.format(slug, label)) tmp.to_subdir('wd_/{}'.format(slug)) expected_output = '\n'.join( 'warning: project {} provides no unit of interest' .format(project) for project in projects_warned) # Generate projects for this test (see below for the description of each # project). ProjectConfig().generate('empty') helper.generate('helper') main_prj = main.generate('main', deps=['empty', 'helper'], mains=['main.adb']) mkdir('obj-empty') mkdir('obj-helper') mkdir('obj-main') # Generate a coverage report for them build_run_and_coverage( gprsw=GPRswitches(root_project=main_prj, projects=projects, units=units, no_subprojects=not recursive), covlevel='stmt', mains=['main'], gpr_obj_dir='obj-main', extra_coverage_args=['-axcov']) log_file = ('coverage.log' if thistest.options.trace_mode == 'bin' else 'instrument.log') thistest.fail_if_not_equal( '[{}/{}] gnatcov output'.format(label, slug), expected_output, contents_of(log_file).strip()) expected_cov = {} for c in expected_cov_list: expected_cov.update(c) check_xcov_reports('obj-*/*.xcov', expected_cov)
def to_workdir(self, wdir): """Switch to work directory WDIR, creating it if necessary. WDIR is expected to be either absolute or relative from the homedir.""" self.to_homedir() mkdir(wdir) cd(wdir) thistest.log("Work directory: %s" % os.getcwd())
def display(self): thistest.log('\n' * self.pre + self.char * (self.width + 6)) for text in self.lines: thistest.log( "%s %s %s" % (self.char * 2, text.center(self.width), self.char * 2)) thistest.log(self.char * (self.width + 6) + '\n' * self.post)
def run(self, discharge_kdict): thistest.log("\n~~ processing " + self.report + " ~~\n") # For each kind in RELEVANT_XNOTE_KINDS, process discharges of # expectations from emitted notes. DISCHARGE_KDICT provides a special # set of of emitted note kinds that may discharge a given kind of # expected note, when that set is wider than the target kind alone. # We have to do this with two distinct loops because there is no # guaranteed one to one correspondance between emitted vs expected # kinds for discharges. # Process expectations first, looking for candidate dischargers and # complaining about violation expectations that were not discharged # (expected bla missing). Discharges of anti-expectations are also # registered here, silently. Complaints will come out of the emitted # notes processing below. [ self.process_xkind(xkind=xkind, ekinds=discharge_kdict.get(xkind, [xkind])) for xkind in self.rxp ] # Then process the relevant emitted notes, complaining about those # that don't discharge any expectation as required, or that discharge # an anti expectation (unexpected blo). [self.process_ekind(ekind) for ekind in self.ren] # Dump the report contents in case this check exposed a test failure: if thistest.n_failed > self.n_failed_init: thistest.log("\nreport contents:\n") thistest.log(contents_of(self.report)) else: thistest.log("OK\n")