def _RunGpuIntegrationTests(self, test_name, extra_args=None): extra_args = extra_args or [] unittest_config = chromium_config.ChromiumConfig( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[ os.path.join(path_util.GetGpuTestDir(), 'unittest_data') ]) with binary_manager.TemporarilyReplaceBinaryManager(None), \ mock.patch.object(gpu_project_config, 'CONFIG', unittest_config): # TODO(crbug.com/1103792): Using NamedTemporaryFile() as a generator is # causing windows bots to fail. When the issue is fixed with # tempfile_ext.NamedTemporaryFile(), put it in the list of generators # starting this with block. Also remove the try finally statement # below. temp_file = tempfile.NamedTemporaryFile(delete=False) temp_file.close() try: test_argv = [ test_name, '--write-full-results-to=%s' % temp_file.name ] + extra_args processed_args = run_gpu_integration_test.ProcessArgs(test_argv) telemetry_args = browser_test_runner.ProcessConfig( unittest_config, processed_args) run_browser_tests.RunTests(telemetry_args) with open(temp_file.name) as f: self._test_result = json.load(f) finally: temp_file.close()
def _RunIntegrationTest(self, test_args): """Runs an integration and asserts fail/success/skip expectations. Args: test_args: A _IntegrationTestArgs instance to use. """ config = chromium_config.ChromiumConfig( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[ os.path.join(path_util.GetGpuTestDir(), 'unittest_data') ]) with binary_manager.TemporarilyReplaceBinaryManager(None), \ tempfile_ext.NamedTemporaryDirectory() as temp_dir: test_results_path = os.path.join(temp_dir, 'test_results.json') test_state_path = os.path.join(temp_dir, 'test_state.json') # We are processing ChromiumConfig instance and getting the argument # list. Then we pass it directly to run_browser_tests.RunTests. If # we called browser_test_runner.Run, then it would spawn another # subprocess which is less efficient. args = browser_test_runner.ProcessConfig(config, [ test_args.test_name, '--write-full-results-to=%s' % test_results_path, '--test-state-json-path=%s' % test_state_path ] + test_args.additional_args) run_browser_tests.RunTests(args) with open(test_results_path) as f: self._test_result = json.load(f) with open(test_state_path) as f: self._test_state = json.load(f) actual_successes, actual_failures, actual_skips = (_ExtractTestResults( self._test_result)) self.assertEquals(set(actual_failures), set(test_args.failures)) self.assertEquals(set(actual_successes), set(test_args.successes)) self.assertEquals(set(actual_skips), set(test_args.skips))
def _RunGpuIntegrationTests(self, test_name, extra_args=None): extra_args = extra_args or [] temp_file = tempfile.NamedTemporaryFile(delete=False) temp_file.close() test_argv = [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') ]) old_manager = binary_manager._binary_manager with mock.patch.object(gpu_project_config, 'CONFIG', unittest_config): processed_args = run_gpu_integration_test.ProcessArgs(test_argv) telemetry_args = browser_test_runner.ProcessConfig( unittest_config, processed_args) try: binary_manager._binary_manager = None run_browser_tests.RunTests(telemetry_args) with open(temp_file.name) as f: self._test_result = json.load(f) finally: binary_manager._binary_manager = old_manager temp_file.close()
def _RunIntegrationTest(self, test_name, failures, successes, skips, additional_args): config = chromium_config.ChromiumConfig( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[ os.path.join(path_util.GetGpuTestDir(), 'unittest_data') ]) temp_dir = tempfile.mkdtemp() test_results_path = os.path.join(temp_dir, 'test_results.json') test_state_path = os.path.join(temp_dir, 'test_state.json') try: browser_test_runner.Run(config, [ test_name, '--write-full-results-to=%s' % test_results_path, '--test-state-json-path=%s' % test_state_path ] + additional_args) with open(test_results_path) as f: self._test_result = json.load(f) with open(test_state_path) as f: self._test_state = json.load(f) actual_successes, actual_failures, actual_skips = ( _ExtractTestResults(self._test_result)) self.assertEquals(set(actual_failures), set(failures)) self.assertEquals(set(actual_successes), set(successes)) self.assertEquals(set(actual_skips), set(skips)) finally: shutil.rmtree(temp_dir)
def _RunGpuIntegrationTests(self, test_name, extra_args=None): 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( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[ os.path.join(path_util.GetGpuTestDir(), 'unittest_data')]) run_gpu_integration_test.main() with open(temp_file.name) as f: self._test_result = json.load(f) finally: temp_file.close()
def testTestNamePrefixGenerationInRunGpuIntegrationTests(self): temp_file = tempfile.NamedTemporaryFile(delete=False) temp_file.close() try: sys.argv = [ run_gpu_integration_test.__file__, 'simple_integration_unittest', '--write-full-results-to=%s' % temp_file.name ] gpu_project_config.CONFIG = chromium_config.ChromiumConfig( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[ os.path.join(path_util.GetGpuTestDir(), 'unittest_data') ]) run_gpu_integration_test.main() with open(temp_file.name) as f: results = json.load(f) self.assertIn('expected_failure', results['tests']) self.assertEqual(results['test_name_prefix'], 'unittest_data.integration_tests.SimpleTest.') finally: temp_file.close()
def _RunIntegrationTest(self, test_name, failures, successes, skips, additional_args): # pylint: disable=too-many-locals config = chromium_config.ChromiumConfig( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[ os.path.join(path_util.GetGpuTestDir(), 'unittest_data') ]) temp_dir = tempfile.mkdtemp() test_results_path = os.path.join(temp_dir, 'test_results.json') test_state_path = os.path.join(temp_dir, 'test_state.json') old_manager = binary_manager._binary_manager try: # TODO(crbug.com/1099856): Fix telemetry binary_manager API so that # we don't need to access its private global variable binary_manager._binary_manager = None # We are proccissing ChromiumConfig instance and getting the argument # list. Then we pass it directly to run_browser_tests.RunTests. If # we called browser_test_runner.Run, then it would spawn another # subprocess which is less efficient. args = browser_test_runner.ProcessConfig(config, [ test_name, '--write-full-results-to=%s' % test_results_path, '--test-state-json-path=%s' % test_state_path ] + additional_args) run_browser_tests.RunTests(args) with open(test_results_path) as f: self._test_result = json.load(f) with open(test_state_path) as f: self._test_state = json.load(f) actual_successes, actual_failures, actual_skips = ( _ExtractTestResults(self._test_result)) self.assertEquals(set(actual_failures), set(failures)) self.assertEquals(set(actual_successes), set(successes)) self.assertEquals(set(actual_skips), set(skips)) finally: binary_manager._binary_manager = old_manager shutil.rmtree(temp_dir)
path_util.AddDirToPathIfNeeded(path_util.GetChromiumSrcDir(), 'third_party', 'logilab') path_util.AddDirToPathIfNeeded(path_util.GetChromiumSrcDir(), 'third_party', 'logilab', 'logilab') path_util.AddDirToPathIfNeeded(path_util.GetChromiumSrcDir(), 'third_party', 'pylint') try: from pylint import lint except ImportError: lint = None _RC_FILE = os.path.join(path_util.GetGpuTestDir(), 'pylintrc') def LintCheckPassed(directory): args = [directory, '--rcfile=%s' % _RC_FILE] try: assert lint, 'pylint module cannot be found' lint.Run(args) assert False, ( 'This should not be reached as lint.Run always raise SystemExit') except SystemExit as err: if err.code == 0: return True return False
# Copyright 2015 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 from gpu_tests import path_util path_util.AddDirToPathIfNeeded(path_util.GetChromiumSrcDir(), 'tools', 'perf') from chrome_telemetry_build import chromium_config CONFIG = chromium_config.ChromiumConfig( top_level_dir=path_util.GetGpuTestDir(), benchmark_dirs=[os.path.join(path_util.GetGpuTestDir(), 'gpu_tests')])