Ejemplo n.º 1
0
    def clewn_test(self, commands, expected, outfile, *test):
        """The test method.

        arguments:
            commands: list of str
                the commands sourced by vim
            expected: list of str
                expected strings that must be found in outfile
            outfile: str
                the output file name
            test: argument list
                the content of the test files that vim is loading

        The result check ignores changes in the amount of white space
        (including new lines).

        """
        cwd = os.getcwd() + os.sep

        use_select_emulation = "CLEWN_PIPES" in os.environ or os.name == "nt"
        if use_select_emulation:
            # handle interrupt in a pdb test
            if commands[0] == "Cinterrupt":
                commands[0:0] = ["sleep %dm" % (3 * TESTRUN_SLEEP_TIME)]
            commands = append_command(("Cinterrupt",), commands, "call Wait_eop()")
            command_list = ()
        else:
            command_list = ("Cquit", "Cinterrupt", "Ccontinue", "Cstep", "Cnext", "Pyclewn pdb", "Csigint", "Crun")
        commands = append_command(command_list, commands)
        commands = append_command(("Cdetach",), commands, "sleep %dm" % (5 * TESTRUN_SLEEP_TIME))
        commands = "%s:%s\n" % (WAIT_EOP, "\n:".join(commands))

        # write the commands
        if self._debug:
            timeout = -1
        else:
            timeout = 5
        fp = open(TESTFN, "w")
        fp.write(
            string.Template(commands).substitute(
                test_file=TESTFN_FILE, test_out=TESTFN_OUT, key=random.randint(0, 1000000000), timeout=timeout, cwd=cwd
            )
        )
        fp.close()

        # write the test files
        for i, t in enumerate(test):
            fp = open(TESTFN_FILE + str(i + 1), "w")
            fp.write(t)
            fp.close()

        # process the commands
        if self._debug:
            vim.pdb(netbeans="localhost:3220:foo")
        unused = vim.main(True)

        # check the result
        fp = open(outfile, "r")
        output = fp.read()
        fp.close()

        expected = "\n".join(expected)
        if os.name == "nt":
            expected = expected.replace("/", "\\")
        expected = string.Template(expected).substitute(cwd=cwd, test_file=TESTFN_FILE)

        checked = " ".join(expected.split()) in " ".join(output.split())
        # project files on Windows do have forward slashes, and gdb may output
        # a mix of backward and forward slashes: convert also output
        if os.name == "nt" and not checked:
            output = output.replace("/", "\\")
            checked = " ".join(expected.split()) in " ".join(output.split())
        self.assertTrue(checked, "\n\n...Expected:\n%s \n\n...Got:\n%s" % (expected, output))
Ejemplo n.º 2
0
"""Debugged script used by the test suite."""
import sys
from testsuite import foo

def main():
    """Main."""
    run = sys.argv[1:] and sys.argv[1:][0]
    do_sleep = sys.argv[2:] and sys.argv[2:][0]
    foo.foo(run, do_sleep, 'unused')
    print 'Terminated.'

if __name__ == '__main__':
    import clewn.vim as vim; vim.pdb(testrun=True,
                            level='nbdebug', file='logfile')
    main()

Ejemplo n.º 3
0
"""Debugged script used by the test suite."""

# Python 2-3 compatibility.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import testsuite.foo as foo


def main():
    run = sys.argv[1:] and sys.argv[1:][0]
    do_sleep = sys.argv[2:] and sys.argv[2:][0]
    foo.foo(run, do_sleep, 'unused')
    print('Terminated.')


if __name__ == '__main__':
    import clewn.vim as vim
    vim.pdb(testrun=True, level='nbdebug', file='logfile')
    main()
    next_line = 1
Ejemplo n.º 4
0
def pytest_cmdline_main(config):
    pyclwen_opt = config.getoption('--pyclewn')
    if pyclwen_opt:
        from clewn.vim import pdb
        pdb()