Path: blob/main/contrib/kyua/drivers/list_tests.cpp
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#include "drivers/list_tests.hpp"2930#include "engine/exceptions.hpp"31#include "engine/filters.hpp"32#include "engine/kyuafile.hpp"33#include "engine/scanner.hpp"34#include "engine/scheduler.hpp"35#include "model/test_program.hpp"36#include "utils/optional.ipp"3738namespace config = utils::config;39namespace fs = utils::fs;40namespace scheduler = engine::scheduler;4142using utils::optional;434445/// Pure abstract destructor.46drivers::list_tests::base_hooks::~base_hooks(void)47{48}495051/// Executes the operation.52///53/// \param kyuafile_path The path to the Kyuafile to be loaded.54/// \param build_root If not none, path to the built test programs.55/// \param filters The test case filters as provided by the user.56/// \param user_config The end-user configuration properties.57/// \param hooks The hooks for this execution.58///59/// \returns A structure with all results computed by this driver.60drivers::list_tests::result61drivers::list_tests::drive(const fs::path& kyuafile_path,62const optional< fs::path > build_root,63const std::set< engine::test_filter >& filters,64const config::tree& user_config,65base_hooks& hooks)66{67scheduler::scheduler_handle handle = scheduler::setup();6869const engine::kyuafile kyuafile = engine::kyuafile::load(70kyuafile_path, build_root, user_config, handle);7172engine::scanner scanner(kyuafile.test_programs(), filters);7374while (!scanner.done()) {75const optional< engine::scan_result > result = scanner.yield();76INV(result);77hooks.got_test_case(*result.get().first, result.get().second);78}7980handle.cleanup();8182return result(scanner.unused_filters());83}848586