Skip to content

Commit

Permalink
Merge pull request #217 from samoht/master
Browse files Browse the repository at this point in the history
Remove dependency to OUnit and nocrypto for compiling the tests
  • Loading branch information
samoht committed Jul 3, 2015
2 parents ced64a1 + f0d61e9 commit 7a94f5b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Executable test_irmin
Build$: flag(tests) && flag(unix) && flag(http) && flag(git)
CompiledObject: best
Install: false
BuildDepends: irmin, irmin.mem, irmin.unix, alcotest, nocrypto, oUnit
BuildDepends: irmin, irmin.mem, irmin.unix, alcotest

Test test_irmin
Run$: flag(tests) && flag(unix) && flag(http) && flag(git)
Expand Down
6 changes: 1 addition & 5 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: c5904109c38afb58fa3dea3ecb183768)
# DO NOT EDIT (digest: b2a0f29f5927309de85d29d8675f4111)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand Down Expand Up @@ -173,8 +173,6 @@ true: annot, bin_annot
<lib_test/test.{native,byte}>: pkg_hex
<lib_test/test.{native,byte}>: pkg_lwt
<lib_test/test.{native,byte}>: pkg_mstruct
<lib_test/test.{native,byte}>: pkg_nocrypto
<lib_test/test.{native,byte}>: pkg_oUnit
<lib_test/test.{native,byte}>: pkg_ocamlgraph
<lib_test/test.{native,byte}>: pkg_re
<lib_test/test.{native,byte}>: pkg_re.pcre
Expand All @@ -200,8 +198,6 @@ true: annot, bin_annot
<lib_test/*.ml{,i,y}>: pkg_hex
<lib_test/*.ml{,i,y}>: pkg_lwt
<lib_test/*.ml{,i,y}>: pkg_mstruct
<lib_test/*.ml{,i,y}>: pkg_nocrypto
<lib_test/*.ml{,i,y}>: pkg_oUnit
<lib_test/*.ml{,i,y}>: pkg_ocamlgraph
<lib_test/*.ml{,i,y}>: pkg_re
<lib_test/*.ml{,i,y}>: pkg_re.pcre
Expand Down
10 changes: 7 additions & 3 deletions lib/unix/irmin_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ module Lock = struct
let is_stale max_age file =
IO.file_exists file >>= fun exists ->
if exists then (
Lwt_unix.stat file >>= fun s ->
let stale = Unix.gettimeofday () -. s.Unix.st_mtime > max_age in
Lwt.return stale
Lwt.catch (fun () ->
Lwt_unix.stat file >>= fun s ->
let stale = Unix.gettimeofday () -. s.Unix.st_mtime > max_age in
Lwt.return stale)
(function
| Unix.Unix_error (Unix.ENOENT, _, _) -> Lwt.return false
| e -> Lwt.fail e)
) else
Lwt.return false

Expand Down
35 changes: 17 additions & 18 deletions lib_test/test_store.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*
* Copyright (c) 2013 Thomas Gazagnaire <[email protected]>
* Copyright (c) 2013-2015 Thomas Gazagnaire <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand All @@ -19,15 +19,21 @@ open Test_common
open Irmin_unix
open Printf

let random_string n =
let t = Unix.gettimeofday () in
let cs = Cstruct.create 8 in
Cstruct.BE.set_uint64 cs 0 Int64.(of_float (t *. 1000.)) ;
Nocrypto.Rng.reseed cs;
Cstruct.to_string (Nocrypto.Rng.generate n)
let () = Random.self_init ()
let random_char () = char_of_int (Random.int 256)

let long_random_string =
random_string 1024_000
(* for OCaml > 4.01 *)
module String = struct
include String
let init n f =
let buf = Bytes.create n in
for i =0 to n-1 do Bytes.set buf i (f i) done;
buf
end

let random_string n = String.init n (fun _i -> random_char ())
let long_random_string = random_string 1024_000
let fail fmt = Printf.ksprintf Alcotest.fail fmt

module Make (S: Irmin.S) = struct

Expand Down Expand Up @@ -604,12 +610,8 @@ module Make (S: Irmin.S) = struct
let y = [ "left", 1; "bar" , 3; "skip", 0 ] in
let m = [ "left", 2; "bar" , 3] in
merge_x ~old x y >>= function
| `Ok m' ->
assert_equal (module X) "compound merge" m m';
return_unit
| `Conflict c ->
OUnit.assert_bool (sprintf "compound merge: %s" c) false;
return_unit
| `Ok m' -> assert_equal (module X) "compound merge" m m'; return_unit
| `Conflict c -> fail "conflict %s" c
in

let test () =
Expand Down Expand Up @@ -696,9 +698,6 @@ module Make (S: Irmin.S) = struct
S.create x.config task >>= fun t ->
let h = h t in
Graph.create (g t 0) [] >>= fun node ->
let fail fmt =
Printf.ksprintf (fun str -> OUnit.assert_string str; assert false) fmt
in
let assert_lcas_err msg err l2 =
let str = function
| `Too_many_lcas -> "Too_many_lcas"
Expand Down
9 changes: 3 additions & 6 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ bug-reports: "https://github.com/mirage/irmin/issues"
dev-repo: "https://github.com/mirage/irmin.git"

build: [
["./configure"
"--prefix" prefix
["./configure" "--prefix" prefix
"--%{cohttp:enable}%-http"
"--%{git:enable}%-git"
"--%{base-unix:enable}%-unix"]
Expand Down Expand Up @@ -36,22 +35,20 @@ depends: [
"re"
"cmdliner"
"crunch"
"nocrypto" {test & >= "0.2.2"}
"base-unix" {test}
"git" {test}
"cohttp" {test}
"alcotest" {test}
"ounit" {test}
"alcotest" {test & >="0.4.1"}
]
depopts: [
"base-unix"
"git"
"cohttp"
"nocrypto"
]
conflicts: [
"git" {< "1.4.10"}
"cohttp" {< "0.14.0"}
"cohttp" {= "0.16.1"}
"git" {<= "1.5.0"}
]
available: [ocaml-version >= "4.01.0"]
10 changes: 4 additions & 6 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.2 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: bb005b68a4b36583faa6eb3e31ba116f) *)
(* DO NOT EDIT (digest: 69265efc97028b8ab1e5f3e8b399a1ea) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -7335,9 +7335,7 @@ let setup_t =
InternalLibrary "irmin";
InternalLibrary "irmin-mem";
InternalLibrary "irmin-unix";
FindlibPackage ("alcotest", None);
FindlibPackage ("nocrypto", None);
FindlibPackage ("oUnit", None)
FindlibPackage ("alcotest", None)
];
bs_build_tools = [ExternalTool "ocamlbuild"];
bs_c_sources = [];
Expand Down Expand Up @@ -7620,14 +7618,14 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "¥\011ÆHÙm\011\139sü£4;\014";
oasis_digest = Some "\146!ýfOeJ\016z¼lwÒ0ïâ";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7632 "setup.ml"
# 7630 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit 7a94f5b

Please sign in to comment.