Test: split out test/{p2p,utils} in various package dir

This commit is contained in:
Grégoire Henry 2018-02-02 16:44:46 +01:00
parent 6205ca9b31
commit 14d902a3fc
12 changed files with 119 additions and 60 deletions

View File

@ -0,0 +1,33 @@
(jbuild_version 1)
(executables
((names (test_merkle))
(libraries (tezos-stdlib
tezos-error-monad
tezos-data-encoding
tezos-crypto
tezos-test-helpers))
(flags (:standard -w -9-32
-safe-string
-open Tezos_test_helpers
-open Tezos_stdlib
-open Tezos_error_monad
-open Tezos_data_encoding
-open Tezos_crypto))))
(alias
((name buildtest)
(deps (test_merkle.exe))))
(alias
((name runtest_merkle)
(action (run ${exe:test_merkle.exe}))))
(alias
((name runtest)
(deps ((alias runtest_merkle)))))
(alias
((name runtest_indent)
(deps ((glob_files *.ml) (glob_files *.mli)))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))

View File

@ -7,9 +7,8 @@
(* *)
(**************************************************************************)
let rec (--) i j =
if j < i then []
else i :: (i+1) -- j
open Error_monad
open Utils.Infix
type tree =
| Empty

View File

@ -0,0 +1,33 @@
(jbuild_version 1)
(executables
((names (test_tzList
test_mbytes_buffer))
(libraries (tezos-stdlib tezos-test-helpers))
(flags (:standard -w -9-32
-safe-string
-open Tezos_test_helpers
-open Tezos_stdlib))))
(alias
((name buildtest)
(deps (test_tzList.exe
test_mbytes_buffer.exe))))
(alias
((name runtest_tzList)
(action (run ${exe:test_tzList.exe}))))
(alias
((name runtest_mbytes_buffer)
(action (run ${exe:test_mbytes_buffer.exe}))))
(alias
((name runtest)
(deps ((alias runtest_tzList)
(alias runtest_mbytes_buffer)))))
(alias
((name runtest_indent)
(deps ((glob_files *.ml) (glob_files *.mli)))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))

View File

@ -7,6 +7,12 @@
(* *)
(**************************************************************************)
module Error = struct
type error = ..
let pp_print_error _ _ = ()
end
module Test = Tezos_test_helpers.Test.Make(Error)
let rec permut = function
| [] -> [[]]
| x :: xs ->
@ -23,32 +29,31 @@ let rec permut = function
let test_take_n _ =
ListLabels.iter (permut [1;2;3;4;5;6;7;8;9]) ~f:begin fun xs ->
Assert.equal ~msg:__LOC__ (List.take_n ~compare 1 xs) [9]
Assert.equal ~msg:__LOC__ (TzList.take_n ~compare 1 xs) [9]
end ;
ListLabels.iter (permut [1;2;3;4;5;6;7;8;9]) ~f:begin fun xs ->
Assert.equal ~msg:__LOC__ (List.take_n ~compare 3 xs) [7;8;9]
Assert.equal ~msg:__LOC__ (TzList.take_n ~compare 3 xs) [7;8;9]
end ;
let inv_compare x y = compare y x in
ListLabels.iter (permut [1;2;3;4;5;6;7;8;9]) ~f:begin fun xs ->
Assert.equal ~msg:__LOC__ (List.take_n ~compare:inv_compare 3 xs) [3;2;1]
Assert.equal ~msg:__LOC__ (TzList.take_n ~compare:inv_compare 3 xs) [3;2;1]
end ;
(* less elements than the bound. *)
ListLabels.iter (permut [1;2;3;4;5;6;7;8;9]) ~f:begin fun xs ->
Assert.equal ~msg:__LOC__ (List.take_n ~compare 12 xs) [1;2;3;4;5;6;7;8;9]
Assert.equal ~msg:__LOC__ (TzList.take_n ~compare 12 xs) [1;2;3;4;5;6;7;8;9]
end ;
(* with duplicates. *)
ListLabels.iter (permut [1;2;3;3;4;5;5;5;6]) ~f:begin fun xs ->
Assert.equal ~msg:__LOC__ (List.take_n ~compare 3 xs) [5;5;6]
Assert.equal ~msg:__LOC__ (TzList.take_n ~compare 3 xs) [5;5;6]
end ;
ListLabels.iter (permut [1;2;3;3;4;5;5;5;6]) ~f:begin fun xs ->
Assert.equal ~msg:__LOC__ (List.take_n ~compare 5 xs) [4;5;5;5;6]
Assert.equal ~msg:__LOC__ (TzList.take_n ~compare 5 xs) [4;5;5;5;6]
end ;
return ()
Lwt.return_ok ()
let tests : (string * (string -> unit tzresult Lwt.t)) list = [
let tests : (string * (string -> (unit, Error.error list) result Lwt.t)) list = [
"take_n", test_take_n ;
]
let () =
let module Test = Tezos_test_helpers.Test.Make(Error_monad) in
Test.run "utils." tests
Test.run "tzList." tests

View File

@ -0,0 +1,27 @@
(jbuild_version 1)
(executables
((names (test_lwt_pipe))
(libraries (tezos-stdlib-lwt tezos-test-helpers))
(flags (:standard -w -9-32
-safe-string
-open Tezos_test_helpers
-open Tezos_stdlib_lwt))))
(alias
((name buildtest)
(deps (test_lwt_pipe.exe))))
(alias
((name runtest_lwt_pipe)
(action (run ${exe:test_lwt_pipe.exe}))))
(alias
((name runtest)
(deps ((alias runtest_lwt_pipe)))))
(alias
((name runtest_indent)
(deps ((glob_files *.ml) (glob_files *.mli)))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))

View File

@ -1,3 +1,12 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2017. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
open Lwt.Infix
include Logging.Make (struct let name = "test-pipe" end)

View File

@ -1,47 +0,0 @@
(jbuild_version 1)
(executables
((names (test_lwt_pipe
test_merkle
test_utils
test_mbytes_buffer))
(libraries (tezos-base tezos-test-helpers))
(flags (:standard -w -9-32
-safe-string
-open Tezos_base__TzPervasives
-open Tezos_test_helpers))))
(alias
((name buildtest)
(deps (test_lwt_pipe.exe
test_merkle.exe
test_utils.exe
test_mbytes_buffer.exe))))
(alias
((name runtest_lwt_pipe)
(action (run ${exe:test_lwt_pipe.exe}))))
(alias
((name runtest_merkle)
(action (run ${exe:test_merkle.exe}))))
(alias
((name runtest_utils)
(action (run ${exe:test_utils.exe}))))
(alias
((name runtest_mbytes_buffer)
(action (run ${exe:test_mbytes_buffer.exe}))))
(alias
((name runtest)
(deps ((alias runtest_lwt_pipe)
(alias runtest_merkle)
(alias runtest_utils)
(alias runtest_mbytes_buffer)))))
(alias
((name runtest_indent)
(deps ((glob_files *.ml) (glob_files *.mli)))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))