Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py

Issue 2143123004: Access environment variables through Host object instead of directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and updated after change for dummy home dir on linux. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 def num_workers(self, requested_num_workers): 1043 def num_workers(self, requested_num_workers):
1044 """Returns the number of available workers (possibly less than the numbe r requested).""" 1044 """Returns the number of available workers (possibly less than the numbe r requested)."""
1045 return requested_num_workers 1045 return requested_num_workers
1046 1046
1047 def clean_up_test_run(self): 1047 def clean_up_test_run(self):
1048 """Perform port-specific work at the end of a test run.""" 1048 """Perform port-specific work at the end of a test run."""
1049 if self._image_differ: 1049 if self._image_differ:
1050 self._image_differ.stop() 1050 self._image_differ.stop()
1051 self._image_differ = None 1051 self._image_differ = None
1052 1052
1053 # FIXME: os.environ access should be moved to onto a common/system class to be more easily mockable.
1054 def _value_or_default_from_environ(self, name, default=None):
1055 if name in os.environ:
1056 return os.environ[name]
1057 return default
1058
1059 def _copy_value_from_environ_if_set(self, clean_env, name):
1060 if name in os.environ:
1061 clean_env[name] = os.environ[name]
1062
1063 def setup_environ_for_server(self): 1053 def setup_environ_for_server(self):
1064 # We intentionally copy only a subset of os.environ when 1054 # We intentionally copy only a subset of the environment when
1065 # launching subprocesses to ensure consistent test results. 1055 # launching subprocesses to ensure consistent test results.
1066 clean_env = { 1056 clean_env = {
1067 'LOCAL_RESOURCE_ROOT': self.layout_tests_dir(), # FIXME: Is this us ed? 1057 'LOCAL_RESOURCE_ROOT': self.layout_tests_dir(), # FIXME: Is this us ed?
1068 } 1058 }
1069 variables_to_copy = [ 1059 variables_to_copy = [
1070 'WEBKIT_TESTFONTS', # FIXME: Is this still used? 1060 'WEBKIT_TESTFONTS', # FIXME: Is this still used?
1071 'WEBKITOUTPUTDIR', # FIXME: Is this still used? 1061 'WEBKITOUTPUTDIR', # FIXME: Is this still used?
1072 'CHROME_DEVEL_SANDBOX', 1062 'CHROME_DEVEL_SANDBOX',
1073 'CHROME_IPC_LOGGING', 1063 'CHROME_IPC_LOGGING',
1074 'ASAN_OPTIONS', 1064 'ASAN_OPTIONS',
1075 'TSAN_OPTIONS', 1065 'TSAN_OPTIONS',
1076 'MSAN_OPTIONS', 1066 'MSAN_OPTIONS',
1077 'LSAN_OPTIONS', 1067 'LSAN_OPTIONS',
1078 'UBSAN_OPTIONS', 1068 'UBSAN_OPTIONS',
1079 'VALGRIND_LIB', 1069 'VALGRIND_LIB',
1080 'VALGRIND_LIB_INNER', 1070 'VALGRIND_LIB_INNER',
1081 ] 1071 ]
1082 if self.host.platform.is_linux() or self.host.platform.is_freebsd(): 1072 if self.host.platform.is_linux() or self.host.platform.is_freebsd():
1083 variables_to_copy += [ 1073 variables_to_copy += [
1084 'XAUTHORITY', 1074 'XAUTHORITY',
1085 'HOME', 1075 'HOME',
1086 'LANG', 1076 'LANG',
1087 'LD_LIBRARY_PATH', 1077 'LD_LIBRARY_PATH',
1088 'DBUS_SESSION_BUS_ADDRESS', 1078 'DBUS_SESSION_BUS_ADDRESS',
1089 'XDG_DATA_DIRS', 1079 'XDG_DATA_DIRS',
1090 ] 1080 ]
1091 clean_env['DISPLAY'] = self._value_or_default_from_environ('DISPLAY' , ':1') 1081 clean_env['DISPLAY'] = self.host.environ.get('DISPLAY', ':1')
1092 if self.host.platform.is_mac(): 1082 if self.host.platform.is_mac():
1093 clean_env['DYLD_LIBRARY_PATH'] = self._build_path() 1083 clean_env['DYLD_LIBRARY_PATH'] = self._build_path()
1094 variables_to_copy += [ 1084 variables_to_copy += [
1095 'HOME', 1085 'HOME',
1096 ] 1086 ]
1097 if self.host.platform.is_win(): 1087 if self.host.platform.is_win():
1098 variables_to_copy += [ 1088 variables_to_copy += [
1099 'PATH', 1089 'PATH',
1100 'GYP_DEFINES', # Required to locate win sdk. 1090 'GYP_DEFINES', # Required to locate win sdk.
1101 ] 1091 ]
1102 if self.host.platform.is_cygwin(): 1092 if self.host.platform.is_cygwin():
1103 variables_to_copy += [ 1093 variables_to_copy += [
1104 'HOMEDRIVE', 1094 'HOMEDRIVE',
1105 'HOMEPATH', 1095 'HOMEPATH',
1106 '_NT_SYMBOL_PATH', 1096 '_NT_SYMBOL_PATH',
1107 ] 1097 ]
1108 1098
1109 for variable in variables_to_copy: 1099 for variable in variables_to_copy:
1110 self._copy_value_from_environ_if_set(clean_env, variable) 1100 if variable in self.host.environ:
1101 clean_env[variable] = self.host.environ[variable]
1111 1102
1112 for string_variable in self.get_option('additional_env_var', []): 1103 for string_variable in self.get_option('additional_env_var', []):
1113 [name, value] = string_variable.split('=', 1) 1104 [name, value] = string_variable.split('=', 1)
1114 clean_env[name] = value 1105 clean_env[name] = value
1115 1106
1116 return clean_env 1107 return clean_env
1117 1108
1118 def show_results_html_file(self, results_filename): 1109 def show_results_html_file(self, results_filename):
1119 """This routine should display the HTML file pointed at by 1110 """This routine should display the HTML file pointed at by
1120 results_filename in a users' browser.""" 1111 results_filename in a users' browser."""
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 """ 1430 """
1440 raise NotImplementedError('Port.path_to_apache') 1431 raise NotImplementedError('Port.path_to_apache')
1441 1432
1442 def path_to_apache_config_file(self): 1433 def path_to_apache_config_file(self):
1443 """Returns the full path to the apache configuration file. 1434 """Returns the full path to the apache configuration file.
1444 1435
1445 If the WEBKIT_HTTP_SERVER_CONF_PATH environment variable is set, its 1436 If the WEBKIT_HTTP_SERVER_CONF_PATH environment variable is set, its
1446 contents will be used instead. 1437 contents will be used instead.
1447 1438
1448 This is needed only by ports that use the apache_http_server module.""" 1439 This is needed only by ports that use the apache_http_server module."""
1449 config_file_from_env = os.environ.get('WEBKIT_HTTP_SERVER_CONF_PATH') 1440 config_file_from_env = self.host.environ.get('WEBKIT_HTTP_SERVER_CONF_PA TH')
1450 if config_file_from_env: 1441 if config_file_from_env:
1451 if not self._filesystem.exists(config_file_from_env): 1442 if not self._filesystem.exists(config_file_from_env):
1452 raise IOError('%s was not found on the system' % config_file_fro m_env) 1443 raise IOError('%s was not found on the system' % config_file_fro m_env)
1453 return config_file_from_env 1444 return config_file_from_env
1454 1445
1455 config_file_name = self._apache_config_file_name_for_platform() 1446 config_file_name = self._apache_config_file_name_for_platform()
1456 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', co nfig_file_name) 1447 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', co nfig_file_name)
1457 1448
1458 # 1449 #
1459 # PROTECTED ROUTINES 1450 # PROTECTED ROUTINES
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 return None 1520 return None
1530 1521
1531 def _get_crash_log(self, name, pid, stdout, stderr, newer_than): 1522 def _get_crash_log(self, name, pid, stdout, stderr, newer_than):
1532 if self.output_contains_sanitizer_messages(stderr): 1523 if self.output_contains_sanitizer_messages(stderr):
1533 # Running the symbolizer script can take a lot of memory, so we need to 1524 # Running the symbolizer script can take a lot of memory, so we need to
1534 # serialize access to it across all the concurrently running drivers . 1525 # serialize access to it across all the concurrently running drivers .
1535 1526
1536 llvm_symbolizer_path = self.path_from_chromium_base( 1527 llvm_symbolizer_path = self.path_from_chromium_base(
1537 'third_party', 'llvm-build', 'Release+Asserts', 'bin', 'llvm-sym bolizer') 1528 'third_party', 'llvm-build', 'Release+Asserts', 'bin', 'llvm-sym bolizer')
1538 if self._filesystem.exists(llvm_symbolizer_path): 1529 if self._filesystem.exists(llvm_symbolizer_path):
1539 env = os.environ.copy() 1530 env = self.host.environ.copy()
1540 env['LLVM_SYMBOLIZER_PATH'] = llvm_symbolizer_path 1531 env['LLVM_SYMBOLIZER_PATH'] = llvm_symbolizer_path
1541 else: 1532 else:
1542 env = None 1533 env = None
1543 sanitizer_filter_path = self.path_from_chromium_base('tools', 'valgr ind', 'asan', 'asan_symbolize.py') 1534 sanitizer_filter_path = self.path_from_chromium_base('tools', 'valgr ind', 'asan', 'asan_symbolize.py')
1544 sanitizer_strip_path_prefix = 'Release/../../' 1535 sanitizer_strip_path_prefix = 'Release/../../'
1545 if self._filesystem.exists(sanitizer_filter_path): 1536 if self._filesystem.exists(sanitizer_filter_path):
1546 stderr = self._executive.run_command( 1537 stderr = self._executive.run_command(
1547 ['flock', sys.executable, sanitizer_filter_path, sanitizer_s trip_path_prefix], input=stderr, decode_output=False, env=env) 1538 ['flock', sys.executable, sanitizer_filter_path, sanitizer_s trip_path_prefix], input=stderr, decode_output=False, env=env)
1548 1539
1549 name_str = name or '<unknown process name>' 1540 name_str = name or '<unknown process name>'
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 1779
1789 def __init__(self, base, args, reference_args=None): 1780 def __init__(self, base, args, reference_args=None):
1790 self.name = base 1781 self.name = base
1791 self.base = base 1782 self.base = base
1792 self.args = args 1783 self.args = args
1793 self.reference_args = args if reference_args is None else reference_args 1784 self.reference_args = args if reference_args is None else reference_args
1794 self.tests = set() 1785 self.tests = set()
1795 1786
1796 def __repr__(self): 1787 def __repr__(self):
1797 return "PhysicalTestSuite('%s', '%s', %s, %s)" % (self.name, self.base, self.args, self.reference_args) 1788 return "PhysicalTestSuite('%s', '%s', %s, %s)" % (self.name, self.base, self.args, self.reference_args)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698