Commit 581b116d authored by Rakib M. Hasan's avatar Rakib M. Hasan Committed by Commit Bot

_RunGpuIntegrationTests leaks state from one unit tests to the other

_RunGpuIntegrationTests permanently sets sys.argv and gpu_project_config.CONFIG to test values
for all tests. This is the state leak that is causing the test expectations conflict checker
to miss the conflict in pixel_tests_expectations.txt. Since gpu_project_config.CONFIG is set to
a test value, the start directories it contains are set to test values. Therefore the conflict
checker cannot find the PixelIntegrationTest class.

Bug: chromium:986538

Change-Id: I25e478fd95bbe42e63b11cdf7408e12ada345a9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1714147
Commit-Queue: Rakib Hasan <rmhasan@google.com>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680613}
parent d3f44365
......@@ -53,15 +53,17 @@ def _GetSystemInfo(
def _GetTagsToTest(browser, test_class=None, args=None):
test_class = test_class or gpu_integration_test.GpuIntegrationTest
tags = None
with mock.patch.object(
test_class, 'ExpectationsFiles', return_value=['exp.txt']):
possible_browser = fakes.FakePossibleBrowser()
possible_browser._returned_browser = browser
args = args or gpu_helper.GetMockArgs()
return set(test_class.GenerateTags(args, possible_browser))
tags = set(test_class.GenerateTags(args, possible_browser))
return tags
def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class, args):
tags = None
with mock.patch.object(
test_class, 'ExpectationsFiles', return_value=['exp.txt']):
_ = [_ for _ in test_class.GenerateGpuTests(args)]
......@@ -69,8 +71,8 @@ def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class, args):
browser = fakes.FakeBrowser(platform, 'release')
browser._returned_system_info = _GetSystemInfo(
gpu=VENDOR_NVIDIA, device=0x1cb3, gl_renderer='ANGLE Direct3D9')
return _GetTagsToTest(browser, test_class)
tags = _GetTagsToTest(browser, test_class)
return tags
class GpuIntegrationTestUnittest(unittest.TestCase):
def setUp(self):
......@@ -81,16 +83,16 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
extra_args = extra_args or []
temp_file = tempfile.NamedTemporaryFile(delete=False)
temp_file.close()
try:
sys.argv = [
run_gpu_integration_test.__file__,
test_name,
'--write-full-results-to=%s' % temp_file.name,
] + extra_args
gpu_project_config.CONFIG = chromium_config.ChromiumConfig(
test_argv = [
run_gpu_integration_test.__file__, test_name,
'--write-full-results-to=%s' % temp_file.name] + extra_args
unittest_config = chromium_config.ChromiumConfig(
top_level_dir=path_util.GetGpuTestDir(),
benchmark_dirs=[
os.path.join(path_util.GetGpuTestDir(), 'unittest_data')])
with mock.patch.object(sys, 'argv', test_argv):
with mock.patch.object(gpu_project_config, 'CONFIG', unittest_config):
try:
run_gpu_integration_test.main()
with open(temp_file.name) as f:
self._test_result = json.load(f)
......
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