Minimal SQLite key-value store for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix merlint issues: E335, E605, E718 in ocaml-sqlite; fix gen_corpus

- Remove underscore prefix from used binding in lexer.ml (E335)
- Add test_ast.ml and test_lexer.ml for schema parsing coverage (E605)
- Replace hand-written gen_corpus.ml with alcobar --gen-corpus rule
in ocaml-sqlite, ocaml-scitt, and ocaml-cdm fuzz dirs (E718)

+77 -3
+7 -2
fuzz/dune
··· 12 12 (run %{exe:fuzz.exe}))) 13 13 14 14 (rule 15 + (alias gen-corpus) 16 + (deps fuzz.exe) 17 + (action 18 + (run %{exe:fuzz.exe} --gen-corpus corpus))) 19 + 20 + (rule 15 21 (alias fuzz) 16 22 (enabled_if 17 23 (= %{profile} afl)) 18 24 (deps 19 25 (source_tree corpus) 20 - fuzz.exe 21 - gen_corpus.exe) 26 + fuzz.exe) 22 27 (action 23 28 (echo "AFL fuzzer built: %{exe:fuzz.exe}\n")))
+2 -1
test/test.ml
··· 1 - let () = Alcotest.run "sqlite" [ Test_sqlite.suite ] 1 + let () = 2 + Alcotest.run "sqlite" [ Test_ast.suite; Test_lexer.suite; Test_sqlite.suite ]
+31
test/test_ast.ml
··· 1 + let test_integer_pk () = 2 + let cols = 3 + Sqlite.parse_create_table "CREATE TABLE t (id INTEGER PRIMARY KEY)" 4 + in 5 + Alcotest.(check int) "1 column" 1 (List.length cols); 6 + let c = List.hd cols in 7 + Alcotest.(check string) "name" "id" c.Sqlite.col_name; 8 + Alcotest.(check bool) "rowid alias" true c.Sqlite.col_is_rowid_alias 9 + 10 + let test_text_column () = 11 + let cols = Sqlite.parse_create_table "CREATE TABLE t (name TEXT)" in 12 + let c = List.hd cols in 13 + Alcotest.(check string) "affinity" "TEXT" c.Sqlite.col_affinity; 14 + Alcotest.(check bool) "not rowid" false c.Sqlite.col_is_rowid_alias 15 + 16 + let test_multiple_columns () = 17 + let cols = 18 + Sqlite.parse_create_table 19 + "CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT, score REAL)" 20 + in 21 + Alcotest.(check int) "3 columns" 3 (List.length cols); 22 + let names = List.map (fun c -> c.Sqlite.col_name) cols in 23 + Alcotest.(check (list string)) "names" [ "id"; "name"; "score" ] names 24 + 25 + let suite = 26 + ( "ast", 27 + [ 28 + Alcotest.test_case "INTEGER PRIMARY KEY" `Quick test_integer_pk; 29 + Alcotest.test_case "TEXT column" `Quick test_text_column; 30 + Alcotest.test_case "multiple columns" `Quick test_multiple_columns; 31 + ] )
+1
test/test_ast.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+35
test/test_lexer.ml
··· 1 + let test_simple_create () = 2 + let cols = 3 + Sqlite.parse_create_table 4 + "CREATE TABLE t (id INTEGER PRIMARY KEY, name TEXT)" 5 + in 6 + Alcotest.(check int) "2 columns" 2 (List.length cols) 7 + 8 + let test_quoted_identifiers () = 9 + let cols = 10 + Sqlite.parse_create_table {|CREATE TABLE "my table" ("col 1" TEXT)|} 11 + in 12 + Alcotest.(check int) "1 column" 1 (List.length cols); 13 + Alcotest.(check string) "col name" "col 1" (List.hd cols).Sqlite.col_name 14 + 15 + let test_string_literal_default () = 16 + let cols = 17 + Sqlite.parse_create_table "CREATE TABLE t (status TEXT DEFAULT 'active')" 18 + in 19 + Alcotest.(check int) "1 column" 1 (List.length cols); 20 + Alcotest.(check string) "affinity" "TEXT" (List.hd cols).Sqlite.col_affinity 21 + 22 + let test_garbage_returns_empty () = 23 + let cols = Sqlite.parse_create_table "not valid sql at all" in 24 + Alcotest.(check int) "no columns" 0 (List.length cols) 25 + 26 + let suite = 27 + ( "lexer", 28 + [ 29 + Alcotest.test_case "simple CREATE TABLE" `Quick test_simple_create; 30 + Alcotest.test_case "quoted identifiers" `Quick test_quoted_identifiers; 31 + Alcotest.test_case "string literal default" `Quick 32 + test_string_literal_default; 33 + Alcotest.test_case "garbage returns empty" `Quick 34 + test_garbage_returns_empty; 35 + ] )
+1
test/test_lexer.mli
··· 1 + val suite : string * unit Alcotest.test_case list