OSDN Git Service

Refactoring OMakefile: remove extra dependencies
authormzp <mzpppp@gmail.com>
Sat, 1 Aug 2009 13:03:18 +0000 (22:03 +0900)
committermzp <mzpppp@gmail.com>
Sat, 1 Aug 2009 13:03:18 +0000 (22:03 +0900)
- One BIG ounit runner is splitted into many small ounit runner

OMakefile
driver/test/OMakefile
driver/test/ruleTest.ml [moved from driver/test/testRule.ml with 100% similarity]
xml/test/OMakefile
xml/test/abcTest.ml
xml/test/byteTest.ml
xml/test/swfmillTest.ml

index 0e19df6..4a9cead 100644 (file)
--- a/OMakefile
+++ b/OMakefile
@@ -20,13 +20,11 @@ else
        export
 
 Shell. +=
-    ounit-postproc(argv) =
-      (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
     ocaml-clean(argv) =
       rm -f *.cm[aiox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a *.spot *.spit *.annot
 
 # ------------------------------
-# rules
+# camlp4 rules
 # ------------------------------
 public.UseCamlp4(files) =
        protected.CAMLP4CMO = $(addprefix $(ROOT)/camlp4/,$(addsuffix .cmo,$(files)))
@@ -36,6 +34,34 @@ public.UseCamlp4(files) =
 
        .SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4CMO)
 
+# ------------------------------
+# ounit rules
+# ------------------------------
+OUNIT_SRC_DIR=../src/
+OUNIT_LIBS[]=
+
+Shell. +=
+    ounit-postproc(argv) =
+      (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
+
+public.OUnitTest(name,files) =
+       .PHONY: check check-$(name) clean
+       protected.src_files = $(addprefix $(OUNIT_SRC_DIR),$(files))
+       OCamlProgram($(name),$(name) $(src_files) $(OUNIT_LIBS))
+
+       check-$(name): $(name)$(EXE)
+               ./$(name)$(EXE) | ounit-postproc
+
+       check: check-$(name)
+
+       clean:
+               rm -f $(name)$(EXE)
+
+       export
+
+# ------------------------------
+# other rules
+# ------------------------------t
 %.mli : %.mlip
     @rm -f $@
     @echo "(* CAUTION: this is a generated file.  If you edit it, all changes will be lost! *)" > $@
index c54e1c2..43ff20f 100644 (file)
@@ -1,14 +1,5 @@
 .PHONY: check clean
 
-################################################
-# Configuration.
-#
-
-
-#
-# This project requires ocamlfind
-#
-
 USE_OCAMLFIND = true
 OCAMLPACKS[] =
        extlib
@@ -20,57 +11,20 @@ if $(not $(OCAMLFIND_EXISTS))
    eprintln(You need to install ocamlfind and run "omake --configure".)
    exit 1
 
-#
-# Include path
-#
-OCAMLINCLUDES += ../src
-
-#
-# Compile native or byte code?
-#
-# The default values are defined as follows:
-#
 NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
 BYTE_ENABLED = true
 
-#
-# Various options
-#
-# OCAMLFLAGS    +=
-# OCAMLCFLAGS   +=
-# OCAMLOPTFLAGS +=
-# OCAML_LINK_FLAGS +=
-# OCAML_BYTE_LINK_FLAGS +=
-# OCAML_NATIVE_LINK_FLAGS +=
-
-
-################################################
-# Build an OCaml program
-#
-
-FILES[] =
-       testRule
-       colorTest
-
+OCAMLINCLUDES += ../src
 OCAMLINCLUDES += $(ROOT)/base/
-OCAML_LIBS += $(ROOT)/base/base
-
-PROGRAM = runner
-OCAML_LIBS += ../src/habc
-
-# OCAML_CLIBS +=
-# OCAML_OTHER_LIBS +=
-# OCAML_LIB_FLAGS +=
 
-OCamlProgram($(PROGRAM), $(FILES))
-
-.DEFAULT: $(PROGRAM)$(EXE)
+OCAML_LIBS += $(ROOT)/base/base
 
-check: $(PROGRAM)$(EXE)
-       ./$(PROGRAM)$(EXE) | ounit-postproc
+OUnitTest(colorTest,color)
+OUnitTest(ruleTest,rule)
 
 #
 # PHONY TARGET
 #
 clean:
-       ocaml-clean $(PROGRAM)
+       ocaml-clean
+
index 284bd84..d1621b9 100644 (file)
@@ -1,14 +1,5 @@
 .PHONY: check clean
 
-################################################
-# Configuration.
-#
-
-
-#
-# This project requires ocamlfind
-#
-
 USE_OCAMLFIND = true
 OCAMLPACKS[] =
        xml-light
@@ -20,34 +11,11 @@ if $(not $(OCAMLFIND_EXISTS))
    eprintln(You need to install ocamlfind and run "omake --configure".)
    exit 1
 
-#
-# Include path
-#
 OCAMLINCLUDES += ../src
 
-#
-# Compile native or byte code?
-#
-# The default values are defined as follows:
-#
 NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
 BYTE_ENABLED = true
 
-#
-# Various options
-#
-# OCAMLFLAGS    +=
-# OCAMLCFLAGS   +=
-# OCAMLOPTFLAGS +=
-# OCAML_LINK_FLAGS +=
-# OCAML_BYTE_LINK_FLAGS +=
-# OCAML_NATIVE_LINK_FLAGS +=
-
-
-################################################
-# Build an OCaml program
-#
-
 FILES[] =
     testSupport
     byteTest
@@ -55,27 +23,16 @@ FILES[] =
     swfmillTest
     codeTest
 
-OCAMLINCLUDES += ../../base/
-OCAML_LIBS += ../../base/base
-
-PROGRAM = runner
-OCAML_LIBS += ../src/habc-xml
-
-# OCAML_CLIBS +=
-# OCAML_OTHER_LIBS +=
-# OCAML_LIB_FLAGS +=
-
-
-
-OCamlProgram($(PROGRAM), $(FILES))
-
-.DEFAULT: $(PROGRAM)$(EXE)
+OCAMLINCLUDES += $(ROOT)/base/
+OCAML_LIBS += $(ROOT)/base/base
 
-check: $(PROGRAM)$(EXE)
-       ./$(PROGRAM)$(EXE) | ounit-postproc
+OUnitTest(byteTest   ,byte parsec)
+OUnitTest(abcTest    ,abc parsec disasm byte)
+OUnitTest(swfmillTest,swfmill easyXml abc code byte disasm parsec)
+OUnitTest(codeTest   ,code easyXml)
 
 #
 # PHONY TARGET
 #
 clean:
-       ocaml-clean $(PROGRAM)
+       ocaml-clean
index 721a411..c90950b 100644 (file)
@@ -1,6 +1,13 @@
 open Base
 open OUnit
-open TestSupport
+
+let ok x y =
+  OUnit.assert_equal ~printer:Std.dump x y
+
+let example name =
+  let ch =
+    open_in_bin @@ Printf.sprintf "../example/%s.abc" name in
+    Abc.of_stream @@ Byte.of_channel ch
 
 let abc =
   example "hello"
index 0f19730..6fb3f42 100644 (file)
@@ -6,9 +6,12 @@ open TestSupport
 let of_list xs =
   Stream.of_list xs
 
+let ok x y =
+  OUnit.assert_equal ~printer:Std.dump x y
+
 let tests = ("byte module test" >::: [
-  "u8 is single byte" >:: 
-    (fun _ -> 
+  "u8 is single byte" >::
+    (fun _ ->
        ok 0 (u8 @@ of_list [0]));
   "u16 is little endian" >::
     (fun _ ->
@@ -27,7 +30,7 @@ let tests = ("byte module test" >::: [
        ok 0x3F_FFl (u30 @@ of_list [0xFF;0x7F]));
   "u30 is 3 bytes when value <= 0x7F 0xFF 0xFF" >::
     (fun _ ->
-       ok 0x7FFFl    (u30 @@ of_list [0xFF;0xFF;0x01]); 
+       ok 0x7FFFl    (u30 @@ of_list [0xFF;0xFF;0x01]);
        ok 0x1F_FFFFl (u30 @@ of_list [0xFF;0xFF;0x7F]));
   "u30 is 4 bytes when value <= 0x7F 0xFF 0xFF 0xFF" >::
     (fun _ ->
index f89e039..56aa0f1 100644 (file)
@@ -3,11 +3,16 @@ open OUnit
 open Xml
 open EasyXml
 
+let example name =
+  let ch =
+    open_in_bin @@ Printf.sprintf "../example/%s.abc" name in
+    Abc.of_stream @@ Byte.of_channel ch
+
 let ok x y =
   OUnit.assert_equal ~printer:Xml.to_string_fmt (normalize x) (normalize y)
 
 let abc =
-  TestSupport.example "hello"
+  example "hello"
 
 let cpool =
   Swfmill.of_cpool abc#constant_pool
@@ -29,8 +34,8 @@ let scripts =
 
 let method_bodies =
   Swfmill.of_method_bodies abc#method_body
-  
-let _ = 
+
+let _ =
   ("action module test" >::: [
      "constants" >::
        (fun () ->
@@ -50,8 +55,8 @@ let _ =
        );
      "method info" >::
        (fun _ ->
-         flip ok methods @@ elem "methods" [       
-           element 
+         flip ok methods @@ elem "methods" [
+           element
              "MethodInfo"
              ["retType"       ,"0";
               "nameIndex"     ,"1";
@@ -96,7 +101,7 @@ let _ =
                  attr "OpPushString" ["index","2"];
                  attr "OpCallPropLex" ["name","2";"argc","1"];
                  attr "OpPop" [];
-                 attr "OpReturnVoid" []; ]; 
+                 attr "OpReturnVoid" []; ];
                elem "exceptions" [];
                elem "traits" [] ]
          ]);