def build_export_from_files(run, lf, root="", with_default=True, with_results=False): """Build an export file from a list of files. """ prof = AsterProfil(run=run) if with_default: prof.add_default_parameters() ddat = build_dict_file(run, prof, dict_typ_test(root), lf, ['com?', '[0-9]*']) dres = {} if with_results: dres = build_dict_file(run, prof, dict_typ_result(), lf) for dicf, dr in ((ddat, 'D'), (dres, 'R')): lcom_i = [] for f, dico in dicf.items(): if dico['type'] != 'comm' or osp.splitext(f)[-1] == '.comm': prof.Set(dr, dico) else: lcom_i.append([f, dico]) lcom_i.sort() for f, dico in lcom_i: prof.Set(dr, dico) return prof
def build_test_export(run, conf, REPREF, reptest, test, resutest=None, with_default=True, d_unig=None): """Return a profile for a testcase. """ lrep = [osp.join(REPREF, dt) for dt in conf['SRCTEST']] if reptest: lrep.extend(reptest) for rep in lrep: if run.IsRemote(rep): run.Mess(ufmt(_(u'reptest (%s) must be on exec host'), rep), '<F>_INVALID_DIR') lrep = [run.PathOnly(rep) for rep in lrep] lrm = [] if d_unig: d_unig = glob_unigest(d_unig, REPREF) lrm = set([osp.basename(f) for f in d_unig['test']]) export = _existing_file(test + '.export', lrep, last=True) # new testcase with .export if export: prof = AsterProfil(run=run) if with_default: prof.add_default_parameters() pexp = AsterProfil(export, run) pexp.set_param_limits() for entry in pexp.get_data(): if osp.basename(entry.path) in lrm: run.Mess(ufmt(_(u'deleting %s (matches unigest)'), osp.basename(entry.path))) pexp.remove(entry) found = _existing_file(entry.path, lrep, last=True) if found is None: run.Mess(ufmt(_(u'file not found : %s'), entry.path), '<E>_FILE_NOT_FOUND') pexp.remove(entry) else: entry.path = found pexp._compatibility() prof.update(pexp) else: # old version using .para lall = [] for r in lrep: f = osp.join(r, '%s.*' % test) lall.extend(glob(f)) lf = [] for f in lall: if osp.basename(f) in lrm: run.Mess(ufmt(_(u'deleting %s (matches unigest)'), osp.basename(f))) else: lf.append(f) if not lf: run.Mess(ufmt(_(u'no such file : %s.*'), test), '<E>_FILE_NOT_FOUND') prof = build_export_from_files(run, lf, test, with_default=with_default) if resutest: ftyp = { 'resu' : 8, 'mess' : 6, 'code' : 15 } for typ, ul in ftyp.items(): new = ExportEntry(osp.join(resutest, '%s.%s' % (test, typ)), type=typ, ul=ul, result=True) prof.add(new) return prof