xref: /netbsd-src/external/bsd/kyua-cli/dist/engine/test_program.hpp (revision f39f9c9b2b3d39fa4e71f38ebea4c5d12192a641)
1 // Copyright 2010 Google Inc.
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/test_program.hpp
30 /// Interface to interact with test programs.
31 ///
32 /// A test program is purely a collection of test cases.  The test program has
33 /// no identity by itself: it only exists to provide a consistent entry point
34 /// for all the test cases it contains and to group such test cases
35 /// semantically.  Therefore, this module provides no data type to represent the
36 /// test program.
37 
38 #if !defined(ENGINE_TEST_PROGRAM_HPP)
39 #define ENGINE_TEST_PROGRAM_HPP
40 
41 #include <ostream>
42 #include <string>
43 #include <vector>
44 
45 #include "engine/test_case.hpp"
46 #include "utils/fs/path.hpp"
47 #include "utils/shared_ptr.hpp"
48 
49 namespace engine {
50 
51 
52 /// Collection of test cases.
53 typedef std::vector< test_case_ptr > test_cases_vector;
54 
55 
56 std::ostream& operator<<(std::ostream&, const test_cases_vector&);
57 
58 
59 /// Representation of a test program.
60 class test_program {
61     struct impl;
62 
63     /// Pointer to the shared internal implementation.
64     std::shared_ptr< impl > _pimpl;
65 
66 public:
67     test_program(const std::string&, const utils::fs::path&,
68                  const utils::fs::path&, const std::string&,
69                  const metadata&);
70     ~test_program(void);
71 
72     const std::string& interface_name(void) const;
73     const utils::fs::path& root(void) const;
74     const utils::fs::path& relative_path(void) const;
75     const utils::fs::path absolute_path(void) const;
76     const std::string& test_suite_name(void) const;
77     const metadata& get_metadata(void) const;
78 
79     const test_case_ptr& find(const std::string&) const;
80     const test_cases_vector& test_cases(void) const;
81     void set_test_cases(const test_cases_vector&);
82 
83     bool operator==(const test_program&) const;
84     bool operator!=(const test_program&) const;
85 };
86 
87 
88 std::ostream& operator<<(std::ostream&, const test_program&);
89 
90 
91 /// Pointer to a test program.
92 typedef std::shared_ptr< test_program > test_program_ptr;
93 
94 
95 /// Collection of test programs.
96 typedef std::vector< test_program_ptr > test_programs_vector;
97 
98 
99 }  // namespace engine
100 
101 #endif  // !defined(ENGINE_TEST_PROGRAM_HPP)
102