コード例 #1
0
    def test_write_exec_trace_with_response(self):
        with libear.temporary_directory() as tmp_dir:
            response_file_one = os.path.join(tmp_dir, 'response1.jom')
            response_file_two = os.path.join(tmp_dir, 'response2.jom')
            input_one = Execution(pid=123,
                                  cwd='/path/to/here',
                                  cmd=[
                                      'clang-cl', '-c',
                                      '@' + response_file_one,
                                      '-Idoes_not_exists',
                                      '@' + response_file_two
                                  ])
            output_one = Execution(pid=123,
                                   cwd='/path/to/here',
                                   cmd=[
                                       'clang-cl', '-c', '-DSOMETHING_HERE',
                                       '-Idoes_not_exists', 'that.cpp'
                                   ])
            with open(response_file_one, 'w') as response_file_one_handle:
                response_file_one_handle.write('        -DSOMETHING_HERE\n')
            with open(response_file_two, 'w') as response_file_two_handle:
                response_file_two_handle.write('        that.cpp\n')

            temp_file = os.path.join(tmp_dir, 'single_report.cmd')
            sut.write_exec_trace(temp_file, input_one)
            result = sut.parse_exec_trace(temp_file)
            self.assertEqual(output_one, result)
コード例 #2
0
 def test_read_write_exec_trace(self):
     input_one = Execution(pid=123,
                           cwd='/path/to/here',
                           cmd=['cc', '-c', 'this.c'])
     with libear.temporary_directory() as tmp_dir:
         temp_file = os.path.join(tmp_dir, 'single_report.cmd')
         sut.write_exec_trace(temp_file, input_one)
         result = sut.parse_exec_trace(temp_file)
         self.assertEqual(input_one, result)
コード例 #3
0
ファイル: test_intercept.py プロジェクト: rizsotto/scan-build
 def test_read_write_exec_trace(self):
     input_one = Execution(
         pid=123,
         cwd='/path/to/here',
         cmd=['cc', '-c', 'this.c'])
     with libear.temporary_directory() as tmp_dir:
         temp_file = os.path.join(tmp_dir, 'single_report.cmd')
         sut.write_exec_trace(temp_file, input_one)
         result = sut.parse_exec_trace(temp_file)
         self.assertEqual(input_one, result)
コード例 #4
0
ファイル: test_intercept.py プロジェクト: pombredanne/Beye
 def test_read_write_exec_trace(self):
     input_one = {
         'pid': 123,
         'ppid': 121,
         'function': 'wrapper',  # it's a constant in the parse method
         'directory': '/path/to/here',
         'command': ['cc', '-c', 'this.c']
     }
     input_two = {
         'pid': 124,
         'ppid': 121,
         'function': 'wrapper',  # it's a constant in the parse method
         'directory': '/path/to/here',
         'command': ['cc', '-c', 'that.c']
     }
     # test with a single exec report
     with tempfile.NamedTemporaryFile() as temp_file:
         sut.write_exec_trace(temp_file.name, **input_one)
         result = sut.parse_exec_trace(temp_file.name)
         self.assertEqual([input_one], list(result))
     # test with multiple exec report
     with tempfile.NamedTemporaryFile() as temp_file:
         sut.write_exec_trace(temp_file.name, **input_one)
         sut.write_exec_trace(temp_file.name, **input_two)
         result = sut.parse_exec_trace(temp_file.name)
         self.assertEqual([input_one, input_two], list(result))
コード例 #5
0
ファイル: test_intercept.py プロジェクト: rizsotto/scan-build
    def test_write_exec_trace_with_response(self):
        with libear.temporary_directory() as tmp_dir:
            response_file_one = os.path.join(tmp_dir, 'response1.jom')
            response_file_two = os.path.join(tmp_dir, 'response2.jom')
            input_one = Execution(
                pid=123,
                cwd='/path/to/here',
                cmd=['clang-cl', '-c', '@'+response_file_one,
                     '-Idoes_not_exists', '@'+response_file_two])
            output_one = Execution(
                pid=123,
                cwd='/path/to/here',
                cmd=['clang-cl', '-c', '-DSOMETHING_HERE',
                     '-Idoes_not_exists', 'that.cpp'])
            with open(response_file_one, 'w') as response_file_one_handle:
                response_file_one_handle.write('        -DSOMETHING_HERE\n')
            with open(response_file_two, 'w') as response_file_two_handle:
                response_file_two_handle.write('        that.cpp\n')

            temp_file = os.path.join(tmp_dir, 'single_report.cmd')
            sut.write_exec_trace(temp_file, input_one)
            result = sut.parse_exec_trace(temp_file)
            self.assertEqual(output_one, result)