Add test harness backend flag "compact"
[xapian.git] / xapian-core / tests / harness / testrunner.h
blob9138fd8042f882fca6b84a3b2b9365eaadb1c127
1 /** @file testrunner.h
2 * @brief Run multiple tests for different backends.
3 */
4 /* Copyright 2008 Lemur Consulting Ltd
5 * Copyright 2008,2009,2014,2015,2017,2018 Olly Betts
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
23 #ifndef XAPIAN_INCLUDED_TESTRUNNER_H
24 #define XAPIAN_INCLUDED_TESTRUNNER_H
26 #include <string>
28 class BackendManager;
30 /// backendmanager is global so that it can be accessed by individual tests.
31 extern BackendManager * backendmanager;
33 /** A test runner, which runs the tests (implemented by subclassing it) with
34 * a variety of backends.
36 class TestRunner {
37 /** Backend specified by the user (or empty if none was specified).
39 std::string user_backend;
41 /** Result of running tests so far.
43 * Actually, the maximum value returned by run() so far.
45 int result_so_far;
47 /** The source directory, read from the test driver.
49 std::string srcdir;
51 /** Return true iff we should use the named backend.
53 bool use_backend(const std::string & backend_name);
55 /** Set the property flags to those for the named backend.
57 void set_properties_for_backend(const std::string & backend_name);
59 void do_tests_for_backend_(BackendManager* manager);
61 /** Run the tests with the specified backend.
63 void do_tests_for_backend(BackendManager&& manager) {
64 do_tests_for_backend_(&manager);
67 void do_tests_for_backend(BackendManager& manager) {
68 do_tests_for_backend_(&manager);
71 protected:
72 enum {
73 BACKEND = 0x00000001,
74 REMOTE = 0x00000002,
75 TRANSACTIONS = 0x00000004,
76 POSITIONAL = 0x00000008,
77 WRITABLE = 0x00000010,
78 SPELLING = 0x00000020,
79 METADATA = 0x00000040,
80 SYNONYMS = 0x00000080,
81 REPLICAS = 0x00000100,
82 VALUESTATS = 0x00000200,
83 GENERATED = 0x00000400,
84 MULTI = 0x00000800,
85 SINGLEFILE = 0x00001000,
86 INMEMORY = 0x00002000,
87 GLASS = 0x00004000,
88 COMPACT = 0x00008000,
91 public:
92 /// Property bitmask.
93 unsigned properties;
95 /// Virtual destructor - needed for abstract class.
96 virtual ~TestRunner();
98 /** Run all the tests.
100 * This should be passed the command line arguments supplied to main,
101 * and will parse them for options.
103 int run_tests(int argc, char ** argv);
105 /** Run the tests with a particular backend.
107 * Properties of the backend can be determined by checking the settings of
108 * the flags.
110 virtual int run() const = 0;
113 #endif // XAPIAN_INCLUDED_TESTRUNNER_H