Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / chromedriver / chrome_paths.py
blob58c4d3ee1a80a80ce8e0f7275c3f89d773616fee
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Paths to common resources in the Chrome repository."""
7 import os
10 _THIS_DIR = os.path.abspath(os.path.dirname(__file__))
13 def GetSrc():
14 """Returns the path to the root src directory."""
15 return os.path.abspath(os.path.join(_THIS_DIR, os.pardir, os.pardir,
16 os.pardir))
19 def GetTestData():
20 """Returns the path to the src/chrome/test/data directory."""
21 return os.path.join(GetSrc(), 'chrome', 'test', 'data')
24 def GetBuildDir(required_paths):
25 """Returns the preferred build directory that contains given paths."""
26 dirs = ['out', 'build', 'xcodebuild']
27 rel_dirs = [os.path.join(x, 'Release') for x in dirs]
28 debug_dirs = [os.path.join(x, 'Debug') for x in dirs]
29 full_dirs = [os.path.join(GetSrc(), x) for x in rel_dirs + debug_dirs]
30 for build_dir in full_dirs:
31 for required_path in required_paths:
32 if not os.path.exists(os.path.join(build_dir, required_path)):
33 break
34 else:
35 return build_dir
36 raise RuntimeError('Cannot find build directory containing ' +
37 ', '.join(required_paths))