def run_test(ctx, rec, name): ctx.logger.check(' * test\t%s' % name, color='cyan') test_base = 'tests' / name test_input = test_base.replaceext('.input.desktop') test_tweaks = test_base.replaceext('.tweaks.desktop') test_expected = test_base.replaceext('.expected.desktop') with fbuild.temp.tempdir(delete=True) as tmp: env = os.environ.copy() env['DTWEAKS_PATH'] = Path.getcwd() / 'tests' tmp_desktop = (tmp / name).replaceext('.tweaks.desktop') test_input.copy(tmp_desktop) rec.c.run([rec.dtweaks, tmp_desktop], env=env, quieter=1) with open(tmp_desktop) as fp: results = fp.read() with open(test_expected) as fp: expected = fp.read() if results != expected: ctx.logger.failed() diff = difflib.unified_diff(expected.splitlines(), results.splitlines()) printing = False for line in diff: if not line.strip(): continue elif line.startswith('@@'): printing = True elif printing: line = ' %s %s\n' % (line[0], line[1:]) if line.startswith(' +'): ctx.logger.write(line, color='green') elif line.startswith(' -'): ctx.logger.write(line, color='red') else: ctx.logger.write(line, color='white') else: ctx.logger.passed()
def f(module, include): # On case-insensitive but case-preserving filesystems, we need to # be careful on how we deal with finding OCaml dependencies. Since # OCaml can store a module named List in either list.ml or List.ml, # we can't just test if the filename exists since fbuild needs to # deal with the exact filenames. To do that, we'll grab the list # of filenames in the directory, then search for the right # spelling in that list. # Grab the filenames in the directory. if include is None: dirs = Path.getcwd().listdir() else: include = Path(include) if not include.exists(): # We can't search for dependencies in a directory that # doesn't exist, so exit early. return False dirs = include.listdir() found = False for suffix in '.mli', '.ml': # Look for the traditional lowercase form. path = module[0].lower() + module[1:] + suffix if path not in dirs: # That didn't work, so lets try the uppercase form. path = module[0].upper() + module[1:] + suffix if path not in dirs: # Couldn't find it, so just skip this module. continue # We found it! Add that file to the dependencies. if include is None: deps.append(Path(path)) else: deps.append(include / path) found = True return found
def f(module, include): # On case-insensitive but case-preserving filesystems, we need to # be careful on how we deal with finding OCaml dependencies. Since # OCaml can store a module named List in either list.ml or List.ml, # we can't just test if the filename exists since fbuild needs to # deal with the exact filenames. To do that, we'll grab the list # of filenames in the directory, then search for the right # spelling in that list. # Grab the filenames in the directory. if include is None: dirs = Path.getcwd().listdir() else: include = Path(include) if not include.exists(): # We can't search for dependencies in a directory that # doesn't exist, so exit early. return False dirs = include.listdir() found = False for suffix in '.mli', '.ml': # Look for the traditional lowercase form. path = module[0].lower() + module[1:] + suffix if path not in dirs: # That didn't work, so lets try the uppercase form. path = module[0].upper() + module[1:] + suffix if path not in dirs: # Couldn't find it, so just skip this module. continue # We found it! Add that file to the dependencies. if include is None: deps.append(Path(path)) else: deps.append(include / path) found = True return found