Coccinelle release 0.2.5-rc3
[bpt/coccinelle.git] / testing.ml
index a224807..0192b10 100644 (file)
@@ -457,19 +457,33 @@ let test_parse_cocci file =
   if not (file =~ ".*\\.cocci")
   then pr2 "warning: seems not a .cocci file";
 
-  let (_,xs,_,_,_,_,grep_tokens,query) =
+  let (_,xs,_,_,_,_,(grep_tokens,query,_)) =
     Parse_cocci.process file (Some !Config.std_iso) false in
   xs +> List.iter Pretty_print_cocci.unparse;
+  Format.print_newline();
+  (* compile ocaml script code *)
+  (match Prepare_ocamlcocci.prepare file xs with
+    None -> ()
+  | Some ocaml_script_file ->
+      (* compile file *)
+      Prepare_ocamlcocci.load_file ocaml_script_file;
+      (* remove file *)
+      (if not !Common.save_tmp_files
+      then Prepare_ocamlcocci.clean_file ocaml_script_file);
+      (* Print the list of registered functions *)
+      Prepare_ocamlcocci.test ());
   Printf.printf "grep tokens\n";
   (match grep_tokens with
     None -> pr "No query"
   | Some x -> pr (String.concat " || " x));
   match !Flag.scanner with
     Flag.NoScanner | Flag.Grep -> ()
-  | Flag.Glimpse | Flag.Google _ ->
+  | Flag.Glimpse | Flag.IdUtils | Flag.Google _ ->
+      Printf.printf "%s tokens\n"
+       (if !Flag.scanner = Flag.Glimpse then "glimpse" else "google");
       (match query with
        None -> pr "No query"
-      | Some x -> pr (String.concat " || " x))
+      | Some x -> pr (String.concat " ||\n" x))