Skip to content

Commit

Permalink
Fix PEP8 in maketest
Browse files Browse the repository at this point in the history
  • Loading branch information
richo committed Jan 27, 2015
1 parent 04408fa commit 58d03ad
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/etc/maketest.py
Expand Up @@ -12,13 +12,14 @@
import os
import sys

# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
# the value is list of paths.
# (if there is only one path, it becomes `c:/real/abs/path`.)
# this causes great confusion and error: shell and Makefile doesn't like
# windows paths so it is really error-prone. revert it for peace.

def normalize_path(v):
"""msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
`c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
the value is list of paths.
(if there is only one path, it becomes `c:/real/abs/path`.)
this causes great confusion and error: shell and Makefile doesn't like
windows paths so it is really error-prone. revert it for peace."""
v = v.replace('\\', '/')
# c:/path -> /c/path
if ':/' in v:
Expand All @@ -31,6 +32,7 @@ def putenv(name, value):
value = normalize_path(value)
os.putenv(name, value)


def convert_path_spec(name, value):
if os.name == 'nt' and name != 'PATH':
value = ":".join(normalize_path(v) for v in value.split(";"))
Expand All @@ -42,14 +44,14 @@ def convert_path_spec(name, value):
putenv('CC', sys.argv[5])
putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
filt = sys.argv[7]
putenv('LD_LIB_PATH_ENVVAR', sys.argv[8]);
putenv('HOST_RPATH_DIR', os.path.abspath(sys.argv[9]));
putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[10]));
putenv('LD_LIB_PATH_ENVVAR', sys.argv[8])
putenv('HOST_RPATH_DIR', os.path.abspath(sys.argv[9]))
putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[10]))
putenv('RUST_BUILD_STAGE', sys.argv[11])
putenv('S', os.path.abspath(sys.argv[12]))
putenv('PYTHON', sys.executable)

if not filt in sys.argv[1]:
if filt not in sys.argv[1]:
sys.exit(0)
print('maketest: ' + os.path.basename(os.path.dirname(sys.argv[1])))

Expand All @@ -63,19 +65,19 @@ def convert_path_spec(name, value):
path = path[:-1]

proc = subprocess.Popen([make, '-C', path],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = proc.communicate()
i = proc.wait()

if i != 0:

print '----- ' + sys.argv[1] + """ --------------------
print """\
----- %s --------------------
------ stdout ---------------------------------------------
""" + out + """
%s
------ stderr ---------------------------------------------
""" + err + """
%s
------ ---------------------------------------------
"""
sys.exit(i)
""" % (sys.argv[1], out, err)

sys.exit(i)

0 comments on commit 58d03ad

Please sign in to comment.