Commits

seanmcl  committed b959d9e

first regression test

  • Participants
  • Parent commits 8aeec61

Comments (0)

Files changed (7)

 *.build_info.c
 *.hg_version.c
 
-test
+# test
 
 .deps

File bin/check.sh

 
 tmp_file=/tmp/all.el
 
-bin=$(dirname $0)
-home=$(dirname $bin)
+home=$0/../..
+cd $home
+home=$(pwd -L)
+bin=$home/bin
 contrib_dir=$home/elisp/contrib
 jane_dir=$home/elisp/jane
 omake_dir=$home/elisp/omake
 
+# echo "home: $home"
+# exit 1
+
 # top_files="
 # jane-common"
 
     exit 1
 fi
 
-
+# run server tests
+if [ -e $bin/omake_server.exe ]; then
+    $home/ocaml/omake/test/runtests.sh
+fi

File ocaml/omake/omake.ml

     (* *** omake: the current directory /home/seanmcl/ocaml/ocaml1/lib/abc
        *** omake: is not part of the root project in /home/seanmcl/ocaml/ocaml1 *)
     let error11 = "\\*\\*\\* omake: the current directory" in
-    let error12 = "depends on:" in
+    let error12 = "\\*\\*\\* omake: is a dependency of" in
     let error13 = " *Error: Preprocessor error" in
     (* Don't use "waiting for project lock" because the line takes a long time
        to end while omake spits out ............. *)
   | Refresh_file of [`Dir of path] * [`Filename_with_no_extension of string]
   | Done
   | Last_line of string
+  | Eof
   with sexp_of
   val parse_events : string Pipe.Reader.t -> t result Pipe.Reader.t
 end = struct
   | Refresh_file of [`Dir of path] * [`Filename_with_no_extension of string]
   | Done
   | Last_line of string
+  | Eof
   with sexp_of
 
   let parse_events string_reader =
-    printf "h3\n";
     let (event_reader, event_writer) = Pipe.create () in
     let write t =
       (* dprintf "parse_events: ok: %s" (Sexp.to_string (sexp_of_t t)); *)
           write (Last_line s)
         end
     in
+    let eq s1 s2 = String.equal (String.strip s1) s2 in
     let iter () : unit deferred = Pipe.iter string_reader ~f:(function
-      | s when String.equal (String.strip s) "" ->
+      | s when eq s "" ->
         Deferred.unit
+      | s when eq s "EOF" ->
+        write Eof
       | s ->
         last_line s >>= fun () ->
         if Regex.has_match Rex.reading_omakefiles s then
             finish_error () >>= fun () ->
             write (Progress_bar (num, denom))
           | [] ->
-          printf "h0\n";
           let rex = Rex.build in
           match Regex.matches rex s with
           | m :: _ ->
             write (Refresh_file (`Dir dir, `Filename_with_no_extension file))
           | [] ->
           let rex = Rex.changed in
-          printf "h1\n";
           match Regex.matches rex s with
           | m :: _ ->
             let dir = match Regex.get rex ~sub:(`Name "dir") m with
             | Some s -> s
             in
             finish_error () >>= fun () ->
-            printf "h4\n";
             write (Refresh_file (`Dir dir, `Filename_with_no_extension file))
-            >>| fun () -> printf "h5\n"
           | [] ->
           (* let rex = Rex.error_enabled_warning_error in
            * match Regex.matches rex s with
         | E.Last_line s ->
           t.last_line <- s;
           update ()
+        | E.Eof ->
+          Pipe.close_read elisp_reader;
+          Deferred.unit
         | E.Status status ->
           begin
             t.status <- status;

File ocaml/omake/test/data/1.expected

+(Omake.Ocaml.update-model-ok
+  :id "/a/b/c"
+  :status Omake.Status.Starting
+  :last-line "*** omake: polling for filesystem changes"
+  :targets-up-to-date '(0 . 0)
+  :progress-bar '(0 . 0)
+  :done nil
+  :num-errors 0
+  :errors
+    nil)

File ocaml/omake/test/data/1.raw

+
+*** omake: polling for filesystem changes
+*** omake: file base/core/lib/heap_block.ml changed
+*** omake: rebuilding
+[============================================                  ] 05793 / 07928
+                                                                               
- build . <.BUILD_BEGIN>
++ bin/hg_version.sh --no-version-util > ./hg_version.out
+- exit . <.BUILD_BEGIN>, 0.26 sec, code 0
+[==========================================================    ] 07622 / 07928
                                                                               
+make[1]: Entering directory `/mnt/local/sda1/sweeks/hg/jane/submissions/base/core/lib'
+                                                                               
- build base/core/lib heap_block.ml.d
++ <compute 273 value dependencies>
+- build base/core/lib heap_block.ml.d
++ ocamldep.opt -pp 'camlp4o   ../../../lib/pa_type_conv/pa_type_conv.cmo ../../../lib/pa_sexp_conv/pa_sexp_conv.cmo ../../../lib/pa_bin_prot/pa_bin_prot.cmo ../../../lib/pa_fields_conv/pa_fields_conv.cmo ../../../lib/pa_variants_conv/pa_variants_conv.cmo ../../../lib/pa_compare/pa_compare.cmo ../../../lib/pa_pipebang/pa_pipebang.cmo ../../../lib/pa_ounit/pa_ounit.cmo pa_macro.cmo -pa-ounit-ident base/core/lib/heap_block.ml' heap_block.ml
+     | ../../../bin/postprocess-ocamldeps heap_block > base/core/lib/heap_block.ml.d
+- exit base/core/lib heap_block.ml.d, 0.26 sec, code 0
+[==========================================================    ] 07625 / 07928
                                                                               
- build base/core/lib heap_block.cmx
++ <compute 1 value dependencies>
+- build base/core/lib heap_block.cmx
++ ocamlopt.opt -I +camlp4 -thread -w @a-4-7-29-28 -strict-sequence -annot -inline 20 -nodynlink -g -pp 'camlp4o   ../../../lib/pa_type_conv/pa_type_conv.cmo ../../../lib/pa_sexp_conv/pa_sexp_conv.cmo ../../../lib/pa_bin_prot/pa_bin_prot.cmo ../../../lib/pa_fields_conv/pa_fields_conv.cmo ../../../lib/pa_variants_conv/pa_variants_conv.cmo ../../../lib/pa_compare/pa_compare.cmo ../../../lib/pa_pipebang/pa_pipebang.cmo ../../../lib/pa_ounit/pa_ounit.cmo pa_macro.cmo -pa-ounit-ident base/core/lib/heap_block.ml' -I ../../../lib/bin_prot -I ../../../lib/fieldslib -I ../../../lib/sexplib -I ../../../lib/variantslib -I ../../../lib/res -I ../../../lib/oUnit -I ../../../lib/typehash -I ../../../lib/oUnit -I ../../../lib/sexplib -for-pack Core -c heap_block.ml
+File "heap_block.ml", line 20, characters 22-26:
+Error: This expression has type 'a option
+       but an expression was expected of type int
+- exit base/core/lib heap_block.cmx, 0.17 sec, code 2
+[==========================================================    ] 07626 / 07928
                                                                               
+*** omake: 7626/7928 targets are up to date
+*** omake: blocked (0.75 sec, 141/491 scans, 716/1177 rules, 959/26224 digests)
+[============================================                  ] 05796 / 07928
                                                                               
+   base/core/lib/heap_block.cmx
+      depends on: base/core/lib/heap_block.ml
+      - build base/core/lib heap_block.cmx
+      + <compute 1 value dependencies>
+      - build base/core/lib heap_block.cmx
+      + ocamlopt.opt -I +camlp4 -thread -w @a-4-7-29-28 -strict-sequence -annot -inline 20 -nodynlink -g -pp 'camlp4o   ../../../lib/pa_type_conv/pa_type_conv.cmo ../../../lib/pa_sexp_conv/pa_sexp_conv.cmo ../../../lib/pa_bin_prot/pa_bin_prot.cmo ../../../lib/pa_fields_conv/pa_fields_conv.cmo ../../../lib/pa_variants_conv/pa_variants_conv.cmo ../../../lib/pa_compare/pa_compare.cmo ../../../lib/pa_pipebang/pa_pipebang.cmo ../../../lib/pa_ounit/pa_ounit.cmo pa_macro.cmo -pa-ounit-ident base/core/lib/heap_block.ml' -I ../../../lib/bin_prot -I ../../../lib/fieldslib -I ../../../lib/sexplib -I ../../../lib/variantslib -I ../../../lib/res -I ../../../lib/oUnit -I ../../../lib/typehash -I ../../../lib/oUnit -I ../../../lib/sexplib -for-pack Core -c heap_block.ml
+      File "heap_block.ml", line 20, characters 22-26:
+      Error: This expression has type 'a option
+             but an expression was expected of type int
+      - exit base/core/lib heap_block.cmx, 0.17 sec, code 2
+   base/core/lib/heap_block.o
+      depends on: base/core/lib/heap_block.ml
+*** omake: polling for filesystem changes
+EOF

File ocaml/omake/test/runtests.sh

+#!/bin/bash
+
+set -e -u -o pipefail
+#set -x
+
+test_dir=$0/..
+cd $test_dir
+test_dir=$(pwd -P)
+data_dir=$test_dir/data
+files=$(ls -1 $data_dir | grep raw)
+
+failed=no
+
+function run {
+    file=$1; shift
+    expected="$data_dir/$(basename -s .raw $file).expected"
+    tmp=/tmp/$file
+    out=$tmp.out
+    cat $data_dir/$file > $tmp
+    echo "EOF" >> $tmp
+    omake_server.exe server file $tmp > $out
+    if [ "$(diff $expected $out)" ]; then
+        echo "Test $file failed!"
+        printf "\nEXPECTED\n\n"
+        cat $expected
+        printf "\nFOUND\n\n"
+        cat $out
+        failed=yes
+    fi
+}
+
+for file in $files; do
+    run $file
+done
+
+case $failed in
+    yes)
+        exit 1
+        ;;
+esac

File ocaml/omake/top.ml

         | Ok () -> shutdown 0
         | Error _ -> shutdown 1))
 
-  let debug =
+  let file =
     let module C = Project.Create in
     Command.basic
-      ~summary:"Run on a given file [debug]."
-      Command.Spec.( anon ("file" %: string) )
-      (fun file -> schedule (fun () ->
-        Omake.debug := true;
-        Reader.open_file file >>= fun reader ->
-        let lines = Reader.lines reader in
-        let elisp = Omake.parse_omake_output ~omakeroot_dir:"/a/b/c" lines in
-        Pipe.iter elisp ~f:(function
-        | Error exn ->
-          printf "%s\n" (Exn.to_string exn);
-          shutdown 1;
-          Deferred.unit
-        | Ok e ->
-          printf "%s\n" e;
-          Deferred.unit)))
+      ~summary:"Run on a given file."
+      Command.Spec.(
+        flag "-debug" no_arg ~doc:" Print debugging info into [omake-server-log]"
+        ++ anon ("file" %: string) )
+      (fun debug file ->
+        schedule ~quit:true (fun () ->
+          if debug then Omake.debug := true;
+          Reader.open_file file >>= fun reader ->
+          let lines = Reader.lines reader in
+          let elisp = Omake.parse_omake_output ~omakeroot_dir:"/a/b/c" lines in
+          Pipe.to_list elisp >>= fun elisp ->
+          Deferred.List.iter elisp ~f:(function
+          | Error exn ->
+            printf "%s\n" (Exn.to_string exn);
+            shutdown 1;
+            Deferred.unit
+          | Ok e ->
+            printf "%s\n" e;
+            Deferred.unit) >>| fun () ->
+          shutdown 0))
 end
 
 module Client = struct
     ; ( "version"             , Server.version )
     ; ( "running"             , Server.running )
       (* Debug *)
-    ; ( "debug"               , Server.debug )
+    ; ( "file"                , Server.file )
     ] )
   ]