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( ...@@ -53,15 +53,17 @@ def _GetSystemInfo(
def _GetTagsToTest(browser, test_class=None, args=None): def _GetTagsToTest(browser, test_class=None, args=None):
test_class = test_class or gpu_integration_test.GpuIntegrationTest test_class = test_class or gpu_integration_test.GpuIntegrationTest
tags = None
with mock.patch.object( with mock.patch.object(
test_class, 'ExpectationsFiles', return_value=['exp.txt']): test_class, 'ExpectationsFiles', return_value=['exp.txt']):
possible_browser = fakes.FakePossibleBrowser() possible_browser = fakes.FakePossibleBrowser()
possible_browser._returned_browser = browser possible_browser._returned_browser = browser
args = args or gpu_helper.GetMockArgs() 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): def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class, args):
tags = None
with mock.patch.object( with mock.patch.object(
test_class, 'ExpectationsFiles', return_value=['exp.txt']): test_class, 'ExpectationsFiles', return_value=['exp.txt']):
_ = [_ for _ in test_class.GenerateGpuTests(args)] _ = [_ for _ in test_class.GenerateGpuTests(args)]
...@@ -69,8 +71,8 @@ def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class, args): ...@@ -69,8 +71,8 @@ def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class, args):
browser = fakes.FakeBrowser(platform, 'release') browser = fakes.FakeBrowser(platform, 'release')
browser._returned_system_info = _GetSystemInfo( browser._returned_system_info = _GetSystemInfo(
gpu=VENDOR_NVIDIA, device=0x1cb3, gl_renderer='ANGLE Direct3D9') 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): class GpuIntegrationTestUnittest(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -81,21 +83,21 @@ class GpuIntegrationTestUnittest(unittest.TestCase): ...@@ -81,21 +83,21 @@ class GpuIntegrationTestUnittest(unittest.TestCase):
extra_args = extra_args or [] extra_args = extra_args or []
temp_file = tempfile.NamedTemporaryFile(delete=False) temp_file = tempfile.NamedTemporaryFile(delete=False)
temp_file.close() temp_file.close()
try: test_argv = [
sys.argv = [ run_gpu_integration_test.__file__, test_name,
run_gpu_integration_test.__file__, '--write-full-results-to=%s' % temp_file.name] + extra_args
test_name, unittest_config = chromium_config.ChromiumConfig(
'--write-full-results-to=%s' % temp_file.name, top_level_dir=path_util.GetGpuTestDir(),
] + extra_args benchmark_dirs=[
gpu_project_config.CONFIG = chromium_config.ChromiumConfig( os.path.join(path_util.GetGpuTestDir(), 'unittest_data')])
top_level_dir=path_util.GetGpuTestDir(), with mock.patch.object(sys, 'argv', test_argv):
benchmark_dirs=[ with mock.patch.object(gpu_project_config, 'CONFIG', unittest_config):
os.path.join(path_util.GetGpuTestDir(), 'unittest_data')]) try:
run_gpu_integration_test.main() run_gpu_integration_test.main()
with open(temp_file.name) as f: with open(temp_file.name) as f:
self._test_result = json.load(f) self._test_result = json.load(f)
finally: finally:
temp_file.close() temp_file.close()
def testOverrideDefaultRetryArgumentsinRunGpuIntegrationTests(self): def testOverrideDefaultRetryArgumentsinRunGpuIntegrationTests(self):
self._RunGpuIntegrationTests( self._RunGpuIntegrationTests(
......
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