예제 #1
0
 def test_small_block(self):
     self.assertEqual(
         [
             Command("cd /tmp", "/tmp", [MAKEANNOTATIONHINT]),
             Command("cc -c -o main.o main.c", "/tmp"),
             Command("cc -c -o divisible.o divisible.c", "/tmp"),
             Command("cc -o divisible main.o divisible.o", "/tmp")
         ],
         # "cd " + os.getcwd() + MAKEANNOTATIONHINT],
         translate_to_commands(
             dedent("""\
         make: Entering directory '/tmp'
         + cc -c -o main.o main.c
         + cc -c -o divisible.o divisible.c
         + cc -o divisible main.o divisible.o
         """))
         # make: Leaving directory '/tmp'
     )
예제 #2
0
    def apply_transformation_on(cmd, container):
        print("TransformCmakeLink " + cmd.bashcmd)
        link_file_name = re.split('\\s', cmd.bashcmd)[3]
        link_file = open(cmd.curdir + "/" + link_file_name, 'r')
        link_line = link_file.readline()
        link_cmd = Command(link_line, cmd.curdir)
        relevant = directory.list_all_llvm_transformers()
        for transformer in relevant:
            if transformer is TransformCmakeLink:
                continue
            if transformer.can_be_applied_on(link_cmd):
                transformed_cmd = transformer.apply_transformation_on(
                    link_cmd, container)
                print("Transformed cmake link command " +
                      transformed_cmd.bashcmd)
                return transformed_cmd

        print("Could not transform from cmake file ")
        print(cmd.curdir + "/" + link_file_name)
        print("Command")
        print(link_cmd.bashcmd)
        exit(-1)
        return None
예제 #3
0
 def test_failcount(self):
     self.assertEqual(0, self.llvm.skipped)
     self.llvm.transform(
         Command("just impossible to translate wtf", "/tmp"))
     self.assertEqual(1, self.llvm.skipped)
예제 #4
0
 def test_empty(self):
     self.assertEqual(
         Command("", "/tmp"), self.llvm.transform(Command("", "/tmp")))
예제 #5
0
 def register(self, cmd, curdir):
     self.llvm.register(Command(cmd, curdir))
예제 #6
0
 def test_spaces(self):
     self.assertTrue(Command("   ", "/tmp").is_noop())
예제 #7
0
 def test_empty(self):
     self.assertTrue(Command("", "/tmp").is_noop())
예제 #8
0
 def test_command_with_comment(self):
     self.assertFalse(
         Command("cd dir # change directory", "/tmp").is_noop())
예제 #9
0
 def test_comment_with_leading_space(self):
     self.assertTrue(Command(" # comment", "/tmp").is_noop())
예제 #10
0
 def test_comment(self):
     self.assertTrue(Command("# comment", "/tmp").is_noop())
예제 #11
0
 def test_command(self):
     self.assertFalse(Command("cd dir", "/tmp").is_noop())
     self.assertFalse(Command("cc -c main.c", "/tmp").is_noop())
 def assertTransformation(self, transformation, command, curdir="/tmp"):
     self.assertEqual(Command(transformation, curdir),
                      self.llvm.transform(Command(command, curdir)))
예제 #13
0
 def test_cd_keep_make(self):
     self.assertEqual(
         Command("cd mydir", "/tmp", [MAKEANNOTATIONHINT]),
         self.llvm.transform(
             Command("cd mydir", "/tmp", [MAKEANNOTATIONHINT])))
예제 #14
0
 def test_make_statement(self):
     self.assertEqual(
         [Command("cd /tmp", "/tmp", [MAKEANNOTATIONHINT])],
         translate_to_commands("make: Entering directory '/tmp'"))
예제 #15
0
 def test_string_representation(self):
     self.assertTrue(
         str(Command("cmd that does something",
                     "/somedir")).startswith("cmd that does something"))