Don't use preexec_fn on Windows

Issue #21 resolved
Anonymous created an issue

Hi, commit 50957c109dc2 made cram usable for me on Windows, by adding the --shell parameter to the script. This way I can run cram tests using the bash.exe that comes with git-bash if I provide the path.

Unfortunately, commit 8f15beaf3a8d, uses the preexec_fn argument to subprocess.Popen which causes an error on windows. Since Popen checks for sys.platform == 'win32' before throwing the error, cram can avoid the error with something like:

{{{ diff -r 8f15beaf3a8d --- a/ Thu Apr 14 23:54:17 2011 -0700 +++ b/ Thu Apr 19 18:05:47 2012 +0100 @@ -170,10 +170,14 @@ def test(path, indent=2, shell='/bin/sh' abspath = os.path.abspath(path) env = os.environ.copy() env['TESTDIR'] = os.path.dirname(abspath) + if sys.platform != "win32": + preexec_fn = resetsigpipe + else: + preexec_fn = None p = subprocess.Popen([shell, '-'], bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, env=env, - preexec_fn=resetsigpipe, + preexec_fn=preexec_fn, == 'posix') salt = 'CRAM%s' % time.time() }}}

Thanks, Oscar Benjamin.

Comments (2)

  1. Brodie Rao repo owner

    Can you copy and paste the exact error you get on Windows? If it's something like AttributeError: 'module' has no attribute 'SIGPIPE', we should probably test that that exists instead of checking sys.platform.

  2. Log in to comment