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 46 namespace engine { 47 namespace drivers { 48 namespace list_tests { 49 50 51 /// Abstract definition of the hooks for this driver. 52 class base_hooks { 53 public: 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. 64 class result { 65 public: 66 /// Filters that did not match any available test case. 67 /// 68 /// The presence of any filters here probably indicates a usage error. If a 69 /// test filter does not match any test case, it is probably a typo. 70 std::set< test_filter > unused_filters; 71 72 /// Initializer for the tuple's fields. 73 /// 74 /// \param unused_filters_ The filters that did not match any test case. result(const std::set<test_filter> & unused_filters_)75 result(const std::set< test_filter >& unused_filters_) : 76 unused_filters(unused_filters_) 77 { 78 } 79 }; 80 81 82 result drive(const utils::fs::path&, const utils::optional< utils::fs::path >, 83 const std::set< test_filter >&, base_hooks&); 84 85 86 } // namespace list_tests 87 } // namespace drivers 88 } // namespace engine 89 90 #endif // !defined(ENGINE_DRIVERS_LIST_TESTS_HPP) 91