diff options
Diffstat (limited to 'odb-tests/build')
-rw-r--r-- | odb-tests/build/.gitignore | 3 | ||||
-rw-r--r-- | odb-tests/build/bootstrap.build | 9 | ||||
-rw-r--r-- | odb-tests/build/export.build | 9 | ||||
-rw-r--r-- | odb-tests/build/root.build | 439 |
4 files changed, 460 insertions, 0 deletions
diff --git a/odb-tests/build/.gitignore b/odb-tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/odb-tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/odb-tests/build/bootstrap.build b/odb-tests/build/bootstrap.build new file mode 100644 index 0000000..2fb5824 --- /dev/null +++ b/odb-tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : GNU GPL v2; see accompanying LICENSE file + +project = odb-tests + +using version +using config +using dist +using test diff --git a/odb-tests/build/export.build b/odb-tests/build/export.build new file mode 100644 index 0000000..3c073d3 --- /dev/null +++ b/odb-tests/build/export.build @@ -0,0 +1,9 @@ +# file : build/export.build +# license : GNU GPL v2; see accompanying LICENSE file + +$out_root/ +{ + include libcommon/ +} + +export $out_root/libcommon/$import.target diff --git a/odb-tests/build/root.build b/odb-tests/build/root.build new file mode 100644 index 0000000..1d22b4c --- /dev/null +++ b/odb-tests/build/root.build @@ -0,0 +1,439 @@ +# file : build/root.build +# license : GNU GPL v2; see accompanying LICENSE file + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +define sql: file +sql{*}: extension = sql + +define xml: file +xml{*}: extension = xml + +skeleton = ($build.mode == 'skeleton') + +# List of the identifiers of the databases to compile and run the tests +# against. The valid identifiers are mysql, sqlite, pgsql, oracle, and mssql. +# +# Note: can be specified by the user but is also conditionally reflected by +# the libodb-* libraries' tests manifest values. +# +config [string_set] config.odb_tests.database + +databases = [strings] ($defined(config.odb_tests.database) \ + ? $config.odb_tests.database \ + : ) + +assert ($skeleton || $size($databases) > 0) \ + 'at least one database must be configured via config.odb_tests.database variable' + +mysql = false +sqlite = false +pgsql = false +oracle = false +mssql = false + +for db: $databases +{ + switch $db + { + case 'mysql' + mysql = true + + case 'sqlite' + sqlite = true + + case 'pgsql' + pgsql = true + + case 'oracle' + oracle = true + + case 'mssql' + mssql = true + + default + fail "invalid database '$db' specified in config.odb_tests.database value" + } +} + +# If true, then build and run the test drivers in the dynamic multi-database +# mode. +# +# Note: do not assign the default value so that if it's not specified by the +# user, then it won't be saved into config.build. Failed that, if we need to +# reconfigure a single-database configuration into multi (or vise-versa), then +# we will have to (remember to) override the saved multi_database value +# explicitly. +# +config [bool, config.report.variable=multi] config.odb_tests.multi_database + +multi = ($defined(config.odb_tests.multi_database) \ + ? $config.odb_tests.multi_database \ + : $size($databases) > 1) + +assert ($skeleton || $multi || $size($databases) == 1) \ + 'only one database can be configured if config.odb_tests.multi_database value is false' + +# If true, then this package is enabled as an external test for libodb library +# (see libodb's manifest for details). +# +# Note that this variable is not used in this package itself. +# +config [bool] config.odb_tests.libodb_test ?= false + +# If true, then build and run the boost/* tests. +# +config [bool] config.odb_tests.boost ?= false + +boost = $config.odb_tests.boost + +# If defined, then, depending on the value, build and run the qt/* tests +# against Qt5 (5) or Qt6 (6). +# +config [uint64] config.odb_tests.qt + +qt = $defined(config.odb_tests.qt) + +if $qt +{ + qt_ver = $config.odb_tests.qt + + assert ($qt_ver == 5 || $qt_ver == 6) \ + 'config.odb_tests.qt value must be between 5 and 6' +} + +# Database connections. +# + +# MySQL +# +# The database user. +# +config [string] config.odb_tests.mysql.user ?= 'odb_test' + +# The database password. +# +config [string] config.odb_tests.mysql.passwd + +# The database name. Note that it WILL BE MODIFIED by the tests. +# +config [string] config.odb_tests.mysql.database ?= 'odb_test' + +# The database host. +# +config [string] config.odb_tests.mysql.host + +# The database port. +# +config [uint64] config.odb_tests.mysql.port + +# The database socket path. +# +config [path] config.odb_tests.mysql.socket + +# PostgreSQL +# +# The database user. Note that the named user must be allowed to connect to +# the database server without specifying credentials. +# +config [string] config.odb_tests.pgsql.user ?= 'odb_test' + +# The database name. Note that it WILL BE MODIFIED by the tests. +# +config [string] config.odb_tests.pgsql.database ?= 'odb_test' + +# The database host or directory of Unix-domain socket. Leaving this variable +# undefined results in using Unix-domain sockets. Machines without Unix-domain +# sockets will connect to localhost. +# +config [string] config.odb_tests.pgsql.host + +# The database port or the socket file name extension for Unix-domain +# connections. +# +# For example, specifying: +# +# config.odb_tests.pgsql.host=/var/run/postgresql +# config.odb_tests.pgsql.port=5433 +# +# Will result in the /var/run/postgresql/.s.PGSQL.5433 socket being used. +# +config [string] config.odb_tests.pgsql.port + +# If true, then assume that libodb-pgsql supports the bulk operations. +# +# Note: config.odb_tests.pgsql.bulk_default is reflected from manifest. +# +config [bool] config.odb_tests.pgsql.bulk_default ?= false +config [bool] config.odb_tests.pgsql.bulk ?= $config.odb_tests.pgsql.bulk_default +pgsql_bulk = $config.odb_tests.pgsql.bulk + +# Oracle +# +# The database user. +# +config [string] config.odb_tests.oracle.user ?= 'odb_test' + +# The database password. +# +config [string] config.odb_tests.oracle.passwd + +# The database host. +# +config [string] config.odb_tests.oracle.host + +# The database port. +# +config [uint64] config.odb_tests.oracle.port + +# The service name. Note that the database associated with this user on this +# service WILL BE MODIFIED by the tests. +# +config [string] config.odb_tests.oracle.service + +# Microsoft SQL Server +# +# The database user. +# +config [string] config.odb_tests.mssql.user ?= 'odb_test' + +# The database password. +# +config [string] config.odb_tests.mssql.passwd + +# The database name. Note that it WILL BE MODIFIED by the tests. +# +config [string] config.odb_tests.mssql.database ?= 'odb_test' + +# The database host. +# +config [string] config.odb_tests.mssql.host + +# The database port. +# +config [uint64] config.odb_tests.mssql.port + +# The SQL Server instance address. +# +# Note: mutually exclusive with config.odb_tests.mssql.{host,port}. +# +config [string] config.odb_tests.mssql.server + +assert (!$defined(config.odb_tests.mssql.server) || \ + !$defined(config.odb_tests.mssql.host)) \ + 'variables config.odb_tests.mssql.server and config.odb_tests.mssql.host cannot be specified both' + +assert (!$defined(config.odb_tests.mssql.server) || \ + !$defined(config.odb_tests.mssql.port)) \ + 'variables config.odb_tests.mssql.server and config.odb_tests.mssql.port cannot be specified both' + +# The SQL Server ODBC Driver. +# +config [string, null] config.odb_tests.mssql.driver + +if! $skeleton +{ + if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + + switch $cxx.class + { + case 'gcc' + { + cxx.coptions += -Wno-unknown-pragmas + } + case 'msvc' + { + cxx.coptions += /wd4068 /wd4251 /wd4275 /wd4800 + } + } + + # Import odb that we are testing. + # + import! [metadata] odb = odb%exe{odb} + + # Import the mysql client for creating the database schemas, etc. + # + if $mysql + { + import! mysql_client = mysql-client%exe{mysql} + testscript{*}: mysql_client = $mysql_client + } + + # Import the psql client for creating the database schemas, etc. + # + if $pgsql + { + import! pgsql_client = psql%exe{psql} + testscript{*}: pgsql_client = $pgsql_client + } + + # Import the sqlplus client for creating the database schemas, etc. + # + # Note: expected to be system-installed. + # + if $oracle + { + import! oracle_client = sqlplus%exe{sqlplus} + testscript{*}: oracle_client = $oracle_client + } + + # Import the sqlcmd client for creating the database schemas, etc. + # + # Note: expected to be system-installed. + # + if $mssql + { + import! mssql_client = sqlcmd%exe{sqlcmd} + testscript{*}: mssql_client = $mssql_client + } + + # Notes: + # + # - The second prerequisite ($<[1]) is expected to be a metadata library + # target which we will use to extract the poptions variable value for + # specifying the contained options on the ODB compiler command line. + # + # - The additional options for the ODB compiler command line must be + # specified via the odb_options variable. + # + # - If the pre/post-migration SQL files are being generated, then the + # version numbers the object model is being migrated through must be + # specified via the schema_versions variable in the NNN form (001 002, + # etc; see the implementation for details). + # + # Also note that we need ((-.+)?) instead of just (-.+)? because we use this + # capture as a back-reference in the pattern. + # + [rule_name=odb_compile] \ + <hxx{~'/(.+)-odb((-.+)?)/'} \ + ixx{~'/\1-odb\2/'} \ + cxx{~'/\1-odb\2/'}>: hxx{~'/\1/'} libue{~'/.+-meta/'} $odb + {{ + pops = $cxx.lib_poptions($<[1]) + depdb hash $pops + + hp = $path($>[0]) + bn = $base($leaf($hp)) + db = $regex.replace($bn, '.+-odb(-(.+))?', '\2') + + if ($db == '') # *-odb.?xx target group? + db = ($multi ? 'common' : $databases[0]) + end + + # If the external SQL schema file will be generated, then add it as a + # dynamic target group member. + # + # @@ BUILD2 Probably we should add support for --generate-dep ODB compiler + # option. Then presumably this will be take care of automatically. + # + # We assume that the '--generate-schema' and '--schema-format' strings + # will never appear as standalone option values. + # + if ($db != 'common' && $regex.find_match($odb_options, '--generate-schema')) + schema_format = ($db == 'sqlite' ? 'embedded' : 'sql') + + for o: $odb_options + if ($o == '--schema-format') + schema_format = [null] # Indicate that the schema format comes next. + elif ($schema_format == [null]) + schema_format = $o + end + end + else + schema_format = '' + end + + ts = ($schema_format == 'sql' \ + ? "$directory($hp)/$regex.replace($bn, '(.+)-odb(-.+)?', '\1\2').sql" \ + : '') + + # If the object model change log and/or migration SQL files will be + # generated, then add them as a dynamic target group member. While at it, + # check if the --std options is specified. + # + changelog = '' + init_changelog = false + suppress_migration = false + std = false + + for o: $odb_options + if ($o == '--changelog') + changelog = [null] # Indicate that the changelog path comes next. + elif ($changelog == [null]) + changelog = $o + elif ($o == '--init-changelog') + init_changelog = true + elif ($o == '--suppress-migration') + suppress_migration = true + elif ($o == '--std') + std = true + end + end + + if ($changelog != '') + if ($init_changelog) + ts = ($ts == '' ? "$changelog" : "$ts$\n$changelog") + end + + if ($schema_format == 'sql' && !$suppress_migration) + n = $base($leaf($path($<[0]))) + + # Note that it's not easy to deduce the object model migration files + # list. Thus, we expect the version numbers the object model is being + # migrated through to be explicitly specified via the schema_versions + # variable. + # + for v: $schema_versions + ns = "$out_base/$n-$v-pre.sql$\n$out_base/$n-$v-post.sql" + ts = ($ts == '' ? "$ns" : "$ts$\n$ns") + end + end + end + + depdb dyndep --dyn-target --target-what 'generated schema' --format lines \ + -- echo "$ts" + + $odb (!$std ? --std c++11 : ) \ + ($multi ? --multi-database dynamic : ) \ + --database $db \ + --output-dir $out_base \ + $odb_options \ + "-I$src_base" \ + $pops \ + $path($<[0]) + }} + + # Every exe{} in this project is by default a test. + # + exe{*}: test = true + + # Specify the test target for cross-testing. + # + test.target = $cxx.target +} + +# The helper targets which can be used as prerequisites of test drivers which +# require either a specific database client or multiple clients for all the +# enabled databases. +# +alias{mysql-client}: $mysql_client: +{ + include = $mysql + clean = false +} + +alias{pgsql-client}: $pgsql_client: +{ + include = $pgsql + clean = false +} + +alias{database-client}: alias{mysql-client pgsql-client} |