Path: blob/main/contrib/kyua/drivers/run_tests.hpp
39478 views
// Copyright 2011 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file drivers/run_tests.hpp29/// Driver to run a collection of tests.30///31/// This driver module implements the logic to execute a collection of tests.32/// The presentation layer is able to monitor progress by hooking into33/// particular points of the driver.3435#if !defined(DRIVERS_RUN_TESTS_HPP)36#define DRIVERS_RUN_TESTS_HPP3738#include <set>39#include <string>4041#include "engine/filters.hpp"42#include "model/test_program.hpp"43#include "model/test_result_fwd.hpp"44#include "utils/config/tree_fwd.hpp"45#include "utils/datetime_fwd.hpp"46#include "utils/fs/path_fwd.hpp"47#include "utils/optional_fwd.hpp"4849namespace drivers {50namespace run_tests {515253/// Abstract definition of the hooks for this driver.54class base_hooks {55public:56virtual ~base_hooks(void) = 0;5758/// Called when the processing of a test case begins.59///60/// \param test_program The test program containing the test case.61/// \param test_case_name The name of the test case being executed.62virtual void got_test_case(const model::test_program& test_program,63const std::string& test_case_name) = 0;6465/// Called when a result of a test case becomes available.66///67/// \param test_program The test program containing the test case.68/// \param test_case_name The name of the executed test case.69/// \param result The result of the execution of the test case.70/// \param duration The time it took to run the test.71virtual void got_result(const model::test_program& test_program,72const std::string& test_case_name,73const model::test_result& result,74const utils::datetime::delta& duration) = 0;75};767778/// Tuple containing the results of this driver.79class result {80public:81/// Filters that did not match any available test case.82///83/// The presence of any filters here probably indicates a usage error. If a84/// test filter does not match any test case, it is probably a typo.85std::set< engine::test_filter > unused_filters;8687/// Initializer for the tuple's fields.88///89/// \param unused_filters_ The filters that did not match any test case.90result(const std::set< engine::test_filter >& unused_filters_) :91unused_filters(unused_filters_)92{93}94};959697result drive(const utils::fs::path&, const utils::optional< utils::fs::path >,98const utils::fs::path&, const std::set< engine::test_filter >&,99const utils::config::tree&, base_hooks&);100101102} // namespace run_tests103} // namespace drivers104105#endif // !defined(DRIVERS_RUN_TESTS_HPP)106107108