# Path: compiler_opt/tools/extract_ir.py
# FLAGS = flags.FLAGS
# def should_include_module(cmdline: str, match_regexp: str) -> bool:
# def get_thinlto_index(cmdline: str, basedir: str) -> str:
#   def __init__(self, obj_relative_path, output_base_dir, obj_base_dir=None):
#   def obj_base_dir(self):
#   def output_base_dir(self):
#   def relative_output_path(self):
#   def input_obj(self):
#   def dest_dir(self):
#   def module_name(self):
#   def cmd_file(self):
#   def bc_file(self):
#   def thinlto_index_file(self):
#   def _get_extraction_cmd_command(self, llvm_objcopy_path):
#   def _get_extraction_bc_command(self, llvm_objcopy_path):
#   def extract(self, llvm_objcopy_path: str, cmd_filter: str,
#               is_thinlto: bool) -> str:
# def convert_compile_command_to_objectfile(command: Dict[str, str],
#                                           output_dir: str):
# def load_from_compile_commands(json_array: List[Dict[str, str]],
#                                output_dir: str) -> List[TrainingIRExtractor]:
# def load_from_lld_params(params_array: List[str], obj_base_dir: str,
#                          output_dir: str) -> List[TrainingIRExtractor]:
#   def make_obj(obj_file: str) -> TrainingIRExtractor:
# def extract_artifacts(obj: TrainingIRExtractor) -> str:
# def main(argv):
# class TrainingIRExtractor:


from absl.testing import absltest
from compiler_opt.tools import extract_ir
                     '/corpus/destination/path/lib/bar.o.thinlto.bc')

    self.assertEqual(res[1].input_obj(), '/output/directory/lib/other/baz.o')
    self.assertEqual(res[1].relative_output_path(), 'lib/other/baz.o')
    self.assertEqual(res[1].cmd_file(),
                     '/corpus/destination/path/lib/other/baz.o.cmd')
    self.assertEqual(res[1].bc_file(),
                     '/corpus/destination/path/lib/other/baz.o.bc')
    self.assertEqual(res[1].thinlto_index_file(),
                     '/corpus/destination/path/lib/other/baz.o.thinlto.bc')

  def test_command_extraction(self):
    obj = extract_ir.TrainingIRExtractor(
        obj_relative_path='lib/obj_file.o',
        output_base_dir='/where/corpus/goes',
        obj_base_dir='/foo/bar')
    self.assertEqual(
        obj._get_extraction_cmd_command('/bin/llvm_objcopy_path'), [
            '/bin/llvm_objcopy_path',
            '--dump-section=.llvmcmd=/where/corpus/goes/lib/obj_file.o.cmd',
            '/foo/bar/lib/obj_file.o', '/dev/null'
        ])
    self.assertEqual(
        obj._get_extraction_bc_command('/bin/llvm_objcopy_path'), [
            '/bin/llvm_objcopy_path',
            '--dump-section=.llvmbc=/where/corpus/goes/lib/obj_file.o.bc',
            '/foo/bar/lib/obj_file.o', '/dev/null'
        ])

  def test_command_extraction_no_basedir(self):

# Path: compiler_opt/tools/extract_ir.py
# FLAGS = flags.FLAGS
# def should_include_module(cmdline: str, match_regexp: str) -> bool:
# def get_thinlto_index(cmdline: str, basedir: str) -> str:
#   def __init__(self, obj_relative_path, output_base_dir, obj_base_dir=None):
#   def obj_base_dir(self):
#   def output_base_dir(self):
#   def relative_output_path(self):
#   def input_obj(self):
#   def dest_dir(self):
#   def module_name(self):
#   def cmd_file(self):
#   def bc_file(self):
#   def thinlto_index_file(self):
#   def _get_extraction_cmd_command(self, llvm_objcopy_path):
#   def _get_extraction_bc_command(self, llvm_objcopy_path):
#   def extract(self, llvm_objcopy_path: str, cmd_filter: str,
#               is_thinlto: bool) -> str:
# def convert_compile_command_to_objectfile(command: Dict[str, str],
#                                           output_dir: str):
# def load_from_compile_commands(json_array: List[Dict[str, str]],
#                                output_dir: str) -> List[TrainingIRExtractor]:
# def load_from_lld_params(params_array: List[str], obj_base_dir: str,
#                          output_dir: str) -> List[TrainingIRExtractor]:
#   def make_obj(obj_file: str) -> TrainingIRExtractor:
# def extract_artifacts(obj: TrainingIRExtractor) -> str:
# def main(argv):
# class TrainingIRExtractor:


# Path: compiler_opt/tools/extract_ir_test.py
from absl.testing import absltest
from compiler_opt.tools import extract_ir

                     '/corpus/destination/path/lib/bar.o.thinlto.bc')

    self.assertEqual(res[1].input_obj(), '/output/directory/lib/other/baz.o')
    self.assertEqual(res[1].relative_output_path(), 'lib/other/baz.o')
    self.assertEqual(res[1].cmd_file(),
                     '/corpus/destination/path/lib/other/baz.o.cmd')
    self.assertEqual(res[1].bc_file(),
                     '/corpus/destination/path/lib/other/baz.o.bc')
    self.assertEqual(res[1].thinlto_index_file(),
                     '/corpus/destination/path/lib/other/baz.o.thinlto.bc')

  def test_command_extraction(self):
    obj = extract_ir.TrainingIRExtractor(
        obj_relative_path='lib/obj_file.o',
        output_base_dir='/where/corpus/goes',
        obj_base_dir='/foo/bar')
    self.assertEqual(
        obj._get_extraction_cmd_command('/bin/llvm_objcopy_path'), [
            '/bin/llvm_objcopy_path',
            '--dump-section=.llvmcmd=/where/corpus/goes/lib/obj_file.o.cmd',
            '/foo/bar/lib/obj_file.o', '/dev/null'
        ])
    self.assertEqual(
        obj._get_extraction_bc_command('/bin/llvm_objcopy_path'), [
            '/bin/llvm_objcopy_path',
            '--dump-section=.llvmbc=/where/corpus/goes/lib/obj_file.o.bc',
            '/foo/bar/lib/obj_file.o', '/dev/null'
        ])

  def test_command_extraction_no_basedir(self):

    obj = extract_ir.TrainingIRExtractor('lib/obj_file.o', '/where/corpus/goes')