Skip to content

Commit

Permalink
Adds unit test checking experimental correctly set
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-dark authored and ihnorton committed Jun 23, 2022
1 parent b757c1d commit 944f089
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -288,7 +288,7 @@ if (TILEDB_TESTS)
add_dependencies(tests tiledb_unit)

add_dependencies(tests unit_buffer unit_datum unit_dynamic_memory)
add_dependencies(tests unit_exception unit_interval unit_thread_pool)
add_dependencies(tests unit_exception unit_interval unit_thread_pool unit_experimental)
add_dependencies(tests unit_array_schema unit_filter_create unit_filter_pipeline unit_metadata)
add_dependencies(tests unit_compressors unit_query unit_misc unit_vfs unit_array)
add_dependencies(tests unit_range_subset)
Expand Down
22 changes: 21 additions & 1 deletion tiledb/common/CMakeLists.txt
Expand Up @@ -61,7 +61,7 @@ add_library(baseline OBJECT
)
find_package(Spdlog_EP REQUIRED)
target_link_libraries(baseline PUBLIC spdlog::spdlog)
target_link_libraries(baseline PRIVATE common)
target_link_libraries(baseline PUBLIC common)
#
# Test-compile of object library ensures link-completeness
#
Expand All @@ -85,3 +85,23 @@ target_link_libraries(compile_stringx PRIVATE stringx)
target_sources(compile_stringx PRIVATE
test/compile_stringx_main.cc $<TARGET_OBJECTS:stringx>
)

if (TILEDB_TESTS)
find_package(Catch_EP REQUIRED)
add_executable(unit_experimental EXCLUDE_FROM_ALL)
target_link_libraries(unit_experimental
PRIVATE baseline
PUBLIC Catch2::Catch2
)
target_sources(unit_experimental
PUBLIC
test/main.cc
$<IF:$<BOOL:${TILEDB_EXPERIMENTAL_FEATURES}>,
test/unit_is_experimental.cc,
test/unit_is_not_experimental.cc>
)
add_test(
NAME "unit_experimental"
COMMAND $<TARGET_FILE:unit_experimental>
)
endif()
34 changes: 34 additions & 0 deletions tiledb/common/test/main.cc
@@ -0,0 +1,34 @@
/**
* @file tiledb/common/test/main.cc
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2022 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @section DESCRIPTION
*
* This file defines a test `main()`
*/

#define CATCH_CONFIG_MAIN
#include <catch.hpp>
41 changes: 41 additions & 0 deletions tiledb/common/test/unit_is_experimental.cc
@@ -0,0 +1,41 @@
/**
* @file unit_is_experimental.cc
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2022 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @section DESCRIPTION
*
* This file tests`is_experimental_build=true` when
* `TILEDB_EXPERIMENTAL_FEATURES=ON`
*/

#include <catch.hpp>
#include "tiledb/common/common.h"

using namespace tiledb::common;

TEST_CASE("TILEDB_EXPERIMENTAL_FEATURES=ON") {
REQUIRE(is_experimental_build);
}
41 changes: 41 additions & 0 deletions tiledb/common/test/unit_is_not_experimental.cc
@@ -0,0 +1,41 @@
/**
* @file unit_is_not_experimental.cc
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2022 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @section DESCRIPTION
*
* This file tests`is_experimental_build=false` when
* `TILEDB_EXPERIMENTAL_FEATURES=OFF`
*/

#include <catch.hpp>
#include "tiledb/common/common.h"

using namespace tiledb::common;

TEST_CASE("TILEDB_EXPERIMENTAL_FEATURES=OFF") {
REQUIRE(!is_experimental_build);
}

0 comments on commit 944f089

Please sign in to comment.