ounit-2.0.8/0000755000175000017500000000000013261071015012175 5ustar gildorgildorounit-2.0.8/README.txt0000644000175000017500000000125213261071015013673 0ustar gildorgildor(* OASIS_START *) (* DO NOT EDIT (digest: 7972011e467ce4298adee5afbb353623) *) ounit - Unit testing framework ============================== OUnit is a unit testing framework for OCaml, inspired by the JUnit tool for Java, and the HUnit tool for Haskell. More information on [HUnit](http://hunit.sourceforge.net) See the file [INSTALL.txt](INSTALL.txt) for building and installation instructions. [Home page](http://ounit.forge.ocamlcore.org) Copyright and license --------------------- (C) 2002-2008 Maas-Maarten Zeeman (C) 2010 OCamlCore SARL ounit is distributed under the terms of the MIT License. See [LICENSE.txt](LICENSE.txt) for more information. (* OASIS_STOP *) ounit-2.0.8/INSTALL.txt0000644000175000017500000000166013261071015014047 0ustar gildorgildor(* OASIS_START *) (* DO NOT EDIT (digest: 0d6708f8c4693a5f8c6110fc47730ecb) *) This is the INSTALL file for the ounit distribution. This package uses OASIS to generate its build system. See section OASIS for full information. Dependencies ============ In order to compile this package, you will need: * ocaml (>= 3.11.0) for all, test main, doc api-ounit * findlib * bytes for library oUnitAdvanced * xmllint for test main Installing ========== 1. Uncompress the source archive and go to the root of the package 2. Run 'ocaml setup.ml -configure' 3. Run 'ocaml setup.ml -build' 4. Run 'ocaml setup.ml -install' Uninstalling ============ 1. Go to the root of the package 2. Run 'ocaml setup.ml -uninstall' OASIS ===== OASIS is a program that generates a setup.ml file using a simple '_oasis' configuration file. The generated setup only depends on the standard OCaml installation: no additional library is required. (* OASIS_STOP *) ounit-2.0.8/AUTHORS.txt0000644000175000017500000000023513261071015014063 0ustar gildorgildor(* OASIS_START *) (* DO NOT EDIT (digest: 32bb7258886e92969facf1ca9ed449e8) *) Authors of ounit: * Maas-Maarten Zeeman * Sylvain Le Gall (* OASIS_STOP *) ounit-2.0.8/tools/0000755000175000017500000000000013261070772013346 5ustar gildorgildorounit-2.0.8/tools/ci/0000755000175000017500000000000013261070772013741 5ustar gildorgildorounit-2.0.8/tools/ci/travis.bash0000644000175000017500000000006413261070772016110 0ustar gildorgildorOPAMROOT="$HOME/.opam" . $(dirname "$0")/build.bash ounit-2.0.8/tools/ci/packages.bash0000644000175000017500000000017413261070772016360 0ustar gildorgildorOPAM_PKGS=() OPAM_PKGS+=( "base-bytes") OPAM_PKGS+=( "base-unix" ) OPAM_PKGS+=( "ocamlfind>=1.3.1" ) OPAM_PKGS+=( "oasis" ) ounit-2.0.8/tools/ci/opam.bash0000644000175000017500000000364313261070772015542 0ustar gildorgildor################################################################################ # OASIS: architecture for building OCaml libraries and applications # # # # Copyright (C) 2011-2016, Sylvain Le Gall # # Copyright (C) 2008-2011, OCamlCore SARL # # # # This library is free software; you can redistribute it and/or modify it # # under the terms of the GNU Lesser General Public License as published by # # the Free Software Foundation; either version 2.1 of the License, or (at # # your option) any later version, with the OCaml static compilation # # exception. # # # # This library is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # # or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with this library; if not, write to the Free Software Foundation, # # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################################################################################ export OPAMYES=1 OPAMROOT="${OPAMROOT:="$(pwd)/.opam"}" export OPAMROOT if [ -f "$OPAMROOT/config" ]; then opam update opam upgrade else opam init fi if [ -n "${OPAM_SWITCH}" ]; then opam switch ${OPAM_SWITCH} fi eval `opam config env` ounit-2.0.8/tools/ci/build.bash0000644000175000017500000000045613261070772015704 0ustar gildorgildor. "$(dirname $0)/packages.bash" || exit 1 . "$(dirname $0)/opam.bash" || exit 1 mkdir dist || true opam install "${OPAM_PKGS[@]}" export OCAMLRUNPARAM=b ocaml setup.ml -distclean ocaml setup.ml -configure \ --enable-tests \ ${CONFIGURE_ARGS} ocaml setup.ml -build ocaml setup.ml -test ${TEST_ARGS} ounit-2.0.8/test/0000755000175000017500000000000013261070772013165 5ustar gildorgildorounit-2.0.8/test/testShared.ml0000644000175000017500000000571113261070772015631 0ustar gildorgildor(**************************************************************************) (* The OUnit library *) (* *) (* Copyright (C) 2002-2008 Maas-Maarten Zeeman. *) (* Copyright (C) 2010 OCamlCore SARL *) (* Copyright (C) 2013 Sylvain Le Gall *) (* *) (* The package OUnit is copyright by Maas-Maarten Zeeman, OCamlCore SARL *) (* and Sylvain Le Gall. *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining *) (* a copy of this document and the OUnit software ("the Software"), to *) (* deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, *) (* sublicense, and/or sell copies of the Software, and to permit persons *) (* to whom the Software is furnished to do so, subject to the following *) (* conditions: *) (* *) (* The above copyright notice and this permission notice shall be *) (* included in all copies or substantial portions of the Software. *) (* *) (* The Software is provided ``as is'', without warranty of any kind, *) (* express or implied, including but not limited to the warranties of *) (* merchantability, fitness for a particular purpose and noninfringement. *) (* In no event shall Maas-Maarten Zeeman be liable for any claim, damages *) (* or other liability, whether in an action of contract, tort or *) (* otherwise, arising from, out of or in connection with the Software or *) (* the use or other dealings in the software. *) (* *) (* See LICENSE.txt for details. *) (**************************************************************************) open OUnit2 let testFakeShared = Conf.make_exec "testFakeShared" let run_test_fake_shared ctxt runner args = let fn, _ = bracket_tmpfile ctxt in assert_command ~ctxt ~exit_code:(Unix.WEXITED 0) (testFakeShared ctxt) ("-output-file" :: fn :: "-runner" :: runner :: args) let tests = "Shared" >::: [ "Sequential" >:: (fun ctxt -> run_test_fake_shared ctxt "sequential" []); "Processes" >:: (fun ctxt -> run_test_fake_shared ctxt "processes" ["-shards"; "2"]); "Threads" >:: (fun ctxt -> run_test_fake_shared ctxt "threads" ["-shards"; "2"]); ] ounit-2.0.8/test/testRunner.ml0000644000175000017500000001613113261070772015672 0ustar gildorgildor(**************************************************************************) (* The OUnit library *) (* *) (* Copyright (C) 2002-2008 Maas-Maarten Zeeman. *) (* Copyright (C) 2010 OCamlCore SARL *) (* Copyright (C) 2013 Sylvain Le Gall *) (* *) (* The package OUnit is copyright by Maas-Maarten Zeeman, OCamlCore SARL *) (* and Sylvain Le Gall. *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining *) (* a copy of this document and the OUnit software ("the Software"), to *) (* deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, *) (* sublicense, and/or sell copies of the Software, and to permit persons *) (* to whom the Software is furnished to do so, subject to the following *) (* conditions: *) (* *) (* The above copyright notice and this permission notice shall be *) (* included in all copies or substantial portions of the Software. *) (* *) (* The Software is provided ``as is'', without warranty of any kind, *) (* express or implied, including but not limited to the warranties of *) (* merchantability, fitness for a particular purpose and noninfringement. *) (* In no event shall Maas-Maarten Zeeman be liable for any claim, damages *) (* or other liability, whether in an action of contract, tort or *) (* otherwise, arising from, out of or in connection with the Software or *) (* the use or other dealings in the software. *) (* *) (* See LICENSE.txt for details. *) (**************************************************************************) open OUnit2 let testFakeRunner = Conf.make_exec "testFakeRunner" type test_results = { cases: int; tried: int; errors: int; failures: int; skip: int; todo: int; timeout: int; } let string_of_test_results test_results = Printf.sprintf "Cases: %d; Tried: %d; Errors: %d; Failures: %d; \ Skip: %d; Todo: %d; Timeout: %d" test_results.cases test_results.tried test_results.errors test_results.failures test_results.skip test_results.todo test_results.timeout let run_test_fake_runner ctxt runner args = let fn, _ = bracket_tmpfile ctxt in let () = assert_command ~ctxt ~exit_code:(Unix.WEXITED 1) ~env:[||] (testFakeRunner ctxt) ("-output-file" :: fn :: "-runner" :: runner :: args); in let mk str = let r = ref (-1) in let regex = Str.regexp (".* I: "^str^": \\([0-9]+\\)\\.$") in r, fun line -> if Str.string_match regex line 0 then r := int_of_string (Str.matched_group 1 line) in let cases, fcases = mk "Cases" in let tried, ftried = mk "Tried" in let errors, ferrors = mk "Errors" in let failures, ffailures = mk "Failures" in let skip, fskip = mk "Skip" in let todo, ftodo = mk "Todo" in let timeout, ftimeout = mk "Timeout" in let rrunner = ref "" in let runner_regex = Str.regexp (".* I: Runner: \\([a-z]+\\)$") in let frunner line = if Str.string_match runner_regex line 0 then rrunner := Str.matched_group 1 line in let chn = open_in fn in let () = try while true do let line = input_line chn in List.iter (fun f -> f line) [frunner; fcases; ftried; ferrors; ffailures; fskip; ftodo; ftimeout] done; with End_of_file -> close_in chn in assert_equal ~msg:"runner" ~printer:(fun s -> s) runner !rrunner; assert_bool "Cases initialized." (!cases >= 0); assert_bool "Tried initialized." (!tried >= 0); assert_bool "Errors initialized." (!errors >= 0); assert_bool "Failures initialized." (!failures >= 0); assert_bool "Skip initialized." (!skip >= 0); assert_bool "Todo initialized." (!todo >= 0); assert_bool "Timeout initialized." (!timeout >= 0); { cases = !cases; tried = !tried; errors = !errors; failures = !failures; skip = !skip; todo = !todo; timeout = !timeout; } let check_standard_results ?(extra_errors=0) ?(extra_timeouts=0) test_results = assert_equal ~msg:"test results" ~printer:string_of_test_results { cases = 7; tried = 7; errors = 1 + extra_errors; failures = 1; skip = 1; todo = 1; timeout = extra_timeouts; } test_results let skip_if_notunix () = skip_if (Sys.os_type <> "Unix") "Only run on Unix." let tests = "Runner" >::: [ "Sequential" >:: (fun ctxt -> let test_results = run_test_fake_runner ctxt "sequential" [] in check_standard_results test_results); "Processes" >:: (fun ctxt -> let test_results = skip_if_notunix (); run_test_fake_runner ctxt "processes" [] in check_standard_results test_results); "Processes#1" >:: (fun ctxt -> let test_results = skip_if_notunix (); run_test_fake_runner ctxt "processes" ["-shards"; "1"] in check_standard_results test_results); "Processes#2" >:: (fun ctxt -> let test_results = skip_if_notunix (); run_test_fake_runner ctxt "processes" ["-shards"; "2"] in check_standard_results test_results); "Processes+SIGSEGV" >:: (fun ctxt -> let test_results = skip_if_notunix (); run_test_fake_runner ctxt "processes" ["-shards"; "2"; "-sigsegv" ; "true"; "-health-check-interval"; "0.0"] in check_standard_results ~extra_errors:1 test_results); "Processes+timeout" >:: (fun ctxt -> let test_results = skip_if_notunix (); run_test_fake_runner ctxt "processes" ["-shards"; "2"; "-timeout" ; "true"; "-processes-grace-period"; "0.1"] in check_standard_results ~extra_timeouts:1 test_results); "Threads" >:: (fun ctxt -> let test_results = run_test_fake_runner ctxt "threads" [] in check_standard_results test_results); "Threads#1" >:: (fun ctxt -> let test_results = run_test_fake_runner ctxt "threads" ["-shards"; "1"] in check_standard_results test_results); "Threads#2" >:: (fun ctxt -> let test_results = run_test_fake_runner ctxt "threads" ["-shards"; "2"] in check_standard_results test_results); ] ounit-2.0.8/test/testOtherTests.ml0000644000175000017500000001562113261070772016530 0ustar gildorgildor(**************************************************************************) (* The OUnit library *) (* *) (* Copyright (C) 2002-2008 Maas-Maarten Zeeman. *) (* Copyright (C) 2010 OCamlCore SARL *) (* Copyright (C) 2013 Sylvain Le Gall *) (* *) (* The package OUnit is copyright by Maas-Maarten Zeeman, OCamlCore SARL *) (* and Sylvain Le Gall. *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining *) (* a copy of this document and the OUnit software ("the Software"), to *) (* deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, *) (* sublicense, and/or sell copies of the Software, and to permit persons *) (* to whom the Software is furnished to do so, subject to the following *) (* conditions: *) (* *) (* The above copyright notice and this permission notice shall be *) (* included in all copies or substantial portions of the Software. *) (* *) (* The Software is provided ``as is'', without warranty of any kind, *) (* express or implied, including but not limited to the warranties of *) (* merchantability, fitness for a particular purpose and noninfringement. *) (* In no event shall Maas-Maarten Zeeman be liable for any claim, damages *) (* or other liability, whether in an action of contract, tort or *) (* otherwise, arising from, out of or in connection with the Software or *) (* the use or other dealings in the software. *) (* *) (* See LICENSE.txt for details. *) (**************************************************************************) open OUnit2 open OUnitUtils let xmllint = Conf.make_exec "xmllint" let testFakeHTML = Conf.make_exec "testFakeHTML" let tests = "OtherTests" >::: [ "TestFakeHTML" >:: (fun ctxt -> (* For easier dev. we don't use a temporary directory but a permanent * one, so that we can see the result. *) let () = skip_if (Sys.os_type = "Win32") "Don't run on Win32." in let html_dir = "log-html" in let junit_xml = Filename.concat html_dir "junit.xml" in let index_html = Filename.concat html_dir "index.html" in let link_to_source bn = Sys.remove (Filename.concat html_dir bn); Unix.symlink (Filename.concat (Sys.getcwd ()) (Filename.concat "src" bn)) (Filename.concat html_dir bn) in let grep_wc fn f = let count = ref 0 in let chn = open_in fn in let () = try while true do let line = input_line chn in if f line then incr count done; with End_of_file -> close_in chn in !count in if not (Sys.file_exists html_dir) then Unix.mkdir html_dir 0o750; assert_command ~ctxt ~exit_code:(Unix.WEXITED 1) (testFakeHTML ctxt) ["-output-file"; Filename.concat html_dir "fake-html.log"; "-output-html-dir"; html_dir; "-output-junit-file"; junit_xml]; assert_equal ~msg:"Number of test case in junit.xml." ~printer:string_of_int 6 (grep_wc junit_xml (fun line -> starts_with ~prefix:" starts_with ~prefix:"