Commit 75ff3b31 authored by dtu@chromium.org's avatar dtu@chromium.org

[telemetry] Define benchmark page sets in relation to base directory.

If you ran run_benchmark from different directories, it would be unable to find the page set.


BUG=263511
TEST=None.
R=tonyg@chromium.org

Review URL: https://chromiumcodereview.appspot.com/19597010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213352 0039d316-1c4b-4281-b951-d872f2087c98
parent 9cad1d5f
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import sys
from telemetry.page import page_runner
from telemetry.page import page_set
from telemetry.page import test_expectations
from telemetry.page import page_test
def GetBaseDir():
main_module = sys.modules['__main__']
if hasattr(main_module, '__file__'):
return os.path.dirname(main_module.__file__)
else:
return os.getcwd()
class Test(object):
"""Base class for a Telemetry test or benchmark.
......@@ -38,7 +49,7 @@ class Test(object):
page_set attribute. Override to generate a custom page set.
"""
assert hasattr(self, 'page_set'), 'This test has no "page_set" attribute.'
return page_set.PageSet.FromFile(self.page_set)
return page_set.PageSet.FromFile(os.path.join(GetBaseDir(), self.page_set))
def CreateExpectations(self, ps): # pylint: disable=W0613
"""Get the expectations this test will run with.
......
......@@ -117,18 +117,10 @@ def _GetScriptName():
return os.path.basename(sys.argv[0])
def _GetBaseDir():
main_module = sys.modules['__main__']
if hasattr(main_module, '__file__'):
return os.path.dirname(main_module.__file__)
else:
return os.getcwd()
def _GetTests():
# Lazy load and cache results.
if not hasattr(_GetTests, 'tests'):
base_dir = _GetBaseDir()
base_dir = test.GetBaseDir()
_GetTests.tests = discover.DiscoverClasses(base_dir, base_dir, test.Test,
index_by_class_name=True)
return _GetTests.tests
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment