Changeset: 67286e9bc4a6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=67286e9bc4a6
Modified Files:
        sql/test/json/Tests/load.test
        testing/Mtest.py.in
        testing/convert_to_sqllogic.sh
Branch: mtest
Log Message:

convert script takes individual files as well


diffs (146 lines):

diff --git a/sql/test/json/Tests/load.test b/sql/test/json/Tests/load.test
--- a/sql/test/json/Tests/load.test
+++ b/sql/test/json/Tests/load.test
@@ -2,7 +2,9 @@ statement ok
 create table jstmp(j json)
 
 statement ok
-copy 10 records  into jstmp from stdin;
+copy 10 records  into jstmp from stdin
+
+statement error
 {"nested_obj": {"num": 4, "str": "GBRDCMBQ"}, "dyn2": true, "dyn1": 9, 
"nested_arr": ["especially"], "str2": "GBRDCMBQ", "str1": "GBRDCMBQGE======", 
"sparse_093": "GBRDCMBQGE======", "thousandth": 9, "sparse_090": 
"GBRDCMBQGE======", "sparse_091": "GBRDCMBQGE======", "sparse_092": 
"GBRDCMBQGE======", "num": 9, "bool": true, "sparse_095": "GBRDCMBQGE======", 
"sparse_096": "GBRDCMBQGE======", "sparse_097": "GBRDCMBQGE======", 
"sparse_098": "GBRDCMBQGE======", "sparse_094": "GBRDCMBQGE======", 
"sparse_099": "GBRDCMBQGE======"}
 {"nested_obj": {"num": 2, "str": "GBRDCMA="}, "dyn2": "GBRDCMJR", "dyn1": 7, 
"nested_arr": ["its", "for", "if", "he", "questions", "to", "put"], "str2": 
"GBRDCMA=", "str1": "GBRDCMJR", "sparse_079": "GBRDCMJR", "thousandth": 7, 
"sparse_078": "GBRDCMJR", "num": 7, "bool": true, "sparse_072": "GBRDCMJR", 
"sparse_073": "GBRDCMJR", "sparse_070": "GBRDCMJR", "sparse_071": "GBRDCMJR", 
"sparse_076": "GBRDCMJR", "sparse_077": "GBRDCMJR", "sparse_074": "GBRDCMJR", 
"sparse_075": "GBRDCMJR"}
 {"nested_obj": {"num": 3, "str": "GBRDCMI="}, "dyn2": 8, "dyn1": 8, 
"nested_arr": [], "str2": "GBRDCMI=", "str1": "GBRDCMBQGA======", "thousandth": 
8, "sparse_087": "GBRDCMBQGA======", "sparse_086": "GBRDCMBQGA======", 
"sparse_085": "GBRDCMBQGA======", "num": 8, "bool": false, "sparse_082": 
"GBRDCMBQGA======", "sparse_081": "GBRDCMBQGA======", "sparse_080": 
"GBRDCMBQGA======", "sparse_083": "GBRDCMBQGA======", "sparse_084": 
"GBRDCMBQGA======", "sparse_089": "GBRDCMBQGA======", "sparse_088": 
"GBRDCMBQGA======"}
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2797,7 +2797,14 @@ def main(argv) :
         # print summary
         failed = env.get('failed', 0)
         skipped = env.get('skipped', 0)
-        if not interupted:
+        if interupted:
+            prred('Interupt')
+        else:
+            print()
+            if failed > 0:
+                prred('ERROR')
+            else:
+                prgreen('OK')
             print()
             print('failed={}, skipped={}'.format(failed, skipped))
             print('Ran {} test in {:7.3f}'.format(test_count - skipped, t_))
diff --git a/testing/convert_to_sqllogic.sh b/testing/convert_to_sqllogic.sh
--- a/testing/convert_to_sqllogic.sh
+++ b/testing/convert_to_sqllogic.sh
@@ -7,18 +7,20 @@
 set -e 
 
 usage() {
-echo "Usage $0 --src-dir <source dir> --dst-dir <destination directory>"
-echo "Converts old test sql scripts to sqllogic scripts."
-echo "Options:"
+echo "USAGE $(basename $0) [OPTION ...] [FILE...]"
+echo "DESCRIPTION: Converts old sql scripts to sqllogic scripts."
+echo "OPTIONS:"
 echo " -s|--src-dir <source dir>          directory with old sql tests."
 echo " -t|--dst-dir <destination dir>     destination dotrectory for *.test 
sqllogic tests."
-echo " -d|--dry-run                    dry run"
+echo " -o|--overwrite <bool>              overwrites existing .test" 
+echo " -d|--dry-run                       dry run"
 echo
 }
 
 src=
 dst=
 dry_run=
+overwrite=
 
 for arg in "$@"
 do
@@ -38,16 +40,35 @@ do
             dry_run="true"
             shift
             ;;
+        -o|--overwrite)
+            overwrite="true"
+            shift
+            ;;
     esac
 done
 
-if [[ ! -d "${src}" ]];then
-    echo "ERROR: source directory required!";
+files=()
+if [[ -d "${src}" ]];then
+    files=$(ls $src)
+fi
+
+for f in $@;do
+    if [[ -f $f ]];then
+        files+=" $f";
+    fi
+done
+
+if [[ -z $files ]];then 
     usage;
     exit 1;
 fi
 
-[[ -d "${dst}" ]] || mkdir -p ${dst}
+if [[ -z "${dst}" ]];then
+    echo "ERROR: need --dest-dir";
+    usage;
+    exit 1;
+fi
+[[ -d "${dst}" ]] || mkdir -p ${dst};
 
 dryrun() {
     local f=$1;
@@ -57,23 +78,34 @@ dryrun() {
 work() {
     local f=$1;
     local dst=$2;
-    cat $f | mktest.py --database "test" > $dst;
-}
-
-for f in $(ls ${src}/*{.sql,.sql.in});do
-    echo ">>> converting $f ...";
     if [[ "${dry_run}" = true ]];then
         dryrun $f;
     else
-        ext=$(echo "${f##*.}");
-        if [[ $ext == "in" ]];then
-            bn=$(basename $f .sql.in);
-            work $f $dst/$bn.test.in;
+        if [[ -e $dst ]];then
+            if [[ "$overwrite" = "true" ]];then
+                echo ">>> overwriting $dst ...";
+                cat $f | mktest.py --database "test" > $dst;
+            else
+                echo "$dst already exists!"
+            fi    
         else
-            bn=$(basename $f .sql);
-            work $f $dst/$bn.test;
+            echo ">>> converting $f ...";
+            cat $f | mktest.py --database "test" > $dst;
         fi
     fi
+}
+
+for f in $files;do
+    ext=$(echo "${f#*.}");
+    if [[ $ext == "sql.in" ]];then
+        bn=$(basename $f .sql.in);
+        work $f $dst/$bn.test.in;
+        continue
+    fi
+    if [[ $ext == "sql" ]];then
+        bn=$(basename $f .sql);
+        work $f $dst/$bn.test;
+    fi
 done;
 
 if [[ -e ${src}/All ]];then
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to