def _TestOutFile(self, test_name, expected):
        gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name)
        command = [
            gtest_prog_path,
            '--gtest_output=json:%s' % self.output_dir_
        ]
        p = gtest_test_utils.Subprocess(
            command, working_dir=gtest_test_utils.GetTempDir())
        self.assert_(p.exited)
        self.assertEquals(0, p.exit_code)

        output_file_name1 = test_name + '.json'
        output_file1 = os.path.join(self.output_dir_, output_file_name1)
        output_file_name2 = 'lt-' + output_file_name1
        output_file2 = os.path.join(self.output_dir_, output_file_name2)
        self.assert_(
            os.path.isfile(output_file1) or os.path.isfile(output_file2),
            output_file1)

        if os.path.isfile(output_file1):
            with open(output_file1) as f:
                actual = json.load(f)
        else:
            with open(output_file2) as f:
                actual = json.load(f)
        self.assertEqual(expected, gtest_json_test_utils.normalize(actual))
Esempio n. 2
0
  def _TestOutFile(self, test_name, expected):
    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name)
    command = [gtest_prog_path, '--gtest_output=json:%s' % self.output_dir_]
    p = gtest_test_utils.Subprocess(command,
                                    working_dir=gtest_test_utils.GetTempDir())
    self.assert_(p.exited)
    self.assertEquals(0, p.exit_code)

    # FIXME: libtool causes the built test binary to be
    #   named lt-gtest_xml_outfiles_test_ instead of
    #   gtest_xml_outfiles_test_.  To account for this possibility, we
    #   allow both names in the following code.  We should remove this
    #   when libtool replacement tool is ready.
    output_file_name1 = test_name + '.json'
    output_file1 = os.path.join(self.output_dir_, output_file_name1)
    output_file_name2 = 'lt-' + output_file_name1
    output_file2 = os.path.join(self.output_dir_, output_file_name2)
    self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),
                 output_file1)

    if os.path.isfile(output_file1):
      with open(output_file1) as f:
        actual = json.load(f)
    else:
      with open(output_file2) as f:
        actual = json.load(f)
    self.assertEqual(expected, gtest_json_test_utils.normalize(actual))
  def _TestOutFile(self, test_name, expected):
    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name)
    command = [gtest_prog_path, '--gtest_output=json:%s' % self.output_dir_]
    p = gtest_test_utils.Subprocess(command,
                                    working_dir=gtest_test_utils.GetTempDir())
    self.assert_(p.exited)
    self.assertEquals(0, p.exit_code)

    # FIXME: libtool causes the built test binary to be
    #   named lt-gtest_xml_outfiles_test_ instead of
    #   gtest_xml_outfiles_test_.  To account for this possibility, we
    #   allow both names in the following code.  We should remove this
    #   when libtool replacement tool is ready.
    output_file_name1 = test_name + '.json'
    output_file1 = os.path.join(self.output_dir_, output_file_name1)
    output_file_name2 = 'lt-' + output_file_name1
    output_file2 = os.path.join(self.output_dir_, output_file_name2)
    self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),
                 output_file1)

    if os.path.isfile(output_file1):
      with open(output_file1) as f:
        actual = json.load(f)
    else:
      with open(output_file2) as f:
        actual = json.load(f)
    self.assertEqual(expected, gtest_json_test_utils.normalize(actual))
  def _TestJsonOutput(self, gtest_prog_name, expected,
                      expected_exit_code, extra_args=None):
    """Checks the JSON output generated by the Google Test binary.

    Asserts that the JSON document generated by running the program
    gtest_prog_name matches expected_json, a string containing another
    JSON document.  Furthermore, the program's exit code must be
    expected_exit_code.

    Args:
      gtest_prog_name: Google Test binary name.
      expected: expected output.
      expected_exit_code: program's exit code.
      extra_args: extra arguments to binary invocation.
    """

    actual = self._GetJsonOutput(gtest_prog_name, extra_args or [],
                                 expected_exit_code)
    self.assertEqual(expected, gtest_json_test_utils.normalize(actual))
  def _TestJsonOutput(self, gtest_prog_name, expected,
                      expected_exit_code, extra_args=None):
    """Checks the JSON output generated by the Google Test binary.

    Asserts that the JSON document generated by running the program
    gtest_prog_name matches expected_json, a string containing another
    JSON document.  Furthermore, the program's exit code must be
    expected_exit_code.

    Args:
      gtest_prog_name: Google Test binary name.
      expected: expected output.
      expected_exit_code: program's exit code.
      extra_args: extra arguments to binary invocation.
    """

    actual = self._GetJsonOutput(gtest_prog_name, extra_args or [],
                                 expected_exit_code)
    self.assertEqual(expected, gtest_json_test_utils.normalize(actual))
  def _TestOutFile(self, test_name, expected):
    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name)
    command = [gtest_prog_path, '--gtest_output=json:%s' % self.output_dir_]
    p = gtest_test_utils.Subprocess(command,
                                    working_dir=gtest_test_utils.GetTempDir())
    self.assert_(p.exited)
    self.assertEquals(0, p.exit_code)

    output_file_name1 = test_name + '.json'
    output_file1 = os.path.join(self.output_dir_, output_file_name1)
    output_file_name2 = 'lt-' + output_file_name1
    output_file2 = os.path.join(self.output_dir_, output_file_name2)
    self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),
                 output_file1)

    if os.path.isfile(output_file1):
      with open(output_file1) as f:
        actual = json.load(f)
    else:
      with open(output_file2) as f:
        actual = json.load(f)
    self.assertEqual(expected, gtest_json_test_utils.normalize(actual))