def setUp(self): self.file_dir = os.path.dirname(os.path.abspath(__file__)) self.reducer = os.path.join(os.path.dirname(self.file_dir), 'bug_reducer', 'bug_reducer.py') self.build_dir = os.path.abspath( os.environ['BUGREDUCE_TEST_SWIFT_OBJ_ROOT']) (root, _) = os.path.splitext(os.path.abspath(__file__)) self.root_basename = ''.join(os.path.basename(root).split('_')) self.tmp_dir = os.path.join( os.path.abspath(os.environ['BUGREDUCE_TEST_TMP_DIR']), self.root_basename) subprocess.call(['mkdir', '-p', self.tmp_dir]) self.module_cache = os.path.join(self.tmp_dir, 'module_cache') self.sdk = subprocess.check_output(['xcrun', '--sdk', 'macosx', '--toolchain', 'Default', '--show-sdk-path']).strip("\n") self.tools = swift_tools.SwiftTools(self.build_dir) self.passes = ['--pass=-bug-reducer-tester'] if os.access(self.tmp_dir, os.F_OK): shutil.rmtree(self.tmp_dir) os.makedirs(self.tmp_dir) os.makedirs(self.module_cache)
def setUp(self): self.file_dir = os.path.dirname(os.path.abspath(__file__)) self.reducer = os.path.join(os.path.dirname(self.file_dir), 'bug_reducer', 'bug_reducer.py') self.build_dir = os.path.abspath( os.environ['BUGREDUCE_TEST_SWIFT_OBJ_ROOT']) (root, _) = os.path.splitext(os.path.abspath(__file__)) self.root_basename = ''.join(os.path.basename(root).split('_')) self.tmp_dir = os.path.join( os.path.abspath(os.environ['BUGREDUCE_TEST_TMP_DIR']), self.root_basename) subprocess.call(['mkdir', '-p', self.tmp_dir]) self.module_cache = os.path.join(self.tmp_dir, 'module_cache') self.sdk = subprocess.check_output([ 'xcrun', '--sdk', 'macosx', '--toolchain', 'Default', '--show-sdk-path' ]).strip("\n") self.tools = swift_tools.SwiftTools(self.build_dir) json_data = json.loads( subprocess.check_output( [self.tools.sil_passpipeline_dumper, '-Performance'])) self.passes = [] for y in (x[2:] for x in json_data): for z in y: self.passes.append('--pass=-' + z[1]) random.seed(0xf487c07f) random.shuffle(self.passes) self.passes.insert(random.randint(0, len(self.passes)), '--pass=-bug-reducer-tester') if os.access(self.tmp_dir, os.F_OK): shutil.rmtree(self.tmp_dir) os.makedirs(self.tmp_dir) os.makedirs(self.module_cache)