예제 #1
0
파일: _make.py 프로젝트: AvdN/tdi
    def _run(self, target, seen=None):
        """ Run a target """
        if target.DEPS:
            self(*target.DEPS, **{'seen': seen})

        if not target.HIDDEN:
            _term.yellow(">>> %(name)s", name=target.NAME)

        try:
            result = target.run()
        except KeyboardInterrupt:
            result, target.ERROR = False, "^C -> exit"
        except Failure as e:
            result, target.ERROR = False, "%s: %s" % (target.NAME, e)
        except (SystemExit, MemoryError):
            raise
        except:
            import traceback
            target.ERROR = "%s errored:\n%s" % (target.NAME, ''.join(
                traceback.format_exception(*_sys.exc_info())
            ))
            result = False
        else:
            if result is None:
                result = True
        return result
예제 #2
0
    def _run(self, target, seen=None):
        """ Run a target """
        if target.DEPS:
            self(*target.DEPS, **{'seen': seen})

        if not target.HIDDEN:
            _term.yellow(">>> %(name)s", name=target.NAME)

        try:
            result = target.run()
        except KeyboardInterrupt:
            result, target.ERROR = False, "^C -> exit"
        except Failure as e:
            result, target.ERROR = False, "%s: %s" % (target.NAME, e)
        except (SystemExit, MemoryError):
            raise
        except:
            import traceback
            target.ERROR = "%s errored:\n%s" % (target.NAME, ''.join(
                traceback.format_exception(*_sys.exc_info())))
            result = False
        else:
            if result is None:
                result = True
        return result
예제 #3
0
    def _run(self, target, seen=None):
        """ Run a target """
        if target.DEPS:
            self(*target.DEPS, **{'seen': seen})

        if not target.HIDDEN:
            _term.yellow(">>> %(name)s", name=target.NAME)

        try:
            result = target.run()
        except KeyboardInterrupt:
            result, target.ERROR = False, "^C -> exit"
        except Failure, e:
            result, target.ERROR = False, "%s: %s" % (target.NAME, e)
예제 #4
0
파일: run_tests.py 프로젝트: giorgil/tdi
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [item for item in dirs
            if item not in ('.svn', '.git', 'out')
        ]
        dirs.sort()
        files = [item for item in files if item.endswith('.py')]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, 'out')):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(
                _os.path.join(dirname, filename),
                _os.path.join(dirname, 'out', filename[:-3] + '.out'),
            ): erred = 1
        term.yellow("<--- %s" % (dirname[strip:],))
    return erred


def main():
    """ Main """
    basedir, libdir = None, None
    accept_opts = True
    args = []
예제 #5
0
def run_tests(basedir, libdir):
    """ Run output based tests """
    import rcssmin as _rcssmin

    py_cssmin = _rcssmin._make_cssmin(python_only=True)
    c_cssmin = _rcssmin._make_cssmin(python_only=False)

    def run_test(example, output_file):
        """ Run it """
        try:
            fp = open(example, "r")
        except IOError:
            return
        else:
            try:
                input = fp.read()
            finally:
                fp.close()

        def load_output(filename):
            try:
                fp = open(filename, "r")
            except IOError:
                return None
            else:
                try:
                    output = fp.read()
                finally:
                    fp.close()
            output = output.strip()
            if _re.search(r"(?<!\\)(?:\\\\)*\\[0-9a-zA-Z]{1,6}$", output):
                output += " "
            return output

        output = load_output(output_file)
        output_b = load_output(output_file + ".b")

        def do_test(cssmin, output, **options):
            try:
                genout = cssmin(input, **options)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                return 1, "%(RED)s exc%(NORMAL)s "
            else:
                if output is None:
                    return 1, "%(RED)smiss%(NORMAL)s "
                elif genout == output or genout == output.rstrip():
                    return 0, "%(GREEN)sOK%(NORMAL)s   "
                else:
                    return 1, "%(RED)sfail%(NORMAL)s "

        erred, out = do_test(py_cssmin, output)
        erred, c_out = do_test(c_cssmin, output)
        erred, out_b = do_test(py_cssmin, output_b, keep_bang_comments=True)
        erred, c_out_b = do_test(c_cssmin, output_b, keep_bang_comments=True)

        term.write(
            "%(out)s %(out_b)s  |  %(c_out)s %(c_out_b)s - %%(example)s\n" % locals(),
            example=_os.path.basename(example),
        )
        return erred

    # end
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [item for item in dirs if item not in (".svn", ".git", "out")]
        dirs.sort()
        files = [item for item in files if item.endswith(".css")]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, "out")):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(_os.path.join(dirname, filename), _os.path.join(dirname, "out", filename[:-4] + ".out")):
                erred = 1
        term.yellow("<--- %s" % (dirname[strip:],))
    return erred
예제 #6
0
def run_tests(basedir, libdir):
    """ Run output based tests """
    import rcssmin as _rcssmin
    py_cssmin = _rcssmin._make_cssmin(python_only=True)
    c_cssmin = _rcssmin._make_cssmin(python_only=False)

    def run_test(example, output_file):
        """ Run it """
        try:
            fp = open(example, 'r')
        except IOError:
            return
        else:
            try:
                input = fp.read()
            finally:
                fp.close()

        def load_output(filename):
            try:
                fp = open(filename, 'r')
            except IOError:
                return None
            else:
                try:
                    output = fp.read()
                finally:
                    fp.close()
            output = output.strip()
            if _re.search(r'(?<!\\)(?:\\\\)*\\[0-9a-zA-Z]{1,6}$', output):
                output += ' '
            return output

        output = load_output(output_file)
        output_b = load_output(output_file + '.b')

        def do_test(cssmin, output, **options):
            try:
                genout = cssmin(input, **options)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                return 1, "%(RED)s exc%(NORMAL)s "
            else:
                if output is None:
                    return 1, "%(RED)smiss%(NORMAL)s "
                elif genout == output or genout == output.rstrip():
                    return 0, "%(GREEN)sOK%(NORMAL)s   "
                else:
                    return 1, "%(RED)sfail%(NORMAL)s "

        erred, out = do_test(py_cssmin, output)
        erred, c_out = do_test(c_cssmin, output)
        erred, out_b = do_test(py_cssmin, output_b, keep_bang_comments=True)
        erred, c_out_b = do_test(c_cssmin, output_b, keep_bang_comments=True)

        term.write(
            "%(out)s %(out_b)s  |  %(c_out)s %(c_out_b)s - %%(example)s\n"
                % locals(),
            example=_os.path.basename(example),
        )
        return erred

    # end
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [
            item for item in dirs if item not in ('.svn', '.git', 'out')
        ]
        dirs.sort()
        files = [item for item in files if item.endswith('.css')]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, 'out')):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(
                _os.path.join(dirname, filename),
                _os.path.join(dirname, 'out', filename[:-4] + '.out'),
            ): erred = 1
        term.yellow("<--- %s" % (dirname[strip:],))
    return erred