diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4681ef2f..cc6036ed 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -90,7 +90,58 @@ target_include_directories( common ) _mysql_common_target_settings(mysql_integrationtests) + +# Regular integration tests add_test( NAME mysql_integrationtests - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/integration/run_tests.py -) \ No newline at end of file + COMMAND + ${CMAKE_CURRENT_BINARY_DIR}/mysql_integrationtests + "--gtest_filter=-*RequiresSha256*" # Exclude anything using SHA256 +) + +if (NOT DEFINED ENV{MYSQL_SKIP_DB_SETUP}) + add_test( + NAME mysql_integrationtests_setup + COMMAND + ${Python3_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/test/common/run_sql.py + ${CMAKE_CURRENT_SOURCE_DIR}/integration/db_setup.sql + ) + set_tests_properties( + mysql_integrationtests_setup + PROPERTIES FIXTURES_SETUP mysql_integrationtests_fixture + ) + + set_tests_properties( + mysql_integrationtests + PROPERTIES FIXTURES_REQUIRED mysql_integrationtests_setup + ) +endif() + +# SHA256 tests +if (DEFINED ENV{MYSQL_HAS_SHA256}) + # Setup + add_test( + NAME mysql_integrationtests_sha256_setup + COMMAND + ${Python3_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/test/common/run_sql.py + ${CMAKE_CURRENT_SOURCE_DIR}/integration/db_setup_sha256.sql + ) + set_tests_properties( + mysql_integrationtests_sha256_setup + PROPERTIES FIXTURES_SETUP mysql_integrationtests_sha256_fixture + ) + + # Actual tests + add_test( + NAME mysql_integrationtests_sha256 + COMMAND + ${CMAKE_CURRENT_BINARY_DIR}/mysql_integrationtests + "--gtest_filter=*RequiresSha256*" # Run only SHA256 stuff + ) + set_tests_properties( + mysql_integrationtests_sha256 + PROPERTIES FIXTURES_REQUIRED mysql_integrationtests_sha256_fixture + ) +endif() diff --git a/test/integration/run_tests.py b/test/integration/run_tests.py deleted file mode 100644 index c5a96933..00000000 --- a/test/integration/run_tests.py +++ /dev/null @@ -1,39 +0,0 @@ -from subprocess import run -import os -from os import path, environ - -def get_executable_name(name): - if os.name == 'nt': - name += '.exe' - return name - -def run_sql_file(fname): - print('Running SQL setup file: {}'.format(fname)) - with open(fname, 'rb') as f: - sql = f.read() - run([get_executable_name('mysql'), '-u', 'root'], input=sql, check=True) - -def main(): - has_sha256 = 'MYSQL_HAS_SHA256' in environ - this_file_dir = path.dirname(path.abspath(__file__)) - - # Run setup - if not 'MYSQL_SKIP_DB_SETUP' in environ: - run_sql_file(path.join(this_file_dir, 'db_setup.sql')) - - # Path to the test binary - test_exe = path.join(os.getcwd(), 'mysql_integrationtests') - if os.name == 'nt': - test_exe += '.exe' - - # Run tests - if 'MYSQL_HAS_SHA256' in environ: - run_sql_file(path.join(this_file_dir, 'db_setup_sha256.sql')) - print('Running integration tests with SHA256 support') - run([test_exe], check=True) - else: - print('Running integration tests without SHA256 support') - run([test_exe, '--gtest_filter=-*RequiresSha256*'], check=True) # Exclude anything containing RequiresSha256 - -if __name__ == '__main__': - main()