Bug 1279020 - [mach] Follow symlinked mach binary when searching for a srcdir, r=gps
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 09 Jun 2016 17:20:02 -0400
changeset 303848 80eb5947da076120f095ac7dd6a32670032e0134
parent 303847 dd8ef51f4920c5f4370afd0aebf43d1113363fc3
child 303849 eb129a2466a9c3beae231ecb9f5f16be16382624
push id79199
push usergszorc@mozilla.com
push dateThu, 07 Jul 2016 01:27:06 +0000
treeherdermozilla-inbound@d666f37dfa89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1279020
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1279020 - [mach] Follow symlinked mach binary when searching for a srcdir, r=gps The mach binary needs to find a srcdir (or test zip) to operator on. As a last resort, it checks the directory containing the binary itself. If the binary has been symlinked to say, $HOME/bin, it won't follow the symlink to the proper location, and the check will fail. Fixing this means developers can run `mach` from outside of the srcdir, as the symlink will be followed to the actual srcdir. The motivation for this is actually to improve the UX of debugging failures on interactive workers. With this fix, we can provide developers with a mach environment directly from $HOME without them needing to go find it. MozReview-Commit-ID: ZEH8MuyKv
mach
--- a/mach
+++ b/mach
@@ -65,18 +65,19 @@ def get_mach():
                 # Continue searching for mach_bootstrap in the source directory.
                 dir_path = info['topsrcdir']
 
         mach = check_and_get_mach(dir_path)
         if mach:
             return mach
 
     # If we didn't find a source path by scanning for a mozinfo.json, check
-    # whether the directory containing this script is a source directory.
-    return check_and_get_mach(os.path.dirname(__file__))
+    # whether the directory containing this script is a source directory. We
+    # follow symlinks so mach can be run even if cwd is outside the srcdir.
+    return check_and_get_mach(os.path.dirname(os.path.realpath(__file__)))
 
 def main(args):
     mach = get_mach()
     if not mach:
         print('Could not run mach: No mach source directory found.')
         sys.exit(1)
     sys.exit(mach.run(args))