Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/isolate/isolate.py

Issue 9704001: Converts absolute paths in the command to relative path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix subtility in path handling with make Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/isolate/isolate_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/isolate/isolate.py
diff --git a/tools/isolate/isolate.py b/tools/isolate/isolate.py
index ae5b8f4060f8c477083c1c0df742c7b45f827945..29d883ed681f493bb4c3a76ef268516952551750 100755
--- a/tools/isolate/isolate.py
+++ b/tools/isolate/isolate.py
@@ -37,6 +37,16 @@ def relpath(path, root):
return out
+def to_relative(path, root, relative):
+ """Converts any absolute path to a relative path, only if under root."""
+ if path.startswith(root):
+ logging.info('%s starts with %s' % (path, root))
+ path = os.path.relpath(path, relative)
+ else:
+ logging.info('%s not under %s' % (path, root))
+ return path
+
+
def separate_inputs_command(args, root, files):
"""Strips off the command line from the inputs.
@@ -78,11 +88,15 @@ def isolate(outdir, resultfile, indir, infiles, mode, read_only, cmd):
# file from this directory is needed to run the test. Otherwise it won't be
# created and the process creation will fail. It's up to the caller to create
# this directory manually before starting the test.
- relative_cwd = os.path.relpath(os.getcwd(), indir)
+ cwd = os.getcwd()
+ relative_cwd = os.path.relpath(cwd, indir)
+
+ # Workaround make behavior of passing absolute paths.
+ cmd = [to_relative(i, indir, cwd) for i in cmd]
if not cmd:
# Note that it is exactly the reverse of relative_cwd.
- cmd = [os.path.join(os.path.relpath(indir, os.getcwd()), infiles[0])]
+ cmd = [os.path.join(os.path.relpath(indir, cwd), infiles[0])]
if cmd[0].endswith('.py'):
cmd.insert(0, sys.executable)
« no previous file with comments | « no previous file | tools/isolate/isolate_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698