def prepare(self, unused_test_methods_to_run): """Builds test jar files for a test.""" shutil.rmtree(self._work_dir, ignore_errors=True) # Copy the source directory to the working directory. # Note that we must not copy the files by python's internal utilities # here, such as shutil.copy, or loops written manually, etc., because it # would cause ETXTBSY in run_subprocess called below if we run this # on multi-threading. Here is the senario: # Let there are two cases A, and B, and, to simplify, let what we do here # are 1) copying the "{A_src,B_src}/build" files to "{A,B}/build", and then # 2) fork() and execute() "{A,B}/build". Each will run on a different # threads, named thread-A and thread-B. # 1) on thread-A, "A_src/build" is copied to "A/build". # 2) on thread-B, "B_src/build" starts to be copied to "B/build". For that # purpose, "B/build" is opened with "write" flag. # 3) on thread-A, the process is fork()'ed, *before the copy of "B/build" # is completed. So, subprocess-A keeps the FD of "B/build" with "write". # 4) on thread-B, "B/build" is copied, and close()'ed, then fork()'ed. # 5) on subprocess-B, it tries to exec "B/build". However, the file is # still kept opened by subprocess-A. As a result, ETXTBSY is reported. # Probably, the ideal solution would be that such an issue should be # handled by the framework (crbug.com/345667), but it seems to need some # more investigation. So, instead, we copy the files in another process. subprocess.check_call(['cp', '-Lr', self._source_dir, self._work_dir]) build_script = os.path.abspath(os.path.join(self._work_dir, 'build')) if not os.path.isfile(build_script): # If not found, use the default-build script. # Note: do not use a python function here, such as shutil.copy directly. # See above comment for details. subprocess.check_call( ['cp', os.path.join(self.get_source_root(), 'etc', 'default-build'), build_script]) # Ensure that the executable bit is set. os.chmod(build_script, stat.S_IRWXU) env = { 'DX': 'dx', 'NEED_DEX': 'true', 'TEST_NAME': self._suite_name, 'JAVAC': toolchain.get_tool('java', 'javac'), 'PATH': ':'.join([ os.path.join(build_common.get_arc_root(), toolchain.get_android_sdk_build_tools_dir()), # Put PATH in the end to prevent shadowing previous path. os.environ['PATH'] ]) } subprocess.check_call([build_script], env=env, cwd=self._work_dir) args = self.get_system_mode_launch_chrome_command(self._name) prep_launch_chrome.prepare_crx_with_raw_args(args)
def prepare(self, test_methods_to_run): args = self.get_system_mode_launch_chrome_command( self._name, additional_args=self._additional_launch_chrome_opts, additional_metadata=self._additional_metadata) prep_launch_chrome.prepare_crx_with_raw_args(args)
def prepare(self, test_methods_to_run): args = self._build_launch_chrome_command(test_methods_to_run) prep_launch_chrome.prepare_crx_with_raw_args(args)
def prepare(self, test_methods_to_run): args = self.get_launch_chrome_command( self._get_js_test_options(), additional_metadata=self._get_additional_metadata(test_methods_to_run)) prep_launch_chrome.prepare_crx_with_raw_args(args)
def prepare(self, test_methods_to_run): args = self.get_launch_chrome_command( self._get_js_test_options(), additional_metadata=self._get_additional_metadata( test_methods_to_run)) prep_launch_chrome.prepare_crx_with_raw_args(args)