1 // Copyright 2011 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 drivers/run_tests.hpp
30 /// Driver to run a collection of tests.
32 /// This driver module implements the logic to execute a collection of tests.
33 /// The presentation layer is able to monitor progress by hooking into
34 /// particular points of the driver.
36 #if !defined(DRIVERS_RUN_TESTS_HPP)
37 #define DRIVERS_RUN_TESTS_HPP
42 #include "engine/filters.hpp"
43 #include "model/test_program.hpp"
44 #include "model/test_result_fwd.hpp"
45 #include "utils/config/tree_fwd.hpp"
46 #include "utils/datetime_fwd.hpp"
47 #include "utils/fs/path_fwd.hpp"
48 #include "utils/optional_fwd.hpp"
54 /// Abstract definition of the hooks for this driver.
57 virtual ~base_hooks(void) = 0;
59 /// Called when the processing of a test case begins.
61 /// \param test_program The test program containing the test case.
62 /// \param test_case_name The name of the test case being executed.
63 virtual void got_test_case(const model::test_program& test_program,
64 const std::string& test_case_name) = 0;
66 /// Called when a result of a test case becomes available.
68 /// \param test_program The test program containing the test case.
69 /// \param test_case_name The name of the executed test case.
70 /// \param result The result of the execution of the test case.
71 /// \param duration The time it took to run the test.
72 virtual void got_result(const model::test_program& test_program,
73 const std::string& test_case_name,
74 const model::test_result& result,
75 const utils::datetime::delta& duration) = 0;
79 /// Tuple containing the results of this driver.
82 /// Filters that did not match any available test case.
84 /// The presence of any filters here probably indicates a usage error. If a
85 /// test filter does not match any test case, it is probably a typo.
86 std::set< engine::test_filter > unused_filters;
88 /// Initializer for the tuple's fields.
90 /// \param unused_filters_ The filters that did not match any test case.
91 result(const std::set< engine::test_filter >& unused_filters_) :
92 unused_filters(unused_filters_)
98 result drive(const utils::fs::path&, const utils::optional< utils::fs::path >,
99 const utils::fs::path&, const std::set< engine::test_filter >&,
100 const utils::config::tree&, base_hooks&);
103 } // namespace run_tests
104 } // namespace drivers
106 #endif // !defined(DRIVERS_RUN_TESTS_HPP)