Commit 932c9b2f authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Switch GPU Gold heuristic

Switches the heuristic that GPU Gold tests use to determine if they're
running on a workstation or not. Previously, it checked for the presence
of a git repository, but is now checking for the presence of the
SWARMING_SERVER environment variable. This is the heuristic that will
be used in other test types as they get switched to use Gold.

Also removes the RunInChromiumSrc context manager that was being used to
run the git commands, as it's simpler to just pass cwd to subprocess.

Change-Id: If1b2fdf2ebda355319359d80017b25e24bb07d0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033637Reviewed-by: default avatarYuly Novikov <ynovikov@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737528}
parent d317721d
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import contextlib
from datetime import date from datetime import date
import json import json
import logging import logging
...@@ -42,16 +41,6 @@ SKIA_GOLD_INSTANCE = 'chrome-gpu' ...@@ -42,16 +41,6 @@ SKIA_GOLD_INSTANCE = 'chrome-gpu'
SKIA_GOLD_CORPUS = SKIA_GOLD_INSTANCE SKIA_GOLD_CORPUS = SKIA_GOLD_INSTANCE
@contextlib.contextmanager
def RunInChromiumSrc():
old_cwd = os.getcwd()
os.chdir(path_util.GetChromiumSrcDir())
try:
yield
finally:
os.chdir(old_cwd)
# This is mainly used to determine if we need to run a subprocess through the # This is mainly used to determine if we need to run a subprocess through the
# shell - on Windows, finding executables via PATH doesn't work properly unless # shell - on Windows, finding executables via PATH doesn't work properly unless
# run through the shell. # run through the shell.
...@@ -556,19 +545,16 @@ class SkiaGoldIntegrationTestBase(gpu_integration_test.GpuIntegrationTest): ...@@ -556,19 +545,16 @@ class SkiaGoldIntegrationTestBase(gpu_integration_test.GpuIntegrationTest):
# Use the --local-run value if it's been set. # Use the --local-run value if it's been set.
elif cls.GetParsedCommandLineOptions().local_run is not None: elif cls.GetParsedCommandLineOptions().local_run is not None:
cls._local_run = cls.GetParsedCommandLineOptions().local_run cls._local_run = cls.GetParsedCommandLineOptions().local_run
# Look for the presence of a git repo as a heuristic to determine whether # Look for the presence of the SWARMING_SERVER environment variable as a
# we're running on a workstation or a bot. # heuristic to determine whether we're running on a workstation or a bot.
else: # This should always be set on swarming, but would be strange to be set on
with RunInChromiumSrc(): # a workstation.
try: cls._local_run = 'SWARMING_SERVER' not in os.environ
subprocess.check_output(['git', 'status'], shell=IsWin()) if cls._local_run:
logging.warning( logging.warning(
'Automatically determined that test is running on a workstation') 'Automatically determined that test is running on a workstation')
cls._local_run = True else:
except subprocess.CalledProcessError: logging.warning('Automatically determined that test is running on a bot')
logging.warning(
'Automatically determined that test is running on a bot')
cls._local_run = False
return cls._local_run return cls._local_run
@classmethod @classmethod
...@@ -582,15 +568,16 @@ class SkiaGoldIntegrationTestBase(gpu_integration_test.GpuIntegrationTest): ...@@ -582,15 +568,16 @@ class SkiaGoldIntegrationTestBase(gpu_integration_test.GpuIntegrationTest):
cls._build_revision = cls.GetParsedCommandLineOptions().build_revision cls._build_revision = cls.GetParsedCommandLineOptions().build_revision
# Try to determine what revision we're on using git. # Try to determine what revision we're on using git.
else: else:
with RunInChromiumSrc(): try:
try: cls._build_revision = subprocess.check_output(
cls._build_revision = subprocess.check_output( ['git', 'rev-parse', 'origin/master'],
['git', 'rev-parse', 'origin/master'], shell=IsWin()).strip() shell=IsWin(),
logging.warning('Automatically determined build revision to be %s', cwd=path_util.GetChromiumSrcDir()).strip()
cls._build_revision) logging.warning('Automatically determined build revision to be %s',
except subprocess.CalledProcessError: cls._build_revision)
raise Exception('--build-revision not passed, and unable to ' except subprocess.CalledProcessError:
'determine revision using git') raise Exception('--build-revision not passed, and unable to '
'determine revision using git')
return cls._build_revision return cls._build_revision
@classmethod @classmethod
......
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