teamcity_cppunit.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright 2011 JetBrains s.r.o.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. *
  15. * $Revision: 88625 $
  16. */
  17. #include <sstream>
  18. #include "teamcity_cppunit.h"
  19. using namespace std;
  20. namespace JetBrains {
  21. TeamcityProgressListener::TeamcityProgressListener()
  22. {
  23. flowid = getFlowIdFromEnvironment();
  24. }
  25. TeamcityProgressListener::TeamcityProgressListener(const std::string& _flowid)
  26. {
  27. flowid = _flowid;
  28. }
  29. void TeamcityProgressListener::startTest(const std::string& test) {
  30. messages.testStarted(test, flowid);
  31. }
  32. static string sourceLine2string(const SourceLine &sline) {
  33. stringstream ss;
  34. ss << sline.fileName << ":" << sline.lineNumber;
  35. return ss.str();
  36. }
  37. void TeamcityProgressListener::addFailure(const TestFailure &failure)
  38. {
  39. string details = failure.details;
  40. if (failure.sourceLine.isValid()) {
  41. details.append(" at ");
  42. details.append(sourceLine2string(failure.sourceLine));
  43. details.append("\n");
  44. }
  45. messages.testFailed(
  46. failure.testName,
  47. failure.description,
  48. details,
  49. flowid
  50. );
  51. }
  52. void TeamcityProgressListener::endTest(const std::string& test)
  53. {
  54. messages.testFinished(test, -1, flowid);
  55. }
  56. void TeamcityProgressListener::startSuite(const std::string& test)
  57. {
  58. messages.suiteStarted(test, flowid);
  59. }
  60. void TeamcityProgressListener::endSuite(const std::string& test)
  61. {
  62. messages.suiteFinished(test, flowid);
  63. }
  64. }