Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/kyua/drivers/run_tests.hpp
39478 views
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/run_tests.hpp
30
/// Driver to run a collection of tests.
31
///
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.
35
36
#if !defined(DRIVERS_RUN_TESTS_HPP)
37
#define DRIVERS_RUN_TESTS_HPP
38
39
#include <set>
40
#include <string>
41
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"
49
50
namespace drivers {
51
namespace run_tests {
52
53
54
/// Abstract definition of the hooks for this driver.
55
class base_hooks {
56
public:
57
virtual ~base_hooks(void) = 0;
58
59
/// Called when the processing of a test case begins.
60
///
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;
65
66
/// Called when a result of a test case becomes available.
67
///
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;
76
};
77
78
79
/// Tuple containing the results of this driver.
80
class result {
81
public:
82
/// Filters that did not match any available test case.
83
///
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;
87
88
/// Initializer for the tuple's fields.
89
///
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_)
93
{
94
}
95
};
96
97
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&);
101
102
103
} // namespace run_tests
104
} // namespace drivers
105
106
#endif // !defined(DRIVERS_RUN_TESTS_HPP)
107
108