diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-06-21 10:39:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-06-21 10:39:59 +0200 |
commit | 6cd8b9f561b912f264ba4f723845935c40a3cb95 (patch) | |
tree | 5983e0af3d2ee621242ca6707a58c89b9914d8f0 /common/circular/multiple | |
parent | 236cd9bb1dd022e64d690c9b0080d1a15c5f61c7 (diff) |
Add support for running tests in dynamic multi-database mode
Only possible in the development build system at this stage.
Diffstat (limited to 'common/circular/multiple')
-rw-r--r-- | common/circular/multiple/driver.cxx | 19 | ||||
-rw-r--r-- | common/circular/multiple/makefile | 28 |
2 files changed, 21 insertions, 26 deletions
diff --git a/common/circular/multiple/driver.cxx b/common/circular/multiple/driver.cxx index cc730be..09a34e7 100644 --- a/common/circular/multiple/driver.cxx +++ b/common/circular/multiple/driver.cxx @@ -15,7 +15,6 @@ #include <odb/transaction.hxx> #include <odb/schema-catalog.hxx> -#include <common/config.hxx> // DATABASE_XXX #include <common/common.hxx> #include "test1.hxx" @@ -43,21 +42,19 @@ main (int argc, char* argv[]) // For these databases this is the only way to drop circularly- // dependant tables. // -#if defined(DATABASE_MYSQL) - c->execute ("SET FOREIGN_KEY_CHECKS=0"); -#elif defined(DATABASE_SQLITE) - c->execute ("PRAGMA foreign_keys=OFF"); -#endif + if (db->id () == odb::id_mysql) + c->execute ("SET FOREIGN_KEY_CHECKS=0"); + else if (db->id () == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=OFF"); transaction t (c->begin ()); schema_catalog::create_schema (*db); t.commit (); -#if defined(DATABASE_MYSQL) - c->execute ("SET FOREIGN_KEY_CHECKS=1"); -#elif defined(DATABASE_SQLITE) - c->execute ("PRAGMA foreign_keys=ON"); -#endif + if (db->id () == odb::id_mysql) + c->execute ("SET FOREIGN_KEY_CHECKS=1"); + else if (db->id () == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=ON"); } query<base> bq (query<base>::d->id != 0); diff --git a/common/circular/multiple/makefile b/common/circular/multiple/makefile index 92784d1..d603c82 100644 --- a/common/circular/multiple/makefile +++ b/common/circular/multiple/makefile @@ -6,17 +6,14 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make cxx_tun := driver.cxx odb_hdr := test1.hxx test2.hxx -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) +genf := $(call odb-gen,$(odb_hdr)) +gen := $(addprefix $(out_base)/,$(genf)) +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o)) cxx_od := $(cxx_obj:.o=.o.d) common.l := $(out_root)/libcommon/common/common.l common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options -driver := $(out_base)/driver -dist := $(out_base)/.dist -test := $(out_base)/.test -clean := $(out_base)/.clean - # Import. # $(call import,\ @@ -29,9 +26,6 @@ $(driver): $(cxx_obj) $(common.l) $(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) $(cxx_obj) $(cxx_od): $(common.l.cpp-options) -genf := $(foreach f,$(odb_hdr:.hxx=),$(addprefix $f,-odb.hxx -odb.ixx -odb.cxx .sql)) -gen := $(addprefix $(out_base)/,$(genf)) - $(gen): $(odb) $(gen): odb := $(odb) $(gen) $(dist): export odb_options += --generate-schema --generate-query \ @@ -43,7 +37,11 @@ $(gen): $(common.l.cpp-options) # $(gen): $(addprefix $(src_base)/,$(odb_hdr)) +ifneq ($(db_id),common) $(gen): odb_options += --database $(db_id) +else +$(gen): odb_options += --multi-database dynamic +endif $(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) @@ -71,11 +69,11 @@ $(dist): # Test. # -$(test): $(driver) $(src_base)/test.std - $(call message,test $<,$< --options-file $(dcf_root)/$(db_id).options \ ->$(out_base)/test.out) - $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) - $(call message,,rm -f $(out_base)/test.out) +ifneq ($(db_id),common) +$(eval $(call test-schemaless-rule)) +else +$(foreach d,$(databases),$(eval $(call test-schemaless-rule,$d))) +endif # Clean. # @@ -83,7 +81,7 @@ $(clean): \ $(driver).o.clean \ $(addsuffix .cxx.clean,$(cxx_obj)) \ $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean)) + $(addsuffix .hxx.clean,$(filter %.cxx,$(gen))) $(call message,,rm -f $(out_base)/test.out) # Generated .gitignore. |