list_tests.hpp revision 1.1.1.1
1// Copyright 2011 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/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(ENGINE_DRIVERS_LIST_TESTS_HPP)
36#define ENGINE_DRIVERS_LIST_TESTS_HPP
37
38#include <set>
39
40#include "engine/filters.hpp"
41#include "engine/test_case.hpp"
42#include "engine/test_program.hpp"
43#include "utils/fs/path.hpp"
44#include "utils/optional.hpp"
45
46namespace engine {
47namespace drivers {
48namespace list_tests {
49
50
51/// Abstract definition of the hooks for this driver.
52class base_hooks {
53public:
54    virtual ~base_hooks(void) = 0;
55
56    /// Called when a test case is identified in a test suite.
57    ///
58    /// \param test_case The data describing the test case.
59    virtual void got_test_case(const engine::test_case& test_case) = 0;
60};
61
62
63/// Tuple containing the results of this driver.
64struct result {
65    /// Filters that did not match any available test case.
66    ///
67    /// The presence of any filters here probably indicates a usage error.  If a
68    /// test filter does not match any test case, it is probably a typo.
69    std::set< test_filter > unused_filters;
70
71    /// Initializer for the tuple's fields.
72    ///
73    /// \param unused_filters_ The filters that did not match any test case.
74    result(const std::set< test_filter >& unused_filters_) :
75        unused_filters(unused_filters_)
76    {
77    }
78};
79
80
81result drive(const utils::fs::path&, const utils::optional< utils::fs::path >,
82             const std::set< test_filter >&, base_hooks&);
83
84
85}  // namespace list_tests
86}  // namespace drivers
87}  // namespace engine
88
89#endif  // !defined(ENGINE_DRIVERS_LIST_TESTS_HPP)
90