Exemplo n.º 1
0
def run_core(paths, nvim=False):
    """Start the test."""
    if nvim:
        # client/server connection
        server = multiprocessing.Process(
            target=subprocess.call,
            args=(VIM + " -u " + str(paths["vimrc"]) + ' --listen ' +
                  str(paths["socket"]), ),
            kwargs={'shell': True})
        server.start()
        time.sleep(1)
        client = attach('socket', path=str(paths["socket"]))
        # run test
        client.command('e %s' % paths["in_file"])
        keys = client.input
        for line in open(paths["command"]):
            l = line.replace('\<', '<')
            l = l.replace("\\\\", "\\")
            exec(l)
            time.sleep(0.3)
        client.command(':w! %s' % paths["gen_out_file"])
        client.quit()
    else:
        vim = vimrunner.Server(noplugin=False,
                               vimrc=paths["vimrc"],
                               executable=VIM)
        client = vim.start()
        client.edit(paths["in_file"])
        keys = client.feedkeys
        for line in open(paths["command"]):
            exec(line)
            time.sleep(0.3)
        client.feedkeys('\<Esc>')
        client.feedkeys(':wq! %s\<CR>' % paths["gen_out_file"])
Exemplo n.º 2
0
def run_core(paths, nvim=False):
    """Start the test and return commands_cpu_time."""
    global CLIENT
    if nvim:
        # client/server connection
        server = multiprocessing.Process(
            target=subprocess.call,
            args=(VIM + " -u " + str(paths["vimrc"]) + ' --listen ' + str(paths["socket"]),),
            kwargs={'shell': True}
        )
        server.start()
        time.sleep(1)
        CLIENT = attach('socket', path=str(paths["socket"]))
        # run test
        CLIENT.command('e %s' % paths["in_file"])
        keys = keys_nvim
        start_time = time.process_time()
        commands = open(paths["command"]).read()
        if not LIVE_EDITING:
            commands = r'keys(r":let g:VM_live_editing = 0\<CR>")\n' + commands
        exec(commands)
        end_time = time.process_time()
        CLIENT.command(':w! %s' % paths["gen_out_file"])
        CLIENT.quit()
    else:
        vim = vimrunner.Server(noplugin=False, vimrc=paths["vimrc"], executable=VIM)
        CLIENT = vim.start()
        CLIENT.edit(paths["in_file"])
        keys = keys_vim
        start_time = time.process_time()
        exec(open(paths["command"]).read())
        end_time = time.process_time()
        CLIENT.feedkeys(r'\<Esc>')
        CLIENT.feedkeys(r':wq! %s\<CR>' % paths["gen_out_file"])
    return end_time - start_time
Exemplo n.º 3
0
 def setUp(self):
     self._lang = os.getenv('LANG', 'C')
     os.environ['LANG'] = 'C'
     if not hasattr(subprocess, 'check_output'):
         subprocess.check_output = self.check_output
     self.server = vimrunner.Server(extra_args=['-N', '-i', 'NONE'])
     self.client = self.server.start()
     self.client.add_plugin(os.getcwd(), 'plugin/betterga.vim')
     self.client.write_buffer('1', 'a')
Exemplo n.º 4
0
def run_core(test, paths, nvim=False):
    """Start the test and return commands_cpu_time."""
    global CLIENT
    if nvim:
        # client/server connection
        server = multiprocessing.Process(
            target=subprocess.call,
            args=(VIM + " -u " + str(paths["vimrc"]) + " --listen " +
                  str(paths["socket"]), ),
            kwargs={"shell": True},
        )
        server.start()
        time.sleep(1)
        CLIENT = attach("socket", path=str(paths["socket"]))
        # run test
        CLIENT.command("e %s" % paths["in_file"])
        CLIENT.command("let b:docgen = {'placeholder': { -> '$PLACEHOLDER' }}")
        keys = keys_nvim
        start_time = time.process_time()
        commands = open(paths["command"]).readlines()
        for line in commands:
            if PAUSE_AT_ERRORS and CLIENT.eval('v:errmsg') != '':
                ERRORS[test].append(CLIENT.eval('v:errmsg'))
                CLIENT.command('let v:errmsg = ""')
            exec(line)
        end_time = time.process_time()
        CLIENT.command(":w! %s" % paths["gen_out_file"])
        CLIENT.quit()
    else:
        vim = vimrunner.Server(noplugin=False,
                               vimrc=paths["vimrc"],
                               executable=VIM)
        CLIENT = vim.start()
        CLIENT.edit(paths["in_file"])
        CLIENT.feedkeys(
            ":let b:docgen = {'placeholder': { -> '$PLACEHOLDER' }}\<Esc>")
        keys = keys_vim
        start_time = time.process_time()
        exec(open(paths["command"]).read())
        end_time = time.process_time()
        CLIENT.feedkeys("\<Esc>")
        CLIENT.feedkeys(":wq! %s\<CR>" % paths["gen_out_file"])
    return end_time - start_time
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

import os
import re
import six
import subprocess
import tempfile
import vimrunner

from tasklib import TaskWarrior, Task
from time import sleep

server_name = "TaskWikiTestServer"
server = vimrunner.Server(name=server_name)


class IntegrationTest(object):

    viminput = None
    vimoutput = None
    tasks = []

    def add_plugin(self, name):
        plugin_base = os.path.expanduser('~/.vim/bundle/')
        plugin_path = os.path.join(plugin_base, name)
        self.client.add_plugin(plugin_path)

    def write_buffer(self, lines, position=0):
        result = self.client.write_buffer(position + 1, lines)
        assert result == u"0"
Exemplo n.º 6
0
# -*- coding: utf-8 -*-

import os
import re
import subprocess
import tempfile
import vimrunner

from tasklib import TaskWarrior, Task
from time import sleep

server = vimrunner.Server()


class IntegrationTest(object):

    viminput = None
    vimoutput = None
    tasks = []

    def add_plugin(self, name):
        plugin_base = os.path.expanduser('~/.vim/bundle/')
        plugin_path = os.path.join(plugin_base, name)
        self.client.add_plugin(plugin_path)

    def write_buffer(self, lines, position=0):
        result = self.client.write_buffer(position + 1, lines)
        assert result == u"0"

    def read_buffer(self, start=0, end=1000):
        return self.client.read_buffer(unicode(start + 1),