1// Copyright 2015 The Kyua Authors. 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: 7// 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. 16// 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. 28 29/// \file engine/tap_parser.hpp 30/// Utilities to parse TAP test program output. 31 32#if !defined(ENGINE_TAP_PARSER_HPP) 33#define ENGINE_TAP_PARSER_HPP 34 35#include "engine/tap_parser_fwd.hpp" 36 37#include <cstddef> 38#include <ostream> 39#include <string> 40 41#include "utils/fs/path_fwd.hpp" 42 43namespace engine { 44 45 46/// TAP plan representing all tests being skipped. 47extern const engine::tap_plan all_skipped_plan; 48 49 50/// TAP output representation and parser. 51class tap_summary { 52 /// Whether the test program bailed out early or not. 53 bool _bailed_out; 54 55 /// The TAP plan. Only valid if not bailed out. 56 tap_plan _plan; 57 58 /// If not empty, the reason why all tests were skipped. 59 std::string _all_skipped_reason; 60 61 /// Total number of 'ok' tests. Only valid if not balied out. 62 std::size_t _ok_count; 63 64 /// Total number of 'not ok' tests. Only valid if not balied out. 65 std::size_t _not_ok_count; 66 67 tap_summary(const bool, const tap_plan&, const std::string&, 68 const std::size_t, const std::size_t); 69 70public: 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, 77 const std::size_t); 78 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; 84 85 bool operator==(const tap_summary&) const; 86 bool operator!=(const tap_summary&) const; 87}; 88 89 90std::ostream& operator<<(std::ostream&, const tap_summary&); 91 92 93tap_summary parse_tap_output(const utils::fs::path&); 94 95 96} // namespace engine 97 98 99#endif // !defined(ENGINE_TAP_PARSER_HPP) 100