summaryrefslogtreecommitdiffstats
path: root/tests/test_in_vterm/test_vim.py
blob: 0fbc319046dc5282e8b74b7d1ac1c79211f6c4b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)

import os
import sys

from time import sleep
from subprocess import check_call
from glob import glob1
from traceback import print_exc

from powerline.lib.dict import updated

from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions,
                                        do_terminal_tests, get_env)
from tests.modules import PowerlineTestSuite


TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT'])


def main(attempts=3):
	vterm_path = os.path.join(TEST_ROOT, 'path')

	vim_exe = os.path.join(vterm_path, 'vim')

	env = get_env(vterm_path, TEST_ROOT)
	env['ROOT'] = os.path.abspath('.')

	dim = MutableDimensions(rows=50, cols=200)

	vimrc = os.path.join(TEST_ROOT, 'init.vim')
	vimrc_contents = '''
		set laststatus=2
		set runtimepath=$ROOT/powerline/bindings/vim
	'''
	with open(vimrc, 'w') as vd:
		vd.write(vimrc_contents)

	base_attrs = {
		(( 64,  64, 255), (0, 0, 0), 0, 0, 0): 'NT',  # NonText
		((240, 240, 240), (0, 0, 0), 0, 0, 0): 'N',   # Normal
	}

	args = [
		'-u', vimrc,
		'-i', 'NONE',
	]

	def feed(p):
		p.send(':echo strtrans(eval(&statusline[2:]))\n')

	tests = (
	)

	with PowerlineTestSuite('vim') as suite:
		return do_terminal_tests(
			tests=tests,
			cmd=vim_exe,
			dim=dim,
			args=args,
			env=env,
			cwd=TEST_ROOT,
			suite=suite,
		)


if __name__ == '__main__':
	if main():
		raise SystemExit(0)
	else:
		raise SystemExit(1)