mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
Test code in C should use test-specific assertions that throw errors instead of exiting the program with a signal (crash). Not only does this provide more useful and easily accessible information of the failing condition, but it also allows running the test suite without assertions (`USE_ASSERT_CHECKING`) enabled. Having assertions disabled during tests also provides more accurate test coverage numbers. Note that these test-specific assertions are not intended to replace regular assertions (`Assert`), which are used in non-test code. The way to enable (or disable) assertions in CMake has also been simplified and cleaned up. The option `-DASSERTIONS=[ON|OFF]` can be used to enable assertions for a build, unless already enabled in the PostgreSQL one is building against (in which case that setting takes precedence). Note that the `ASSERTIONS` option defaults to `OFF` since it is no longer necessary to have assertions enabled for tests.
25 lines
1.1 KiB
SQL
25 lines
1.1 KiB
SQL
-- This file and its contents are licensed under the Apache License 2.0.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-APACHE for a copy of the license.
|
|
|
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
|
CREATE OR REPLACE FUNCTION test.condition() RETURNS VOID
|
|
AS :MODULE_PATHNAME, 'ts_test_utils_condition' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
|
CREATE OR REPLACE FUNCTION test.int64_eq() RETURNS VOID
|
|
AS :MODULE_PATHNAME, 'ts_test_utils_int64_eq' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
|
CREATE OR REPLACE FUNCTION test.ptr_eq() RETURNS VOID
|
|
AS :MODULE_PATHNAME, 'ts_test_utils_ptr_eq' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
|
CREATE OR REPLACE FUNCTION test.double_eq() RETURNS VOID
|
|
AS :MODULE_PATHNAME, 'ts_test_utils_double_eq' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
|
|
|
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER;
|
|
|
|
-- We're testing that the test utils work and generate errors on
|
|
-- failing conditions
|
|
\set ON_ERROR_STOP 0
|
|
SELECT test.condition();
|
|
SELECT test.int64_eq();
|
|
SELECT test.ptr_eq();
|
|
SELECT test.double_eq();
|
|
\set ON_ERROR_STOP 1
|