diff --git a/tests/cdb2sql.test/runit b/tests/cdb2sql.test/runit index a290ff0437..16a6a401a1 100755 --- a/tests/cdb2sql.test/runit +++ b/tests/cdb2sql.test/runit @@ -7,45 +7,48 @@ if [[ -z $dbname ]] ; then exit 1 fi -for testreq in `find . -name 't[0-9][0-9].sql' -exec basename {} \;` ; do - testname=`echo $testreq | cut -d "." -f 1` - cmd="cdb2sql -s -f $testreq ${CDB2_OPTIONS} $dbname default " - echo $cmd "> $testname.output" - $cmd 2>&1 | perl -pe "s/.n_writeops_done=([0-9]+)/rows inserted='\1'/; s/BLOCK2_SEQV2\(824\)/BLOCK_SEQ(800)/; s/OP #2 BLOCK_SEQ/OP #3 BLOCK_SEQ/;" > $testname.output +run_test() { + local test_input_file_name=$1 output_file_extension=$2 extra_cdb2sql_opts=$3 - cmd="diff $testname.expected $testname.output" - $cmd > /dev/null + local test_name + test_name=$(echo ${test_input_file_name} | cut -d "." -f 1) - if [[ $? -eq 0 ]]; then - echo "passed $testname" - else - echo "failed $testname" - echo "see diffs here: $HOSTNAME" - echo "> diff -u ${PWD}/{$testname.expected,$testname.output}" - echo - exit 1 - fi -done + local exp_output_file_name=${test_name}${output_file_extension}.expected + local output_file_name=${test_name}${output_file_extension}.output -for testreq in `find . -name 't[0-9][0-9].tab.sql' -exec basename {} \;` ; do - testname=`echo $testreq | cut -d "." -f 1` - cmd="cdb2sql -s -f $testreq ${CDB2_OPTIONS} -tabular $dbname default " - echo $cmd "> $testname.tab.output" - $cmd 2>&1 | perl -pe "s/.n_writeops_done=([0-9]+)/rows inserted='\1'/; s/BLOCK2_SEQV2\(824\)/BLOCK_SEQ(800)/; s/OP #2 BLOCK_SEQ/OP #3 BLOCK_SEQ/;" > $testname.tab.output + local cmd="cdb2sql -s -f ${test_input_file_name} ${CDB2_OPTIONS} ${extra_cdb2sql_opts} ${dbname} default " + echo $cmd "> ${output_file_name}" + $cmd 2>&1 | perl -pe "s/.n_writeops_done=([0-9]+)/rows inserted='\1'/; s/BLOCK2_SEQV2\(824\)/BLOCK_SEQ(800)/; s/OP #2 BLOCK_SEQ/OP #3 BLOCK_SEQ/;" > ${output_file_name} - cmd="diff $testname.tab.expected $testname.tab.output" - $cmd > /dev/null + cmd="diff ${exp_output_file_name} ${output_file_name}" + ${cmd} > /dev/null if [[ $? -eq 0 ]]; then - echo "passed $testname" + echo "passed ${test_name}" else - echo "failed $testname" - echo "see diffs here: $HOSTNAME" - echo "> diff -u ${PWD}/{$testname.tab.expected,$testname.tab.output}" + echo "failed ${test_name}" + echo "see diffs here: ${HOSTNAME}" + echo "> diff -u ${PWD}/{${exp_output_file_name},${output_file_name}}" echo exit 1 fi -done +} + +main() { + local test_input_file_name + + for test_input_file_name in `find . -name 't[0-9][0-9].sql' -exec basename {} \;` ; do + run_test "${test_input_file_name}" + done + + for test_input_file_name in `find . -name 't[0-9][0-9].tab.sql' -exec basename {} \;` ; do + run_test "${test_input_file_name}" ".tab" "-tabular" + done + + for test_input_file_name in `find . -name 't[0-9][0-9].multiline.sql' -exec basename {} \;` ; do + run_test "${test_input_file_name}" ".multiline" "-l" + done +} -echo +main exit 0 diff --git a/tests/cdb2sql.test/t02.multiline.expected b/tests/cdb2sql.test/t02.multiline.expected new file mode 100644 index 0000000000..012223b4c5 --- /dev/null +++ b/tests/cdb2sql.test/t02.multiline.expected @@ -0,0 +1 @@ +(1=1) diff --git a/tests/cdb2sql.test/t02.multiline.sql b/tests/cdb2sql.test/t02.multiline.sql new file mode 100644 index 0000000000..13c7bc8f31 --- /dev/null +++ b/tests/cdb2sql.test/t02.multiline.sql @@ -0,0 +1,3 @@ +-- test complete statment that spans multiple lines +select +1; diff --git a/tests/cdb2sql.test/t03.multiline.expected b/tests/cdb2sql.test/t03.multiline.expected new file mode 100644 index 0000000000..590e17126c --- /dev/null +++ b/tests/cdb2sql.test/t03.multiline.expected @@ -0,0 +1 @@ +(';'=';') diff --git a/tests/cdb2sql.test/t03.multiline.sql b/tests/cdb2sql.test/t03.multiline.sql new file mode 100644 index 0000000000..8c94b78d9f --- /dev/null +++ b/tests/cdb2sql.test/t03.multiline.sql @@ -0,0 +1,4 @@ +-- test complete statment spanning multiple lines that contains +-- a non-terminating semicolon +select ';' +; diff --git a/tests/cdb2sql.test/t04.multiline.expected b/tests/cdb2sql.test/t04.multiline.expected new file mode 100644 index 0000000000..8d973645c5 --- /dev/null +++ b/tests/cdb2sql.test/t04.multiline.expected @@ -0,0 +1,19 @@ +(' +hello +i +am +a +long +multi +line +statement +'=' +hello +i +am +a +long +multi +line +statement +') diff --git a/tests/cdb2sql.test/t04.multiline.sql b/tests/cdb2sql.test/t04.multiline.sql new file mode 100644 index 0000000000..b1b86bf9b7 --- /dev/null +++ b/tests/cdb2sql.test/t04.multiline.sql @@ -0,0 +1,13 @@ +-- test a longer multi-line statement +select +' +hello +i +am +a +long +multi +line +statement +' +; diff --git a/tests/cdb2sql.test/t05.multiline.expected b/tests/cdb2sql.test/t05.multiline.expected new file mode 100644 index 0000000000..30ea48ed70 --- /dev/null +++ b/tests/cdb2sql.test/t05.multiline.expected @@ -0,0 +1,3 @@ +(1=1) +(1=1) +(1=1) diff --git a/tests/cdb2sql.test/t05.multiline.sql b/tests/cdb2sql.test/t05.multiline.sql new file mode 100644 index 0000000000..717dbe0120 --- /dev/null +++ b/tests/cdb2sql.test/t05.multiline.sql @@ -0,0 +1,7 @@ +-- test that we can run back-to-back multi-line statements +select 1 +; +select 1 +; +select 1 +; diff --git a/tests/cdb2sql.test/t06.multiline.expected b/tests/cdb2sql.test/t06.multiline.expected new file mode 100644 index 0000000000..012223b4c5 --- /dev/null +++ b/tests/cdb2sql.test/t06.multiline.expected @@ -0,0 +1 @@ +(1=1) diff --git a/tests/cdb2sql.test/t06.multiline.sql b/tests/cdb2sql.test/t06.multiline.sql new file mode 100644 index 0000000000..b7f53f8509 --- /dev/null +++ b/tests/cdb2sql.test/t06.multiline.sql @@ -0,0 +1,2 @@ + -- test that a non-multiline statement works in multi-line mode + select 1; diff --git a/tests/cdb2sql.test/t07.multiline.expected b/tests/cdb2sql.test/t07.multiline.expected new file mode 100644 index 0000000000..8eb8e3bccc --- /dev/null +++ b/tests/cdb2sql.test/t07.multiline.expected @@ -0,0 +1,4 @@ +(1=1) +(1=1) +(1=1) +(1=1) diff --git a/tests/cdb2sql.test/t07.multiline.sql b/tests/cdb2sql.test/t07.multiline.sql new file mode 100644 index 0000000000..a79a5ee499 --- /dev/null +++ b/tests/cdb2sql.test/t07.multiline.sql @@ -0,0 +1,3 @@ +-- Test that multiple non-multi-line statements work in multi-line mode +select 1; select 1; +select 1; select 1; diff --git a/tests/cdb2sql.test/t08.multiline.expected b/tests/cdb2sql.test/t08.multiline.expected new file mode 100644 index 0000000000..e8c442845b --- /dev/null +++ b/tests/cdb2sql.test/t08.multiline.expected @@ -0,0 +1,5 @@ +(1=1) +(1=1) +(1=1) +(1=1) +(1=1) diff --git a/tests/cdb2sql.test/t08.multiline.sql b/tests/cdb2sql.test/t08.multiline.sql new file mode 100644 index 0000000000..418ec6997e --- /dev/null +++ b/tests/cdb2sql.test/t08.multiline.sql @@ -0,0 +1,7 @@ +-- test that a combination of multi-line and non-multi-line statments work +-- in multi-line mode +select 1; select +1; select 1; +select 1; +select +1; diff --git a/tests/cdb2sql.test/t09.multiline.expected b/tests/cdb2sql.test/t09.multiline.expected new file mode 100644 index 0000000000..8177d29f35 --- /dev/null +++ b/tests/cdb2sql.test/t09.multiline.expected @@ -0,0 +1 @@ +[select] failed: Not a complete statement diff --git a/tests/cdb2sql.test/t09.multiline.sql b/tests/cdb2sql.test/t09.multiline.sql new file mode 100644 index 0000000000..fd660fe58d --- /dev/null +++ b/tests/cdb2sql.test/t09.multiline.sql @@ -0,0 +1,2 @@ +-- test that an incomplete statement is handled properly +select diff --git a/tests/cdb2sql.test/t10.multiline.expected b/tests/cdb2sql.test/t10.multiline.expected new file mode 100644 index 0000000000..135a6e520f --- /dev/null +++ b/tests/cdb2sql.test/t10.multiline.expected @@ -0,0 +1,2 @@ +(1=1) +[select] failed: Not a complete statement diff --git a/tests/cdb2sql.test/t10.multiline.sql b/tests/cdb2sql.test/t10.multiline.sql new file mode 100644 index 0000000000..699cbdc8f8 --- /dev/null +++ b/tests/cdb2sql.test/t10.multiline.sql @@ -0,0 +1,3 @@ +-- test that an incomplete statement following a complete +-- statement is handled properly +select 1; select diff --git a/tests/cdb2sql.test/t11.multiline.expected b/tests/cdb2sql.test/t11.multiline.expected new file mode 100644 index 0000000000..c5e09e73a6 --- /dev/null +++ b/tests/cdb2sql.test/t11.multiline.expected @@ -0,0 +1,2 @@ +[select +1] failed: Not a complete statement diff --git a/tests/cdb2sql.test/t11.multiline.sql b/tests/cdb2sql.test/t11.multiline.sql new file mode 100644 index 0000000000..db5ad67d68 --- /dev/null +++ b/tests/cdb2sql.test/t11.multiline.sql @@ -0,0 +1,3 @@ +-- test that an incomplete multi-line statement is handled properly +select +1 diff --git a/tests/cdb2sql.test/t12.multiline.expected b/tests/cdb2sql.test/t12.multiline.expected new file mode 100644 index 0000000000..37bac57970 --- /dev/null +++ b/tests/cdb2sql.test/t12.multiline.expected @@ -0,0 +1 @@ +[select ';'] failed: Not a complete statement diff --git a/tests/cdb2sql.test/t12.multiline.sql b/tests/cdb2sql.test/t12.multiline.sql new file mode 100644 index 0000000000..4b5be6b7bd --- /dev/null +++ b/tests/cdb2sql.test/t12.multiline.sql @@ -0,0 +1,2 @@ +-- test incomplete statment with a semicolon +select ';' diff --git a/tests/cdb2sql.test/t13.multiline.expected b/tests/cdb2sql.test/t13.multiline.expected new file mode 100644 index 0000000000..d7ea4816e1 --- /dev/null +++ b/tests/cdb2sql.test/t13.multiline.expected @@ -0,0 +1,5 @@ +(' +-- fake comment +'=' +-- fake comment +') diff --git a/tests/cdb2sql.test/t13.multiline.sql b/tests/cdb2sql.test/t13.multiline.sql new file mode 100644 index 0000000000..5c19a2edd3 --- /dev/null +++ b/tests/cdb2sql.test/t13.multiline.sql @@ -0,0 +1,4 @@ +-- test a line that looks like a comment but isn't a comment +select ' +-- fake comment +'; diff --git a/tests/cdb2sql.test/t14.multiline.expected b/tests/cdb2sql.test/t14.multiline.expected new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/cdb2sql.test/t14.multiline.sql b/tests/cdb2sql.test/t14.multiline.sql new file mode 100644 index 0000000000..a89b471717 --- /dev/null +++ b/tests/cdb2sql.test/t14.multiline.sql @@ -0,0 +1 @@ + diff --git a/tests/cdb2sql.test/t15.multiline.expected b/tests/cdb2sql.test/t15.multiline.expected new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/cdb2sql.test/t15.multiline.sql b/tests/cdb2sql.test/t15.multiline.sql new file mode 100644 index 0000000000..01ab7bca9c --- /dev/null +++ b/tests/cdb2sql.test/t15.multiline.sql @@ -0,0 +1 @@ +-- test comment containing ';'