xml_output.cpp 933 B

1234567891011121314151617181920212223242526
  1. #include <fstream>
  2. #include <iostream>
  3. #include <string>
  4. int main(int argc, char** argv)
  5. {
  6. // Note: GoogleTestXML.cmake doesn't actually depend on Google Test as such;
  7. // it only mimicks the output file creation using the path passed to this
  8. // test without any content
  9. for (int i = 0; i < argc; i++) {
  10. std::string param(argv[i]);
  11. if (param.find("--gtest_list_tests") != std::string::npos) {
  12. // This actually defines the name of the file passed in the 2nd run
  13. std::cout << "GoogleTestXML." << std::endl;
  14. std::cout << " Foo" << std::endl;
  15. } else if (param.find("--gtest_output=xml:") != std::string::npos) {
  16. std::string::size_type split = param.find(":");
  17. std::string filepath = param.substr(split + 1);
  18. // The full file path is passed
  19. std::ofstream ostrm(filepath.c_str(), std::ios::binary);
  20. ostrm << "--gtest_output=xml: mockup file\n";
  21. }
  22. }
  23. return 0;
  24. }