Example #1
0
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,
        )
Example #2
0
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,
		)
Example #3
0
def main(attempts=3):
	vterm_path = os.path.join(VTERM_TEST_DIR, 'path')

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

	env = get_env(vterm_path, VTERM_TEST_DIR)

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

	tests = (
	)

	args = []

	return do_terminal_tests(
		tests=tests,
		cmd=vim_exe,
		dim=dim,
		args=args,
		env=env,
		cwd=VTERM_TEST_DIR,
	)
Example #4
0
def main(attempts=3):
	vterm_path = os.path.join(TEST_ROOT, 'path')

	tmux_exe = os.path.join(vterm_path, 'tmux')

	socket_path = os.path.abspath('tmux-socket-{0}'.format(attempts))
	if os.path.exists(socket_path):
		os.unlink(socket_path)

	env = get_env(vterm_path, TEST_ROOT, {
		'POWERLINE_THEME_OVERRIDES': ';'.join((
			key + '=' + json.dumps(val)
			for key, val in (
				('default.segments.right', [{
					'type': 'string',
					'name': 's1',
					'highlight_groups': ['cwd'],
					'priority':50,
				}]),
				('default.segments.left', [{
					'type': 'string',
					'name': 's2',
					'highlight_groups': ['background'],
					'priority':20,
				}]),
				('default.segment_data.s1.contents', 'S1 string here'),
				('default.segment_data.s2.contents', 'S2 string here'),
			)
		)),
		'POWERLINE_TMUX_SOCKET_PATH': socket_path,
	})

	conf_path = os.path.abspath('powerline/bindings/tmux/powerline.conf')
	conf_line = 'source "' + (
		conf_path.replace('\\', '\\\\').replace('"', '\\"')) + '"\n'
	conf_file = os.path.realpath(os.path.join(TEST_ROOT, 'tmux.conf'))
	with open(conf_file, 'w') as cf_fd:
		cf_fd.write(conf_line)

	tmux_version = get_tmux_version(get_fallback_logger())

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

	def prepare_test_1(p):
		sleep(5)

	def prepare_test_2(p):
		dim.cols = 40
		p.resize(dim)
		sleep(5)

	base_attrs = {
		((0, 0, 0), (243, 243, 243), 1, 0, 0): 'lead',
		((243, 243, 243), (11, 11, 11), 0, 0, 0): 'leadsep',
		((255, 255, 255), (11, 11, 11), 0, 0, 0): 'bg',
		((199, 199, 199), (88, 88, 88), 0, 0, 0): 'cwd',
		((88, 88, 88), (11, 11, 11), 0, 0, 0): 'cwdhsep',
		((0, 0, 0), (0, 224, 0), 0, 0, 0): 'defstl',
	}
	tests = (
		{
			'expected_result': get_expected_result(
				tmux_version,
				expected_result_old=(
					'{lead: 0 }{leadsep: }{bg: S2 string here  }'
					'{4: 0  }{cwdhsep:| }{6:bash  }'
					'{bg: }{4: 1- }{cwdhsep:| }{6:bash  }'
					'{bg: }{7: }{8:2* | }{9:bash }{10: }'
					'{bg:' + (' ' * 124) + '}'
					'{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
						((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 7,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 8,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 9,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 10,
					})),
				expected_result_1_8=(
					'{lead: 0 }{leadsep: }{bg: S2 string here  }'
					'{4: 0  }{cwdhsep:| }{6:bash  }'
					'{bg: }{4: 1- }{cwdhsep:| }{7:bash  }'
					'{bg: }{8: }{9:2* | }{10:bash }{7: }'
					'{bg:' + (' ' * 124) + '}'
					'{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
						((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 7,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 8,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 9,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 10,
					})),
				expected_result_2_0=(
					'{lead: 0 }{leadsep: }{bg: S2 string here }'
					'{4: 0  }{cwdhsep:| }{6:bash  }'
					'{bg: }{4: 1- }{cwdhsep:| }{7:bash  }'
					'{bg: }{8: }{9:2* | }{10:bash }{7: }'
					'{bg:' + (' ' * 125) + '}'
					'{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
						((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 7,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 8,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 9,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 10,
					})),
			),
			'prep_cb': prepare_test_1,
			'row': dim.rows - 1,
		}, {
			'expected_result': get_expected_result(
				tmux_version,
				expected_result_old=('{bg:' + (' ' * 40) + '}', base_attrs),
				expected_result_1_7=(
					'{lead: 0 }'
					'{leadsep: }{bg: <}{4:h  }{bg: }{5: }'
					'{6:2* | }{7:bash }{8: }{bg: }{cwdhsep: }'
					'{cwd: S1 string here }', updated(base_attrs, {
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 4,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 8,
					})),
				expected_result_1_8=(
					'{lead: 0 }'
					'{leadsep: }{bg: <}{4:h  }{bg: }{5: }'
					'{6:2* | }{7:bash }{4: }{bg: }{cwdhsep: }'
					'{cwd: S1 string here }', updated(base_attrs, {
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 4,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
					})),
				expected_result_2_0=(
					'{lead: 0 }'
					'{leadsep: }{bg:<}{4:ash  }{bg: }{5: }'
					'{6:2* | }{7:bash }{4: }{cwdhsep: }'
					'{cwd: S1 string here }', updated(base_attrs, {
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 4,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
					})),
			),
			'prep_cb': prepare_test_2,
			'row': dim.rows - 1,
		}
	)

	args = [
		# Specify full path to tmux socket (testing tmux instance must not 
		# interfere with user one)
		'-S', socket_path,
		# Force 256-color mode
		'-2',
		# Request verbose logging just in case
		'-v',
		# Specify configuration file
		'-f', conf_file,
		# Run bash three times
		'new-session', 'bash --norc --noprofile -i', ';',
		'new-window', 'bash --norc --noprofile -i', ';',
		'new-window', 'bash --norc --noprofile -i', ';',
	]

	with PowerlineTestSuite('tmux') as suite:
		return do_terminal_tests(
			tests=tests,
			cmd=tmux_exe,
			dim=dim,
			args=args,
			env=env,
			cwd=TEST_ROOT,
			fin_cb=tmux_fin_cb,
			last_attempt_cb=print_tmux_logs,
			suite=suite,
		)
Example #5
0
def main(attempts=3):
	vterm_path = os.path.join(VTERM_TEST_DIR, 'path')

	tmux_exe = os.path.join(vterm_path, 'tmux')

	socket_path = os.path.abspath('tmux-socket-{0}'.format(attempts))
	if os.path.exists(socket_path):
		os.unlink(socket_path)

	env = get_env(vterm_path, VTERM_TEST_DIR, {
		'POWERLINE_THEME_OVERRIDES': ';'.join((
			key + '=' + json.dumps(val)
			for key, val in (
				('default.segments.right', [{
					'type': 'string',
					'name': 's1',
					'highlight_groups': ['cwd'],
					'priority':50,
				}]),
				('default.segments.left', [{
					'type': 'string',
					'name': 's2',
					'highlight_groups': ['background'],
					'priority':20,
				}]),
				('default.segment_data.s1.contents', 'S1 string here'),
				('default.segment_data.s2.contents', 'S2 string here'),
			)
		)),
		'POWERLINE_TMUX_SOCKET_PATH': socket_path,
	})

	conf_path = os.path.abspath('powerline/bindings/tmux/powerline.conf')
	conf_line = 'source "' + (
		conf_path.replace('\\', '\\\\').replace('"', '\\"')) + '"\n'
	conf_file = os.path.realpath(os.path.join(VTERM_TEST_DIR, 'tmux.conf'))
	with open(conf_file, 'w') as cf_fd:
		cf_fd.write(conf_line)

	tmux_version = get_tmux_version(get_fallback_logger())

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

	def prepare_test_1(p):
		sleep(5)

	def prepare_test_2(p):
		dim.cols = 40
		p.resize(dim)
		sleep(5)

	base_attrs = {
		((0, 0, 0), (243, 243, 243), 1, 0, 0): 'lead',
		((243, 243, 243), (11, 11, 11), 0, 0, 0): 'leadsep',
		((255, 255, 255), (11, 11, 11), 0, 0, 0): 'bg',
		((199, 199, 199), (88, 88, 88), 0, 0, 0): 'cwd',
		((88, 88, 88), (11, 11, 11), 0, 0, 0): 'cwdhsep',
		((0, 0, 0), (0, 224, 0), 0, 0, 0): 'defstl',
	}
	tests = (
		{
			'expected_result': get_expected_result(
				tmux_version,
				expected_result_old=(
					'{lead: 0 }{leadsep: }{bg: S2 string here  }'
					'{4: 0  }{cwdhsep:| }{6:bash  }'
					'{bg: }{4: 1- }{cwdhsep:| }{6:bash  }'
					'{bg: }{7: }{8:2* | }{9:bash }{10: }'
					'{bg:' + (' ' * 124) + '}'
					'{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
						((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 7,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 8,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 9,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 10,
					})),
				expected_result_1_8=(
					'{lead: 0 }{leadsep: }{bg: S2 string here  }'
					'{4: 0  }{cwdhsep:| }{6:bash  }'
					'{bg: }{4: 1- }{cwdhsep:| }{7:bash  }'
					'{bg: }{8: }{9:2* | }{10:bash }{7: }'
					'{bg:' + (' ' * 124) + '}'
					'{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
						((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 7,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 8,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 9,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 10,
					})),
				expected_result_2_0=(
					'{lead: 0 }{leadsep: }{bg: S2 string here }'
					'{4: 0  }{cwdhsep:| }{6:bash  }'
					'{bg: }{4: 1- }{cwdhsep:| }{7:bash  }'
					'{bg: }{8: }{9:2* | }{10:bash }{7: }'
					'{bg:' + (' ' * 125) + '}'
					'{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, {
						((133, 133, 133), (11, 11, 11), 0, 0, 0): 4,
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 6,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 7,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 8,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 9,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 10,
					})),
			),
			'prep_cb': prepare_test_1,
			'row': dim.rows - 1,
		}, {
			'expected_result': get_expected_result(
				tmux_version,
				expected_result_old=('{bg:' + (' ' * 40) + '}', base_attrs),
				expected_result_1_7=(
					'{lead: 0 }'
					'{leadsep: }{bg: <}{4:h  }{bg: }{5: }'
					'{6:2* | }{7:bash }{8: }{bg: }{cwdhsep: }'
					'{cwd: S1 string here }', updated(base_attrs, {
						((188, 188, 188), (11, 11, 11), 0, 0, 0): 4,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 8,
					})),
				expected_result_1_8=(
					'{lead: 0 }'
					'{leadsep: }{bg: <}{4:h  }{bg: }{5: }'
					'{6:2* | }{7:bash }{4: }{bg: }{cwdhsep: }'
					'{cwd: S1 string here }', updated(base_attrs, {
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 4,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
					})),
				expected_result_2_0=(
					'{lead: 0 }'
					'{leadsep: }{bg:<}{4:ash  }{bg: }{5: }'
					'{6:2* | }{7:bash }{4: }{cwdhsep: }'
					'{cwd: S1 string here }', updated(base_attrs, {
						((0, 102, 153), (11, 11, 11), 0, 0, 0): 4,
						((11, 11, 11), (0, 102, 153), 0, 0, 0): 5,
						((102, 204, 255), (0, 102, 153), 0, 0, 0): 6,
						((255, 255, 255), (0, 102, 153), 1, 0, 0): 7,
					})),
			),
			'prep_cb': prepare_test_2,
			'row': dim.rows - 1,
		}
	)

	args = [
		# Specify full path to tmux socket (testing tmux instance must not 
		# interfere with user one)
		'-S', socket_path,
		# Force 256-color mode
		'-2',
		# Request verbose logging just in case
		'-v',
		# Specify configuration file
		'-f', conf_file,
		# Run bash three times
		'new-session', 'bash --norc --noprofile -i', ';',
		'new-window', 'bash --norc --noprofile -i', ';',
		'new-window', 'bash --norc --noprofile -i', ';',
	]

	return do_terminal_tests(
		tests=tests,
		cmd=tmux_exe,
		dim=dim,
		args=args,
		env=env,
		cwd=VTERM_TEST_DIR,
		fin_cb=tmux_fin_cb,
		last_attempt_cb=print_tmux_logs,
	)
Example #6
0
def main(argv):
	script_args = get_parser().parse_args(argv)

	vterm_path = os.path.join(TEST_ROOT, 'path')

	env = get_env(vterm_path, TEST_ROOT)
	env['ROOT'] = os.path.abspath('.')
	env['TEST_ROOT'] = TEST_ROOT
	env['TEST_TYPE'] = script_args.type
	env['TEST_CLIENT'] = script_args.client
	env['LANG'] = 'en_US.UTF_8'
	env['_POWERLINE_RUNNING_SHELL_TESTS'] = (
		'ee5bcdc6-b749-11e7-9456-50465d597777')

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

	binding_opts = BINDING_OPTIONS[script_args.binding]

	cmd = os.path.join(vterm_path, binding_opts['cmd'])
	args = binding_opts['args']

	def gen_init(binding):
		def init(p):
			for line in binding_opts['init']:
				p.send(line + '\n')
			sleep(1)

		return init

	def gen_feed(line):
		def feed(p):
			p.send(line + '\n')
			sleep(0.1)

		return feed

	base_attrs = {
		((255, 204,0), (204, 51, 0), 0, 0, 0): 'H',
		((204, 51, 0), (0, 102, 153), 0, 0, 0): 'sHU',
		((255, 255, 255), (0, 102, 153), 1, 0, 0): 'U',
		((0, 102, 153), (44, 44, 44), 0, 0, 0): 'sUB',
		((199, 199, 199), (44, 44, 44), 0, 0, 0): 'B',
		((44, 44, 44), (88, 88, 88), 0, 0, 0): 'sBD',
		((199, 199, 199), (88, 88, 88), 0, 0, 0): 'D',
		((144, 144, 144), (88, 88, 88), 0, 0, 0): 'sD',
		((221, 221, 221), (88, 88, 88), 1, 0, 0): 'C',
		((88, 88, 88), (0, 0, 0), 0, 0, 0): 'sDN',
		((240, 240, 240), (0, 0, 0), 0, 0, 0): 'N',
		((0, 102, 153), (51, 153, 204), 0, 0, 0): 'sUE',
		((255, 255, 255), (51, 153, 204), 0, 0, 0): 'E',
		((51, 153, 204), (44, 44, 44), 0, 0, 0): 'sEB',
	}

	tests = (
		{
			'expected_result': (
				'{H:  hostname }{sHU: }'
				'{U:user }{sUB: }'
				'{B: BRANCH }{sBD: }'
				'{D:… }{sD: }{D:tmp }{sD: }{D:vshells }{sD: }{C:3rd }{sDN: }'
				'{N:}',
				base_attrs,
			),
			'prep_cb': gen_init(script_args.binding),
		},
		{
			'expected_result': (
				'{H:  hostname }{sHU: }'
				'{U:user }{sUB: }'
				'{B: BRANCH }{sBD: }'
				'{D:… }{sD: }{D:vshells }{sD: }{D:3rd }{sD: }{C:.git }{sDN: }'
				'{N:}',
				base_attrs
			),
			'prep_cb': gen_feed('cd .git'),
		},
		{
			'expected_result': (
				'{H:  hostname }{sHU: }'
				'{U:user }{sUB: }'
				'{B: BRANCH }{sBD: }'
				'{D:… }{sD: }{D:tmp }{sD: }{D:vshells }{sD: }{C:3rd }{sDN: }'
				'{N:}',
				base_attrs,
			),
			'prep_cb': gen_feed('cd ..'),
		},
		{
			'expected_result': (
				'{H:  hostname }{sHU: }'
				'{U:user }{sUE: }'
				'{E:(e) some-venv }{sEB: }'
				'{B: BRANCH }{sBD: }'
				'{D:… }{sD: }{D:tmp }{sD: }{D:vshells }{sD: }{C:3rd }{sDN: }'
				'{N:}',
				base_attrs,
			),
			'prep_cb': gen_feed('set_virtual_env some-venv'),
		},
	)

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