xref: /freebsd/contrib/kyua/drivers/list_tests.hpp (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1 // Copyright 2011 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 drivers/list_tests.hpp
30 /// Driver to obtain a list of test cases out of a test suite.
31 ///
32 /// This driver module implements the logic to extract a list of test cases out
33 /// of a particular test suite.
34 
35 #if !defined(DRIVERS_LIST_TESTS_HPP)
36 #define DRIVERS_LIST_TESTS_HPP
37 
38 #include <set>
39 #include <string>
40 
41 #include "engine/filters_fwd.hpp"
42 #include "model/test_program_fwd.hpp"
43 #include "utils/config/tree_fwd.hpp"
44 #include "utils/fs/path_fwd.hpp"
45 #include "utils/optional_fwd.hpp"
46 
47 namespace drivers {
48 namespace list_tests {
49 
50 
51 /// Abstract definition of the hooks for this driver.
52 class base_hooks {
53 public:
54     virtual ~base_hooks(void) = 0;
55 
56     /// Called when a test case is identified in a test suite.
57     ///
58     /// \param test_program The test program containing the test case.
59     /// \param test_case_name The name of the located test case.
60     virtual void got_test_case(const model::test_program& test_program,
61                                const std::string& test_case_name) = 0;
62 };
63 
64 
65 /// Tuple containing the results of this driver.
66 class result {
67 public:
68     /// Filters that did not match any available test case.
69     ///
70     /// The presence of any filters here probably indicates a usage error.  If a
71     /// test filter does not match any test case, it is probably a typo.
72     std::set< engine::test_filter > unused_filters;
73 
74     /// Initializer for the tuple's fields.
75     ///
76     /// \param unused_filters_ The filters that did not match any test case.
77     result(const std::set< engine::test_filter >& unused_filters_) :
78         unused_filters(unused_filters_)
79     {
80     }
81 };
82 
83 
84 result drive(const utils::fs::path&, const utils::optional< utils::fs::path >,
85              const std::set< engine::test_filter >&,
86              const utils::config::tree&, base_hooks&);
87 
88 
89 }  // namespace list_tests
90 }  // namespace drivers
91 
92 #endif  // !defined(DRIVERS_LIST_TESTS_HPP)
93