xapian-core  1.4.19
testrunner.h
Go to the documentation of this file.
1 
4 /* Copyright 2008 Lemur Consulting Ltd
5  * Copyright 2008,2009,2014,2015,2017,2018 Olly Betts
6  *
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.
11  *
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.
16  *
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
21  */
22 
23 #ifndef XAPIAN_INCLUDED_TESTRUNNER_H
24 #define XAPIAN_INCLUDED_TESTRUNNER_H
25 
26 #include <string>
27 
28 class BackendManager;
29 
32 
36 class TestRunner {
39  std::string user_backend;
40 
46 
49  std::string srcdir;
50 
53  bool use_backend(const std::string & backend_name);
54 
57  void set_properties_for_backend(const std::string & backend_name);
58 
60 
64  do_tests_for_backend_(&manager);
65  }
66 
68  do_tests_for_backend_(&manager);
69  }
70 
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  CHERT = 0x00004000,
88  GLASS = 0x00008000,
89  COMPACT = 0x00010000,
91  PATH = 0x00020000,
92  };
93 
94  public:
96  unsigned properties;
97 
99  virtual ~TestRunner();
100 
106  int run_tests(int argc, char ** argv);
107 
113  virtual int run() const = 0;
114 };
115 
116 #endif // XAPIAN_INCLUDED_TESTRUNNER_H
virtual int run() const =0
Run the tests with a particular backend.
const char * backend_name(int code)
Definition: backends.h:33
BackendManager * backendmanager
backendmanager is global so that it can be accessed by individual tests.
Definition: testrunner.cc:42
std::string srcdir
The source directory, read from the test driver.
Definition: testrunner.h:49
void set_properties_for_backend(const std::string &backend_name)
Set the property flags to those for the named backend.
Definition: testrunner.cc:59
virtual ~TestRunner()
Virtual destructor - needed for abstract class.
Definition: testrunner.cc:44
int run_tests(int argc, char **argv)
Run all the tests.
Definition: testrunner.cc:137
bool use_backend(const std::string &backend_name)
Return true iff we should use the named backend.
Definition: testrunner.cc:47
void do_tests_for_backend(BackendManager &manager)
Definition: testrunner.h:67
int result_so_far
Result of running tests so far.
Definition: testrunner.h:45
void do_tests_for_backend_(BackendManager *manager)
Definition: testrunner.cc:123
A test runner, which runs the tests (implemented by subclassing it) with a variety of backends...
Definition: testrunner.h:36
Requires get_database_path() or similar.
Definition: testrunner.h:91
void do_tests_for_backend(BackendManager &&manager)
Run the tests with the specified backend.
Definition: testrunner.h:63
std::string user_backend
Backend specified by the user (or empty if none was specified).
Definition: testrunner.h:39
unsigned properties
Property bitmask.
Definition: testrunner.h:96