def test_get_from_environment(self): """Tests getting the source directory from the os environment.""" self.mock_os_environment({'CHROMIUM_SRC': self.source_dir}) result = common.get_source_directory('chromium') self.assertEqual(result, self.source_dir) self.assertEqual(0, self.mock.ask.call_count)
def test_ask_and_expand_path(self): """Tests getting the source directory and expand abspath.""" self.mock_os_environment({'CHROMIUM_SRC': ''}) os.makedirs(os.path.abspath('./test-dir')) self.mock.ask.return_value = './test-dir' result = common.get_source_directory('chromium') self.assertEqual(os.path.abspath('./test-dir'), result)
def get_build_directory(self): """Returns the location of the correct build to use for reproduction.""" if self.build_directory: return self.build_directory download_build(self.build_dir_name(), self.build_url, self.binary_name) # We need the source dir so we can use asan_symbolize.py from the # chromium source directory. self.source_directory = common.get_source_directory('chromium') self.build_directory = self.build_dir_name() return self.build_directory
def __init__(self, name, testcase, definition, binary_name, target, options): """self.git_sha must be set in a subclass, or some of these instance methods may not work.""" super(GenericBuilder, self).__init__( testcase_id=testcase.id, build_url=testcase.build_url, binary_name=binary_name) self.name = name self.testcase = testcase self.target = target if target else binary_name self.options = options # TODO(tanin): Move computation out of constructor because it's difficult # to mock. self.source_directory = ( os.environ.get(definition.source_var) or common.get_source_directory(self.name)) self.gn_args = None self.gn_args_options = {} self.gn_flags = '--check' self.definition = definition
def get_build_directory(self): """Returns the location of the correct build to use for reproduction.""" if self.build_directory: return self.build_directory if not self.gn_args: self.download_build_data() self.build_directory = self.build_dir_name() if not self.source_directory: self.source_directory = common.get_source_directory(self.name) if not self.current: self.checkout_source_by_sha() self.build_directory = self.out_dir_name() self.build_target() return self.build_directory