1 // Copyright 2015 The Kyua Authors.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /// \file engine/tap_parser.hpp
30 /// Utilities to parse TAP test program output.
32 #if !defined(ENGINE_TAP_PARSER_HPP)
33 #define ENGINE_TAP_PARSER_HPP
35 #include "engine/tap_parser_fwd.hpp"
41 #include "utils/fs/path_fwd.hpp"
46 /// TAP plan representing all tests being skipped.
47 extern const engine::tap_plan all_skipped_plan;
50 /// TAP output representation and parser.
52 /// Whether the test program bailed out early or not.
55 /// The TAP plan. Only valid if not bailed out.
58 /// If not empty, the reason why all tests were skipped.
59 std::string _all_skipped_reason;
61 /// Total number of 'ok' tests. Only valid if not balied out.
62 std::size_t _ok_count;
64 /// Total number of 'not ok' tests. Only valid if not balied out.
65 std::size_t _not_ok_count;
67 tap_summary(const bool, const tap_plan&, const std::string&,
68 const std::size_t, const std::size_t);
71 // Yes, these three constructors indicate that we really ought to have three
72 // different classes and select between them at runtime. But doing so would
73 // be overly complex for our really simple needs here.
74 static tap_summary new_bailed_out(void);
75 static tap_summary new_all_skipped(const std::string&);
76 static tap_summary new_results(const tap_plan&, const std::size_t,
79 bool bailed_out(void) const;
80 const tap_plan& plan(void) const;
81 const std::string& all_skipped_reason(void) const;
82 std::size_t ok_count(void) const;
83 std::size_t not_ok_count(void) const;
85 bool operator==(const tap_summary&) const;
86 bool operator!=(const tap_summary&) const;
90 std::ostream& operator<<(std::ostream&, const tap_summary&);
93 tap_summary parse_tap_output(const utils::fs::path&);
99 #endif // !defined(ENGINE_TAP_PARSER_HPP)