Remove compare.sh scripts and invoke sqldiff directly from CMake

This commit is contained in:
2023-07-20 11:25:24 +02:00
parent b988544be2
commit c352ca4372
3 changed files with 6 additions and 26 deletions

View File

@@ -28,7 +28,7 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors:
# Authors:
# Derek Christ
###############################################
@@ -62,8 +62,6 @@ function(test_standard standard test_name base_config resource_dir output_filena
# Put all the generated files into a subdirectory
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_name})
configure_file(compare.sh ${test_name}/compare.sh)
# Test to create database
add_test(
NAME Regression${test_name}.CreateDatabase
@@ -78,20 +76,21 @@ function(test_standard standard test_name base_config resource_dir output_filena
add_test(
NAME Regression${test_name}.SqlDiff
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_name}
COMMAND compare.sh
COMMAND sqldiff ${CMAKE_CURRENT_SOURCE_DIR}/${standard}/expected/${output_filename} ${output_filename}
)
set_tests_properties(Regression${test_name}.SqlDiff PROPERTIES FIXTURES_REQUIRED Regression${test_name}.CreateDatabase)
# Tests to diff individual tables
foreach(table IN LISTS TABLES_TO_COMPARE)
configure_file(compare_table.sh ${test_name}/compare_table-${table}.sh)
add_test(
NAME Regression${test_name}.SqlDiff.${table}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_name}
COMMAND compare_table-${table}.sh
COMMAND sqldiff --table ${table} ${CMAKE_CURRENT_SOURCE_DIR}/${standard}/expected/${output_filename} ${output_filename}
)
set_tests_properties(Regression${test_name}.SqlDiff.${table} PROPERTIES FIXTURES_REQUIRED Regression${test_name}.CreateDatabase)
# Only pass test if output is empty
set_tests_properties(Regression${test_name}.SqlDiff.${table} PROPERTIES PASS_REGULAR_EXPRESSION "^$")
endforeach()
endfunction()

View File

@@ -1,9 +0,0 @@
#!/bin/bash
# When comparing the whole database, we do not care if there are differences or not.
# The tables that need to be checked have their own tests.
# The purpose of this script is solely to output the differences of the two databases
# so that they can be inspected easily.
sqldiff ${CMAKE_CURRENT_SOURCE_DIR}/${standard}/expected/${output_filename} ${output_filename}
exit 0

View File

@@ -1,10 +0,0 @@
#!/bin/bash
stdout=$(sqldiff --table ${table} ${CMAKE_CURRENT_SOURCE_DIR}/${standard}/expected/${output_filename} ${output_filename})
if [[ $stdout ]]; then
echo $stdout
exit -1
else
exit 0
fi