• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 #ifndef H_TEAMCITY_MESSAGES
19 #define H_TEAMCITY_MESSAGES
20 
21 #include <iostream>
22 #include <string>
23 
24 namespace jetbrains {
25 namespace teamcity {
26 
27 std::string getFlowIdFromEnvironment();
28 bool underTeamcity();
29 
30 class TeamcityMessages {
31     std::ostream *m_out;
32 
33 protected:
34     std::string escape(const std::string &s);
35 
36     void openMsg(const std::string &name);
37     void writeProperty(const std::string &name, const std::string &value);
38     void closeMsg();
39 
40 public:
41     static const bool StdErr = true;
42     static const bool StdOut = false;
43 
44     TeamcityMessages();
45 
46     void setOutput(std::ostream &);
47 
48     void suiteStarted(const std::string &name, const std::string &flowid =  std::string());
49     void suiteFinished(const std::string &name, const std::string &flowid =  std::string());
50 
51     void testStarted(const std::string &name, const std::string &flowid =  std::string(), bool captureStandardOutput = false);
52     void testFailed(const std::string &name, const std::string &message, const std::string &details, const std::string &flowid =  std::string());
53     void testIgnored(const std::string &name, const std::string &message, const std::string &flowid =  std::string());
54     void testOutput(const std::string &name, const std::string &output, const std::string &flowid, bool isStdErr = StdOut);
55     void testFinished(const std::string &name, int durationMs = -1, const std::string &flowid = std::string());
56 };
57 
58 }
59 }
60 
61 #endif /* H_TEAMCITY_MESSAGES */
62