Created
April 2, 2015 12:18
-
-
Save hroncok/7cba5df9c46f23b4c02b to your computer and use it in GitHub Desktop.
DevAssistant test on Mac OS X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================= test session starts ============================== | |
platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.7.0 | |
rootdir: /Users/churchyard/Documents/devassistant, inifile: | |
collected 911 items | |
test/test_actions.py ................... | |
test/test_argument.py ............ | |
test/test_assistant_base.py ....... | |
test/test_cache.py ....FF.. | |
test/test_command_helpers.py ............................... | |
test/test_command_runners.py ............................................................................ | |
test/test_config_manager.py ......................... | |
test/test_devassistant_gui.py . | |
test/test_lang.py .................................................................................................. | |
test/test_logger.py ...... | |
test/test_package_managers.py ...........s........s....................................................................... | |
test/test_snippet.py .............. | |
test/test_utils.py .. | |
test/test_yaml_assistant.py ....................... | |
test/test_yaml_assistant_loader.py .......... | |
test/test_yaml_loader.py .F | |
test/test_yaml_snippet_loader.py .... | |
test/cli/test_argparse_generator.py .. | |
test/dapi/test_dap.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................FFFFF..... | |
test/dapi/test_dapicli.py ........ | |
test/dapi/test_dapver.py . | |
test/integration/test_dapi_integration.py .................... | |
test/integration/test_help.py .......... | |
=================================== FAILURES =================================== | |
________ TestCache.test_cache_reacts_to_new_changed_removed_assistants _________ | |
self = <test.test_cache.TestCache object at 0x1127e7bd0> | |
def test_cache_reacts_to_new_changed_removed_assistants(self): | |
self.create_or_refresh_cache() | |
# add new assistant and test that everything is fine | |
self.addme_copy('addme.yaml', 'assistants/crt/addme.yaml') | |
self.addme_copy('addme_snippet.yaml', 'snippets/addme_snippet.yaml') | |
self.create_or_refresh_cache() | |
addme = self.cch.cache['crt']['addme'] | |
assert 'addme_snippet' in addme['snippets'] | |
assert len(addme['snippets']) == 1 | |
assert addme['source'].endswith('assistants/crt/addme.yaml') | |
assert addme['attrs']['fullname'] == 'Add me and watch miracles happen' | |
assert addme['attrs']['args']['some_arg']['flags'] == ['-x'] | |
# change assistant fullname | |
time.sleep(0.1) | |
self.addme_copy('addme_change_fullname.yaml', 'assistants/crt/addme.yaml') | |
self.create_or_refresh_cache() | |
assert addme['attrs']['fullname'] == 'Fullname changed!' | |
# change current snippet (will change argument flag) | |
# snippets are cached during one startup => reset snippet cache manually | |
# TODO: fix this ^^ | |
time.sleep(0.1) | |
self.addme_copy('addme_snippet_changed.yaml', 'snippets/addme_snippet.yaml') | |
from devassistant import yaml_snippet_loader; yaml_snippet_loader.YamlSnippetLoader._snippets = {} | |
self.cch.snip_ctimes = {} | |
self.create_or_refresh_cache() | |
addme = self.cch.cache['crt']['addme'] | |
assert addme['attrs']['args']['some_arg']['flags'] == ['-z'] | |
# switch assistant to another snippet | |
time.sleep(0.1) | |
self.addme_copy('addme_change_snippet.yaml', 'assistants/crt/addme.yaml') | |
self.create_or_refresh_cache() | |
> assert addme['attrs']['args']['some_arg']['flags'] == ['-s', '--some-arg'] | |
E assert ['-z'] == ['-s', '--some-arg'] | |
E At index 0 diff: '-z' != '-s' | |
E Right contains more items, first extra item: '--some-arg' | |
E Use -v to get the full diff | |
test/test_cache.py:189: AssertionError | |
______________ TestCache.test_cache_deletes_if_different_version _______________ | |
self = <test.test_cache.TestCache object at 0x1127ecb90> | |
def test_cache_deletes_if_different_version(self): | |
self.create_fake_cache({'version': '0.0.0'}) | |
prev_time = os.path.getctime(self.cch.cache_file) | |
time.sleep(0.1) | |
Cache() | |
> assert prev_time < os.path.getctime(self.cch.cache_file) | |
E assert 1427976879.0 < 1427976879.0 | |
E + where 1427976879.0 = <function getctime at 0x10fb3b230>('/Users/churchyard/Documents/devassistant/test/fixtures/.cache.yaml') | |
E + where <function getctime at 0x10fb3b230> = <module 'posixpath' from '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'>.getctime | |
E + where <module 'posixpath' from '/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'> = os.path | |
E + and '/Users/churchyard/Documents/devassistant/test/fixtures/.cache.yaml' = <devassistant.cache.Cache object at 0x1127ec210>.cache_file | |
E + where <devassistant.cache.Cache object at 0x1127ec210> = <test.test_cache.TestCache object at 0x1127ecb90>.cch | |
test/test_cache.py:202: AssertionError | |
TestYamlLoader.test_load_yaml_by_path_logs_and_returns_None_on_bad_syntax[bad_syntax3-Yaml error in {p} \(line 2, column 0\): did not find expected key] | |
self = <test.test_yaml_loader.TestYamlLoader object at 0x112c3dc50> | |
which_bad = 'bad_syntax3' | |
err = 'Yaml error in {p} \\(line 2, column 0\\): did not find expected key' | |
@pytest.mark.parametrize('which_bad, err', [ | |
('bad_syntax1', 'Yaml error in {p} \(line 0, column 3\): mapping values are ' + \ | |
'not allowed (in this context|here)'), | |
('bad_syntax3', 'Yaml error in {p} \(line 2, column 0\): did not find expected key'), | |
]) | |
def test_load_yaml_by_path_logs_and_returns_None_on_bad_syntax(self, which_bad, err): | |
path = getattr(self, which_bad) | |
e = err.format(p=path) | |
assert YamlLoader.load_yaml_by_path(path) == None | |
assert 'WARNING' == self.tlh.msgs[0][0] | |
> assert re.match(e, self.tlh.msgs[0][1]) | |
E assert None | |
E + where None = <function match at 0x10fbe4c80>('Yaml error in /Users/churchyard/Documents/devassistant/test/fixtures/assistants_malformed/crt/a3.yaml \\(line 2, column 0\\): did not find expected key', "Yaml error in /Users/churchyard/Documents/devassistant/test/fixtures/assistants_malformed/crt/a3.yaml (line 2, column 0): expected <block end>, but found '-'") | |
E + where <function match at 0x10fbe4c80> = re.match | |
test_yaml_loader.py:31: AssertionError | |
TestDap.test_sha256sum[/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/bad_version-0.1.dap] | |
self = <test_dap.TestDap object at 0x112c90990> | |
dap = '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/bad_version-0.1.dap' | |
@pytest.mark.parametrize('dap', glob.glob(dap_path('meta_only/*.dap'))) | |
def test_sha256sum(self, dap): | |
'''Check that sha256sum of the files is the same as sha256sum command does''' | |
> process = subprocess.Popen(['sha256sum', dap], stdout=subprocess.PIPE) | |
dapi/test_dap.py:539: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:710: in __init__ | |
errread, errwrite) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <subprocess.Popen object at 0x112c90f10> | |
args = ['sha256sum', '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/bad_version-0.1.dap'] | |
executable = 'sha256sum', preexec_fn = None, close_fds = False, cwd = None | |
env = None, universal_newlines = False, startupinfo = None, creationflags = 0 | |
shell = False, to_close = set([8]), p2cread = None, p2cwrite = None, c2pread = 8 | |
c2pwrite = 17, errread = None, errwrite = None | |
def _execute_child(self, args, executable, preexec_fn, close_fds, | |
cwd, env, universal_newlines, | |
startupinfo, creationflags, shell, to_close, | |
p2cread, p2cwrite, | |
c2pread, c2pwrite, | |
errread, errwrite): | |
"""Execute program (POSIX version)""" | |
if isinstance(args, types.StringTypes): | |
args = [args] | |
else: | |
args = list(args) | |
if shell: | |
args = ["/bin/sh", "-c"] + args | |
if executable: | |
args[0] = executable | |
if executable is None: | |
executable = args[0] | |
def _close_in_parent(fd): | |
os.close(fd) | |
to_close.remove(fd) | |
# For transferring possible exec failure from child to parent | |
# The first char specifies the exception type: 0 means | |
# OSError, 1 means some other error. | |
errpipe_read, errpipe_write = self.pipe_cloexec() | |
try: | |
try: | |
gc_was_enabled = gc.isenabled() | |
# Disable gc to avoid bug where gc -> file_dealloc -> | |
# write to stderr -> hang. http://bugs.python.org/issue1336 | |
gc.disable() | |
try: | |
self.pid = os.fork() | |
except: | |
if gc_was_enabled: | |
gc.enable() | |
raise | |
self._child_created = True | |
if self.pid == 0: | |
# Child | |
try: | |
# Close parent's pipe ends | |
if p2cwrite is not None: | |
os.close(p2cwrite) | |
if c2pread is not None: | |
os.close(c2pread) | |
if errread is not None: | |
os.close(errread) | |
os.close(errpipe_read) | |
# When duping fds, if there arises a situation | |
# where one of the fds is either 0, 1 or 2, it | |
# is possible that it is overwritten (#12607). | |
if c2pwrite == 0: | |
c2pwrite = os.dup(c2pwrite) | |
if errwrite == 0 or errwrite == 1: | |
errwrite = os.dup(errwrite) | |
# Dup fds for child | |
def _dup2(a, b): | |
# dup2() removes the CLOEXEC flag but | |
# we must do it ourselves if dup2() | |
# would be a no-op (issue #10806). | |
if a == b: | |
self._set_cloexec_flag(a, False) | |
elif a is not None: | |
os.dup2(a, b) | |
_dup2(p2cread, 0) | |
_dup2(c2pwrite, 1) | |
_dup2(errwrite, 2) | |
# Close pipe fds. Make sure we don't close the | |
# same fd more than once, or standard fds. | |
closed = { None } | |
for fd in [p2cread, c2pwrite, errwrite]: | |
if fd not in closed and fd > 2: | |
os.close(fd) | |
closed.add(fd) | |
if cwd is not None: | |
os.chdir(cwd) | |
if preexec_fn: | |
preexec_fn() | |
# Close all other fds, if asked for - after | |
# preexec_fn(), which may open FDs. | |
if close_fds: | |
self._close_fds(but=errpipe_write) | |
if env is None: | |
os.execvp(executable, args) | |
else: | |
os.execvpe(executable, args, env) | |
except: | |
exc_type, exc_value, tb = sys.exc_info() | |
# Save the traceback and attach it to the exception object | |
exc_lines = traceback.format_exception(exc_type, | |
exc_value, | |
tb) | |
exc_value.child_traceback = ''.join(exc_lines) | |
os.write(errpipe_write, pickle.dumps(exc_value)) | |
# This exitcode won't be reported to applications, so it | |
# really doesn't matter what we return. | |
os._exit(255) | |
# Parent | |
if gc_was_enabled: | |
gc.enable() | |
finally: | |
# be sure the FD is closed no matter what | |
os.close(errpipe_write) | |
# Wait for exec to fail or succeed; possibly raising exception | |
# Exception limited to 1M | |
data = _eintr_retry_call(os.read, errpipe_read, 1048576) | |
finally: | |
if p2cread is not None and p2cwrite is not None: | |
_close_in_parent(p2cread) | |
if c2pwrite is not None and c2pread is not None: | |
_close_in_parent(c2pwrite) | |
if errwrite is not None and errread is not None: | |
_close_in_parent(errwrite) | |
# be sure the FD is closed no matter what | |
os.close(errpipe_read) | |
if data != "": | |
try: | |
_eintr_retry_call(os.waitpid, self.pid, 0) | |
except OSError as e: | |
if e.errno != errno.ECHILD: | |
raise | |
child_exception = pickle.loads(data) | |
> raise child_exception | |
E OSError: [Errno 2] No such file or directory | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:1335: OSError | |
TestDap.test_sha256sum[/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/bar.dap] | |
self = <test_dap.TestDap object at 0x112a22b10> | |
dap = '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/bar.dap' | |
@pytest.mark.parametrize('dap', glob.glob(dap_path('meta_only/*.dap'))) | |
def test_sha256sum(self, dap): | |
'''Check that sha256sum of the files is the same as sha256sum command does''' | |
> process = subprocess.Popen(['sha256sum', dap], stdout=subprocess.PIPE) | |
dapi/test_dap.py:539: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:710: in __init__ | |
errread, errwrite) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <subprocess.Popen object at 0x112a22d10> | |
args = ['sha256sum', '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/bar.dap'] | |
executable = 'sha256sum', preexec_fn = None, close_fds = False, cwd = None | |
env = None, universal_newlines = False, startupinfo = None, creationflags = 0 | |
shell = False, to_close = set([8]), p2cread = None, p2cwrite = None, c2pread = 8 | |
c2pwrite = 17, errread = None, errwrite = None | |
def _execute_child(self, args, executable, preexec_fn, close_fds, | |
cwd, env, universal_newlines, | |
startupinfo, creationflags, shell, to_close, | |
p2cread, p2cwrite, | |
c2pread, c2pwrite, | |
errread, errwrite): | |
"""Execute program (POSIX version)""" | |
if isinstance(args, types.StringTypes): | |
args = [args] | |
else: | |
args = list(args) | |
if shell: | |
args = ["/bin/sh", "-c"] + args | |
if executable: | |
args[0] = executable | |
if executable is None: | |
executable = args[0] | |
def _close_in_parent(fd): | |
os.close(fd) | |
to_close.remove(fd) | |
# For transferring possible exec failure from child to parent | |
# The first char specifies the exception type: 0 means | |
# OSError, 1 means some other error. | |
errpipe_read, errpipe_write = self.pipe_cloexec() | |
try: | |
try: | |
gc_was_enabled = gc.isenabled() | |
# Disable gc to avoid bug where gc -> file_dealloc -> | |
# write to stderr -> hang. http://bugs.python.org/issue1336 | |
gc.disable() | |
try: | |
self.pid = os.fork() | |
except: | |
if gc_was_enabled: | |
gc.enable() | |
raise | |
self._child_created = True | |
if self.pid == 0: | |
# Child | |
try: | |
# Close parent's pipe ends | |
if p2cwrite is not None: | |
os.close(p2cwrite) | |
if c2pread is not None: | |
os.close(c2pread) | |
if errread is not None: | |
os.close(errread) | |
os.close(errpipe_read) | |
# When duping fds, if there arises a situation | |
# where one of the fds is either 0, 1 or 2, it | |
# is possible that it is overwritten (#12607). | |
if c2pwrite == 0: | |
c2pwrite = os.dup(c2pwrite) | |
if errwrite == 0 or errwrite == 1: | |
errwrite = os.dup(errwrite) | |
# Dup fds for child | |
def _dup2(a, b): | |
# dup2() removes the CLOEXEC flag but | |
# we must do it ourselves if dup2() | |
# would be a no-op (issue #10806). | |
if a == b: | |
self._set_cloexec_flag(a, False) | |
elif a is not None: | |
os.dup2(a, b) | |
_dup2(p2cread, 0) | |
_dup2(c2pwrite, 1) | |
_dup2(errwrite, 2) | |
# Close pipe fds. Make sure we don't close the | |
# same fd more than once, or standard fds. | |
closed = { None } | |
for fd in [p2cread, c2pwrite, errwrite]: | |
if fd not in closed and fd > 2: | |
os.close(fd) | |
closed.add(fd) | |
if cwd is not None: | |
os.chdir(cwd) | |
if preexec_fn: | |
preexec_fn() | |
# Close all other fds, if asked for - after | |
# preexec_fn(), which may open FDs. | |
if close_fds: | |
self._close_fds(but=errpipe_write) | |
if env is None: | |
os.execvp(executable, args) | |
else: | |
os.execvpe(executable, args, env) | |
except: | |
exc_type, exc_value, tb = sys.exc_info() | |
# Save the traceback and attach it to the exception object | |
exc_lines = traceback.format_exception(exc_type, | |
exc_value, | |
tb) | |
exc_value.child_traceback = ''.join(exc_lines) | |
os.write(errpipe_write, pickle.dumps(exc_value)) | |
# This exitcode won't be reported to applications, so it | |
# really doesn't matter what we return. | |
os._exit(255) | |
# Parent | |
if gc_was_enabled: | |
gc.enable() | |
finally: | |
# be sure the FD is closed no matter what | |
os.close(errpipe_write) | |
# Wait for exec to fail or succeed; possibly raising exception | |
# Exception limited to 1M | |
data = _eintr_retry_call(os.read, errpipe_read, 1048576) | |
finally: | |
if p2cread is not None and p2cwrite is not None: | |
_close_in_parent(p2cread) | |
if c2pwrite is not None and c2pread is not None: | |
_close_in_parent(c2pwrite) | |
if errwrite is not None and errread is not None: | |
_close_in_parent(errwrite) | |
# be sure the FD is closed no matter what | |
os.close(errpipe_read) | |
if data != "": | |
try: | |
_eintr_retry_call(os.waitpid, self.pid, 0) | |
except OSError as e: | |
if e.errno != errno.ECHILD: | |
raise | |
child_exception = pickle.loads(data) | |
> raise child_exception | |
E OSError: [Errno 2] No such file or directory | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:1335: OSError | |
TestDap.test_sha256sum[/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/common_args-0.0.1.dap] | |
self = <test_dap.TestDap object at 0x112c3d810> | |
dap = '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/common_args-0.0.1.dap' | |
@pytest.mark.parametrize('dap', glob.glob(dap_path('meta_only/*.dap'))) | |
def test_sha256sum(self, dap): | |
'''Check that sha256sum of the files is the same as sha256sum command does''' | |
> process = subprocess.Popen(['sha256sum', dap], stdout=subprocess.PIPE) | |
dapi/test_dap.py:539: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:710: in __init__ | |
errread, errwrite) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <subprocess.Popen object at 0x112c6a350> | |
args = ['sha256sum', '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/common_args-0.0.1.dap'] | |
executable = 'sha256sum', preexec_fn = None, close_fds = False, cwd = None | |
env = None, universal_newlines = False, startupinfo = None, creationflags = 0 | |
shell = False, to_close = set([8]), p2cread = None, p2cwrite = None, c2pread = 8 | |
c2pwrite = 17, errread = None, errwrite = None | |
def _execute_child(self, args, executable, preexec_fn, close_fds, | |
cwd, env, universal_newlines, | |
startupinfo, creationflags, shell, to_close, | |
p2cread, p2cwrite, | |
c2pread, c2pwrite, | |
errread, errwrite): | |
"""Execute program (POSIX version)""" | |
if isinstance(args, types.StringTypes): | |
args = [args] | |
else: | |
args = list(args) | |
if shell: | |
args = ["/bin/sh", "-c"] + args | |
if executable: | |
args[0] = executable | |
if executable is None: | |
executable = args[0] | |
def _close_in_parent(fd): | |
os.close(fd) | |
to_close.remove(fd) | |
# For transferring possible exec failure from child to parent | |
# The first char specifies the exception type: 0 means | |
# OSError, 1 means some other error. | |
errpipe_read, errpipe_write = self.pipe_cloexec() | |
try: | |
try: | |
gc_was_enabled = gc.isenabled() | |
# Disable gc to avoid bug where gc -> file_dealloc -> | |
# write to stderr -> hang. http://bugs.python.org/issue1336 | |
gc.disable() | |
try: | |
self.pid = os.fork() | |
except: | |
if gc_was_enabled: | |
gc.enable() | |
raise | |
self._child_created = True | |
if self.pid == 0: | |
# Child | |
try: | |
# Close parent's pipe ends | |
if p2cwrite is not None: | |
os.close(p2cwrite) | |
if c2pread is not None: | |
os.close(c2pread) | |
if errread is not None: | |
os.close(errread) | |
os.close(errpipe_read) | |
# When duping fds, if there arises a situation | |
# where one of the fds is either 0, 1 or 2, it | |
# is possible that it is overwritten (#12607). | |
if c2pwrite == 0: | |
c2pwrite = os.dup(c2pwrite) | |
if errwrite == 0 or errwrite == 1: | |
errwrite = os.dup(errwrite) | |
# Dup fds for child | |
def _dup2(a, b): | |
# dup2() removes the CLOEXEC flag but | |
# we must do it ourselves if dup2() | |
# would be a no-op (issue #10806). | |
if a == b: | |
self._set_cloexec_flag(a, False) | |
elif a is not None: | |
os.dup2(a, b) | |
_dup2(p2cread, 0) | |
_dup2(c2pwrite, 1) | |
_dup2(errwrite, 2) | |
# Close pipe fds. Make sure we don't close the | |
# same fd more than once, or standard fds. | |
closed = { None } | |
for fd in [p2cread, c2pwrite, errwrite]: | |
if fd not in closed and fd > 2: | |
os.close(fd) | |
closed.add(fd) | |
if cwd is not None: | |
os.chdir(cwd) | |
if preexec_fn: | |
preexec_fn() | |
# Close all other fds, if asked for - after | |
# preexec_fn(), which may open FDs. | |
if close_fds: | |
self._close_fds(but=errpipe_write) | |
if env is None: | |
os.execvp(executable, args) | |
else: | |
os.execvpe(executable, args, env) | |
except: | |
exc_type, exc_value, tb = sys.exc_info() | |
# Save the traceback and attach it to the exception object | |
exc_lines = traceback.format_exception(exc_type, | |
exc_value, | |
tb) | |
exc_value.child_traceback = ''.join(exc_lines) | |
os.write(errpipe_write, pickle.dumps(exc_value)) | |
# This exitcode won't be reported to applications, so it | |
# really doesn't matter what we return. | |
os._exit(255) | |
# Parent | |
if gc_was_enabled: | |
gc.enable() | |
finally: | |
# be sure the FD is closed no matter what | |
os.close(errpipe_write) | |
# Wait for exec to fail or succeed; possibly raising exception | |
# Exception limited to 1M | |
data = _eintr_retry_call(os.read, errpipe_read, 1048576) | |
finally: | |
if p2cread is not None and p2cwrite is not None: | |
_close_in_parent(p2cread) | |
if c2pwrite is not None and c2pread is not None: | |
_close_in_parent(c2pwrite) | |
if errwrite is not None and errread is not None: | |
_close_in_parent(errwrite) | |
# be sure the FD is closed no matter what | |
os.close(errpipe_read) | |
if data != "": | |
try: | |
_eintr_retry_call(os.waitpid, self.pid, 0) | |
except OSError as e: | |
if e.errno != errno.ECHILD: | |
raise | |
child_exception = pickle.loads(data) | |
> raise child_exception | |
E OSError: [Errno 2] No such file or directory | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:1335: OSError | |
TestDap.test_sha256sum[/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/foo-1.0.0.dap] | |
self = <test_dap.TestDap object at 0x112c92650> | |
dap = '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/foo-1.0.0.dap' | |
@pytest.mark.parametrize('dap', glob.glob(dap_path('meta_only/*.dap'))) | |
def test_sha256sum(self, dap): | |
'''Check that sha256sum of the files is the same as sha256sum command does''' | |
> process = subprocess.Popen(['sha256sum', dap], stdout=subprocess.PIPE) | |
dapi/test_dap.py:539: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:710: in __init__ | |
errread, errwrite) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <subprocess.Popen object at 0x112c9e2d0> | |
args = ['sha256sum', '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/foo-1.0.0.dap'] | |
executable = 'sha256sum', preexec_fn = None, close_fds = False, cwd = None | |
env = None, universal_newlines = False, startupinfo = None, creationflags = 0 | |
shell = False, to_close = set([8]), p2cread = None, p2cwrite = None, c2pread = 8 | |
c2pwrite = 17, errread = None, errwrite = None | |
def _execute_child(self, args, executable, preexec_fn, close_fds, | |
cwd, env, universal_newlines, | |
startupinfo, creationflags, shell, to_close, | |
p2cread, p2cwrite, | |
c2pread, c2pwrite, | |
errread, errwrite): | |
"""Execute program (POSIX version)""" | |
if isinstance(args, types.StringTypes): | |
args = [args] | |
else: | |
args = list(args) | |
if shell: | |
args = ["/bin/sh", "-c"] + args | |
if executable: | |
args[0] = executable | |
if executable is None: | |
executable = args[0] | |
def _close_in_parent(fd): | |
os.close(fd) | |
to_close.remove(fd) | |
# For transferring possible exec failure from child to parent | |
# The first char specifies the exception type: 0 means | |
# OSError, 1 means some other error. | |
errpipe_read, errpipe_write = self.pipe_cloexec() | |
try: | |
try: | |
gc_was_enabled = gc.isenabled() | |
# Disable gc to avoid bug where gc -> file_dealloc -> | |
# write to stderr -> hang. http://bugs.python.org/issue1336 | |
gc.disable() | |
try: | |
self.pid = os.fork() | |
except: | |
if gc_was_enabled: | |
gc.enable() | |
raise | |
self._child_created = True | |
if self.pid == 0: | |
# Child | |
try: | |
# Close parent's pipe ends | |
if p2cwrite is not None: | |
os.close(p2cwrite) | |
if c2pread is not None: | |
os.close(c2pread) | |
if errread is not None: | |
os.close(errread) | |
os.close(errpipe_read) | |
# When duping fds, if there arises a situation | |
# where one of the fds is either 0, 1 or 2, it | |
# is possible that it is overwritten (#12607). | |
if c2pwrite == 0: | |
c2pwrite = os.dup(c2pwrite) | |
if errwrite == 0 or errwrite == 1: | |
errwrite = os.dup(errwrite) | |
# Dup fds for child | |
def _dup2(a, b): | |
# dup2() removes the CLOEXEC flag but | |
# we must do it ourselves if dup2() | |
# would be a no-op (issue #10806). | |
if a == b: | |
self._set_cloexec_flag(a, False) | |
elif a is not None: | |
os.dup2(a, b) | |
_dup2(p2cread, 0) | |
_dup2(c2pwrite, 1) | |
_dup2(errwrite, 2) | |
# Close pipe fds. Make sure we don't close the | |
# same fd more than once, or standard fds. | |
closed = { None } | |
for fd in [p2cread, c2pwrite, errwrite]: | |
if fd not in closed and fd > 2: | |
os.close(fd) | |
closed.add(fd) | |
if cwd is not None: | |
os.chdir(cwd) | |
if preexec_fn: | |
preexec_fn() | |
# Close all other fds, if asked for - after | |
# preexec_fn(), which may open FDs. | |
if close_fds: | |
self._close_fds(but=errpipe_write) | |
if env is None: | |
os.execvp(executable, args) | |
else: | |
os.execvpe(executable, args, env) | |
except: | |
exc_type, exc_value, tb = sys.exc_info() | |
# Save the traceback and attach it to the exception object | |
exc_lines = traceback.format_exception(exc_type, | |
exc_value, | |
tb) | |
exc_value.child_traceback = ''.join(exc_lines) | |
os.write(errpipe_write, pickle.dumps(exc_value)) | |
# This exitcode won't be reported to applications, so it | |
# really doesn't matter what we return. | |
os._exit(255) | |
# Parent | |
if gc_was_enabled: | |
gc.enable() | |
finally: | |
# be sure the FD is closed no matter what | |
os.close(errpipe_write) | |
# Wait for exec to fail or succeed; possibly raising exception | |
# Exception limited to 1M | |
data = _eintr_retry_call(os.read, errpipe_read, 1048576) | |
finally: | |
if p2cread is not None and p2cwrite is not None: | |
_close_in_parent(p2cread) | |
if c2pwrite is not None and c2pread is not None: | |
_close_in_parent(c2pwrite) | |
if errwrite is not None and errread is not None: | |
_close_in_parent(errwrite) | |
# be sure the FD is closed no matter what | |
os.close(errpipe_read) | |
if data != "": | |
try: | |
_eintr_retry_call(os.waitpid, self.pid, 0) | |
except OSError as e: | |
if e.errno != errno.ECHILD: | |
raise | |
child_exception = pickle.loads(data) | |
> raise child_exception | |
E OSError: [Errno 2] No such file or directory | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:1335: OSError | |
TestDap.test_sha256sum[/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/foo.dap] | |
self = <test_dap.TestDap object at 0x112da1b50> | |
dap = '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/foo.dap' | |
@pytest.mark.parametrize('dap', glob.glob(dap_path('meta_only/*.dap'))) | |
def test_sha256sum(self, dap): | |
'''Check that sha256sum of the files is the same as sha256sum command does''' | |
> process = subprocess.Popen(['sha256sum', dap], stdout=subprocess.PIPE) | |
dapi/test_dap.py:539: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:710: in __init__ | |
errread, errwrite) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <subprocess.Popen object at 0x112da1f10> | |
args = ['sha256sum', '/Users/churchyard/Documents/devassistant/test/fixtures/dapi/daps/meta_only/foo.dap'] | |
executable = 'sha256sum', preexec_fn = None, close_fds = False, cwd = None | |
env = None, universal_newlines = False, startupinfo = None, creationflags = 0 | |
shell = False, to_close = set([8]), p2cread = None, p2cwrite = None, c2pread = 8 | |
c2pwrite = 17, errread = None, errwrite = None | |
def _execute_child(self, args, executable, preexec_fn, close_fds, | |
cwd, env, universal_newlines, | |
startupinfo, creationflags, shell, to_close, | |
p2cread, p2cwrite, | |
c2pread, c2pwrite, | |
errread, errwrite): | |
"""Execute program (POSIX version)""" | |
if isinstance(args, types.StringTypes): | |
args = [args] | |
else: | |
args = list(args) | |
if shell: | |
args = ["/bin/sh", "-c"] + args | |
if executable: | |
args[0] = executable | |
if executable is None: | |
executable = args[0] | |
def _close_in_parent(fd): | |
os.close(fd) | |
to_close.remove(fd) | |
# For transferring possible exec failure from child to parent | |
# The first char specifies the exception type: 0 means | |
# OSError, 1 means some other error. | |
errpipe_read, errpipe_write = self.pipe_cloexec() | |
try: | |
try: | |
gc_was_enabled = gc.isenabled() | |
# Disable gc to avoid bug where gc -> file_dealloc -> | |
# write to stderr -> hang. http://bugs.python.org/issue1336 | |
gc.disable() | |
try: | |
self.pid = os.fork() | |
except: | |
if gc_was_enabled: | |
gc.enable() | |
raise | |
self._child_created = True | |
if self.pid == 0: | |
# Child | |
try: | |
# Close parent's pipe ends | |
if p2cwrite is not None: | |
os.close(p2cwrite) | |
if c2pread is not None: | |
os.close(c2pread) | |
if errread is not None: | |
os.close(errread) | |
os.close(errpipe_read) | |
# When duping fds, if there arises a situation | |
# where one of the fds is either 0, 1 or 2, it | |
# is possible that it is overwritten (#12607). | |
if c2pwrite == 0: | |
c2pwrite = os.dup(c2pwrite) | |
if errwrite == 0 or errwrite == 1: | |
errwrite = os.dup(errwrite) | |
# Dup fds for child | |
def _dup2(a, b): | |
# dup2() removes the CLOEXEC flag but | |
# we must do it ourselves if dup2() | |
# would be a no-op (issue #10806). | |
if a == b: | |
self._set_cloexec_flag(a, False) | |
elif a is not None: | |
os.dup2(a, b) | |
_dup2(p2cread, 0) | |
_dup2(c2pwrite, 1) | |
_dup2(errwrite, 2) | |
# Close pipe fds. Make sure we don't close the | |
# same fd more than once, or standard fds. | |
closed = { None } | |
for fd in [p2cread, c2pwrite, errwrite]: | |
if fd not in closed and fd > 2: | |
os.close(fd) | |
closed.add(fd) | |
if cwd is not None: | |
os.chdir(cwd) | |
if preexec_fn: | |
preexec_fn() | |
# Close all other fds, if asked for - after | |
# preexec_fn(), which may open FDs. | |
if close_fds: | |
self._close_fds(but=errpipe_write) | |
if env is None: | |
os.execvp(executable, args) | |
else: | |
os.execvpe(executable, args, env) | |
except: | |
exc_type, exc_value, tb = sys.exc_info() | |
# Save the traceback and attach it to the exception object | |
exc_lines = traceback.format_exception(exc_type, | |
exc_value, | |
tb) | |
exc_value.child_traceback = ''.join(exc_lines) | |
os.write(errpipe_write, pickle.dumps(exc_value)) | |
# This exitcode won't be reported to applications, so it | |
# really doesn't matter what we return. | |
os._exit(255) | |
# Parent | |
if gc_was_enabled: | |
gc.enable() | |
finally: | |
# be sure the FD is closed no matter what | |
os.close(errpipe_write) | |
# Wait for exec to fail or succeed; possibly raising exception | |
# Exception limited to 1M | |
data = _eintr_retry_call(os.read, errpipe_read, 1048576) | |
finally: | |
if p2cread is not None and p2cwrite is not None: | |
_close_in_parent(p2cread) | |
if c2pwrite is not None and c2pread is not None: | |
_close_in_parent(c2pwrite) | |
if errwrite is not None and errread is not None: | |
_close_in_parent(errwrite) | |
# be sure the FD is closed no matter what | |
os.close(errpipe_read) | |
if data != "": | |
try: | |
_eintr_retry_call(os.waitpid, self.pid, 0) | |
except OSError as e: | |
if e.errno != errno.ECHILD: | |
raise | |
child_exception = pickle.loads(data) | |
> raise child_exception | |
E OSError: [Errno 2] No such file or directory | |
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py:1335: OSError | |
======== 8 failed, 901 passed, 2 skipped, 8 warnings in 105.69 seconds ========= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment