merge from master

This commit is contained in:
adam j hartz 2016-06-07 17:28:50 -04:00
commit 27e8409760
4 changed files with 31 additions and 6 deletions

View file

@ -23,6 +23,9 @@ Current Developments
* Partial workaround for Cygwin where ``pthread_sigmask`` appears to be missing
from the ``signal`` module.
* Fixed crash resulting from malformed ``$PROMPT``.
* Fixed regression on Windows with the locate_binary() function.
The bug prevented `source-cmd` from working correctly and broke the
``activate``/``deactivate`` aliases for the conda environements.
**Security:** None

View file

@ -5,8 +5,8 @@ xonsh
:alt: Join the chat at https://gitter.im/scopatz/xonsh
:target: https://gitter.im/scopatz/xonsh?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
.. image:: https://travis-ci.org/scopatz/xonsh.svg?branch=master
:target: https://travis-ci.org/scopatz/xonsh
.. image:: https://travis-ci.org/xonsh/xonsh.svg?branch=master
:target: https://travis-ci.org/xonsh/xonsh
.. image:: https://ci.appveyor.com/api/projects/status/ufqtigii8ma3rctt/branch/master?svg=true
:target: https://ci.appveyor.com/project/rbrewer123/xonsh-unq93

View file

@ -4,12 +4,15 @@ from __future__ import unicode_literals, print_function
import os
import tempfile
import builtins
from tempfile import TemporaryDirectory
from xonsh.tools import ON_WINDOWS
import nose
from nose.tools import (assert_equal, assert_true, assert_not_in,
assert_is_instance, assert_in, assert_raises)
from xonsh.environ import Env, format_prompt, load_static_config
from xonsh.environ import Env, format_prompt, load_static_config, locate_binary
from tools import mock_xonsh_env
@ -127,6 +130,23 @@ def test_load_static_config_json_fail():
s = b'{"best": "awash"'
check_load_static_config(s, {}, False)
if ON_WINDOWS:
def test_locate_binary_on_windows():
files = ('file1.exe', 'FILE2.BAT', 'file3.txt')
with TemporaryDirectory() as tmpdir:
for fname in files:
fpath = os.path.join(tmpdir, fname)
with open(fpath, 'w') as f:
f.write(fpath)
env = Env({'PATH': [tmpdir], 'PATHEXT': ['.COM', '.EXE', '.BAT']})
with mock_xonsh_env(env):
assert_equal( locate_binary('file1'), os.path.join(tmpdir,'file1.exe'))
assert_equal( locate_binary('file1.exe'), os.path.join(tmpdir,'file1.exe'))
assert_equal( locate_binary('file2'), os.path.join(tmpdir,'FILE2.BAT'))
assert_equal( locate_binary('file2.bat'), os.path.join(tmpdir,'FILE2.BAT'))
assert_equal( locate_binary('file3'), None)
if __name__ == '__main__':
nose.runmodule()

View file

@ -750,9 +750,10 @@ class Env(MutableMapping):
def _yield_executables(directory, name):
if ON_WINDOWS:
base_name, ext = os.path.splitext(name.lower())
for fname in executables_in(directory):
base_name, ext = os.path.splitext(fname)
if name.lower() == base_name.lower():
fbase, fext = os.path.splitext(fname.lower())
if base_name == fbase and (len(ext) == 0 or ext == fext):
yield os.path.join(directory, fname)
else:
for x in executables_in(directory):
@ -767,7 +768,8 @@ def locate_binary(name):
directories = builtins.__xonsh_env__.get('PATH')
# Windows users expect t obe able to execute files in the same directory without `./`
# Windows users expect t obe able to execute files in the same directory
# without `./`
if ON_WINDOWS:
directories = [_get_cwd()] + directories