summaryrefslogtreecommitdiff
path: root/odb-tests/evolution/combined
diff options
context:
space:
mode:
Diffstat (limited to 'odb-tests/evolution/combined')
-rw-r--r--odb-tests/evolution/combined/buildfile64
-rw-r--r--odb-tests/evolution/combined/driver.cxx17
-rw-r--r--odb-tests/evolution/combined/model.hxx2
-rw-r--r--odb-tests/evolution/combined/testscript54
4 files changed, 130 insertions, 7 deletions
diff --git a/odb-tests/evolution/combined/buildfile b/odb-tests/evolution/combined/buildfile
new file mode 100644
index 0000000..0ccce68
--- /dev/null
+++ b/odb-tests/evolution/combined/buildfile
@@ -0,0 +1,64 @@
+# file : evolution/combined/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+if ($build.meta_operation != 'dist')
+ assert (!$multi) "multi-database mode is not supported by this test"
+
+db = ($databases[0])
+
+import libodb = libodb%lib{odb}
+import libodb_db = libodb-$db%lib{odb-$db}
+import libcommon = lib{common}
+
+hdrs = test1 test2 test3
+
+exe{driver}: {hxx cxx}{* -*-odb} testscript
+
+# Introduce the metadata library target to make sure the libodb and libcommon
+# libraries are resolved for the odb_compile ad hoc rule (see build/root.build
+# for details).
+#
+libue{test-meta}: $libodb $libcommon
+
+for h: $hdrs
+ exe{driver}: {hxx ixx cxx}{$h-odb}: hxx{$h} libue{test-meta} hxx{model}
+
+# Make sure testN.hxx are compiled serially since they share the changelog.
+#
+# @@ TODO: make order-only when supported by build2.
+#
+{hxx ixx cxx}{test3-odb}: {hxx ixx cxx}{test2-odb}: {hxx ixx cxx}{test1-odb}
+
+exe{driver}: libue{test-meta} $libodb_db
+
+# Specify the ODB custom options to be used by the odb_compile ad hoc rule
+# (see build/root.build for details).
+#
+odb_options = --table-prefix evo_comb_ \
+ --schema-version-table evo_comb_sv \
+ --generate-schema \
+ --generate-query \
+ --at-once \
+ --changelog $out_base/model.xml \
+ --sqlite-override-null
+
+<{hxx ixx cxx}{test1-odb}>: odb_options += --init-changelog
+<{hxx ixx cxx}{test2-odb}>: odb_options += --omit-create --suppress-migration
+
+<{hxx ixx cxx}{test3-odb}>:
+{
+ odb_options += --omit-create
+ schema_versions = 002 003
+}
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../alias{database-client}: include = adhoc
+
+testscript@./:
+{
+ db = $db
+ schemas = $hdrs
+}
diff --git a/odb-tests/evolution/combined/driver.cxx b/odb-tests/evolution/combined/driver.cxx
index 88453c3..027bddd 100644
--- a/odb-tests/evolution/combined/driver.cxx
+++ b/odb-tests/evolution/combined/driver.cxx
@@ -4,21 +4,23 @@
// Combined schema evolution test.
//
-#include <memory> // std::auto_ptr
-#include <cassert>
+#include <memory> // std::unique_ptr
#include <iostream>
#include <odb/database.hxx>
#include <odb/transaction.hxx>
#include <odb/schema-catalog.hxx>
-#include <common/common.hxx>
+#include <libcommon/common.hxx>
#include "test2.hxx"
#include "test3.hxx"
#include "test2-odb.hxx"
#include "test3-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
using namespace odb::core;
@@ -27,7 +29,10 @@ main (int argc, char* argv[])
{
try
{
- auto_ptr<database> db (create_database (argc, argv, false));
+ unique_ptr<database> db (create_database (argc, argv, false));
+
+ db->schema_version_table ("evo_comb_sv");
+
bool embedded (schema_catalog::exists (*db));
// 1 - base version
@@ -89,7 +94,7 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- auto_ptr<object> p (db->load<object> ("1"));
+ unique_ptr<object> p (db->load<object> ("1"));
assert (p->ac1 == 999);
assert (!p->ac2);
@@ -126,7 +131,7 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- auto_ptr<object> p (db->load<object> ("1"));
+ unique_ptr<object> p (db->load<object> ("1"));
// Check post-migration.
//
diff --git a/odb-tests/evolution/combined/model.hxx b/odb-tests/evolution/combined/model.hxx
index e924943..5f1180b 100644
--- a/odb-tests/evolution/combined/model.hxx
+++ b/odb-tests/evolution/combined/model.hxx
@@ -11,7 +11,7 @@
#include <odb/core.hxx>
#include <odb/nullable.hxx>
-#include <common/config.hxx> // DATABASE_XXX
+#include <libcommon/config.hxx> // DATABASE_XXX
#pragma db model version(1, MODEL_VERSION)
diff --git a/odb-tests/evolution/combined/testscript b/odb-tests/evolution/combined/testscript
new file mode 100644
index 0000000..a7bb826
--- /dev/null
+++ b/odb-tests/evolution/combined/testscript
@@ -0,0 +1,54 @@
+# file : evolution/combined/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../database-options.testscript
+.include ../../$db-schema.testscript
+
+test.arguments += $($(db)_options)
+
+: basics
+:
+if! $sqlite
+{
+ ss =; # Schema modification base file names.
+
+ # Drop everything.
+ #
+ for s: $schemas
+ ss =+ $s
+ end;
+
+ # Add base schema.
+ #
+ ss += test3-002-pre test3-002-post;
+
+ # Add migration.
+ #
+ ss += test3-003-pre test3-003-post;
+
+ # Run tests.
+ #
+ for s: $ss
+ f = $out_base/"$s".sql
+
+ if $mysql
+ cat $f | $create_schema_cmd
+ elif $pgsql
+ $create_schema_cmd -f $f
+ end
+
+ if ($s == 'test3-002-post')
+ $* 1
+ elif ($s == 'test3-003-pre')
+ $* 2
+ elif ($s == 'test3-003-post')
+ $* 3
+ end
+ end
+}
+else
+{
+ $* 1 &odb-test.db;
+ $* 2;
+ $* 3
+}