Browse Source

Remove crypto dependency & fix test bug.

* Use erlang:md5 instead of crypto:sha for checksum calculation.

* Automatically create rendered_output directory if it does not exist.
Evan Miller 15 years ago
parent
commit
2b3c16bc5f

+ 1 - 1
src/erlydtl/erlydtl.app

@@ -16,7 +16,7 @@
              erlydtl_scanner,
              erlydtl_scanner,
              erlydtl_unittests
              erlydtl_unittests
             ]},
             ]},
-  {applications, [kernel, stdlib, crypto]},
+  {applications, [kernel, stdlib]},
   {registered, []}
   {registered, []}
  ]}.
  ]}.
 
 

+ 2 - 3
src/erlydtl/erlydtl_compiler.erl

@@ -85,7 +85,6 @@ compile(Binary, Module, Options) when is_binary(Binary) ->
     end;
     end;
     
     
 compile(File, Module, Options) ->  
 compile(File, Module, Options) ->  
-    crypto:start(),
     Context = init_dtl_context(File, Module, Options),
     Context = init_dtl_context(File, Module, Options),
     case parse(File, Context) of  
     case parse(File, Context) of  
         ok ->
         ok ->
@@ -165,7 +164,7 @@ is_up_to_date(CheckSum, Context) ->
                             ({XFile, XCheckSum}, Acc) ->
                             ({XFile, XCheckSum}, Acc) ->
                                 case catch M:F(XFile) of
                                 case catch M:F(XFile) of
                                     {ok, Data} ->
                                     {ok, Data} ->
-                                        case binary_to_list(crypto:sha(Data)) of
+                                        case binary_to_list(erlang:md5(Data)) of
                                             XCheckSum ->
                                             XCheckSum ->
                                                 Acc;
                                                 Acc;
                                             _ ->
                                             _ ->
@@ -191,7 +190,7 @@ parse(File, Context) ->
     {M, F} = Context#dtl_context.reader,
     {M, F} = Context#dtl_context.reader,
     case catch M:F(File) of
     case catch M:F(File) of
         {ok, Data} ->
         {ok, Data} ->
-            CheckSum = binary_to_list(crypto:sha(Data)),
+            CheckSum = binary_to_list(erlang:md5(Data)),
             case parse(CheckSum, Data, Context) of
             case parse(CheckSum, Data, Context) of
                 {error, Msg} when is_list(Msg) ->
                 {error, Msg} when is_list(Msg) ->
                     {error, File ++ ": " ++ Msg};
                     {error, File ++ ": " ++ Msg};

+ 13 - 7
src/tests/erlydtl_functional_tests.erl

@@ -177,13 +177,19 @@ setup(_) ->
 
 
 run_tests() ->    
 run_tests() ->    
     io:format("Running functional tests...~n"),
     io:format("Running functional tests...~n"),
-    case fold_tests() of
-        {N, []}->
-            Msg = lists:concat(["All ", N, " functional tests passed~n~n"]),
-            io:format(Msg),
-            {ok, Msg};
-        {_, Errs} ->
-            io:format("Errors: ~p~n~n",[Errs]),
+    case filelib:ensure_dir(filename:join([templates_outdir(), "foo"])) of
+        ok ->
+            case fold_tests() of
+                {N, []}->
+                    Msg = lists:concat(["All ", N, " functional tests passed~n~n"]),
+                    io:format(Msg),
+                    {ok, Msg};
+                {_, Errs} ->
+                    io:format("Errors: ~p~n~n",[Errs]),
+                    failed
+            end;
+        {error, Reason} ->
+            io:format("Error: ~p~n~n", [Reason]),
             failed
             failed
     end.
     end.