Skip to content

Commit

Permalink
Skip AssertCodePosition test if no debug symbols are available. (Closes
Browse files Browse the repository at this point in the history
…: #21).
  • Loading branch information
gildor478 committed Dec 19, 2020
1 parent 84086bd commit 4e25966
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.2.4 - 2020-12-20

### Fixed
- Skip AssertCodePosition test if no debug symbols are available. (Closes: #21)

## v2.2.3 - 2020-07-11

### Changed
Expand Down
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(test
(name test)
(libraries ounit2 ounit2.advanced str testcommon)
(libraries ounit2 ounit2.advanced str libtest)
(package ounit2)
(deps
test.exe
Expand Down
4 changes: 4 additions & 0 deletions test/libtest/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name libtest)
(wrapped false)
(libraries ounit2 ounit2.advanced testcommon))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 7 additions & 3 deletions test/testOtherTests.ml → test/libtest/testOtherTests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,16 @@ let tests =
characters 11-24",
Some ("src/oUnitRunner.ml", 14);
]);
]


let test_assert_code_position =
"AssertCodePosition" >::
(fun ctxt ->
skip_if (not (Printexc.backtrace_status ())) "No backtrace.";
skip_if
((Printexc.get_backtrace ()) = "Called from unknown location\n")
"No debug symbols available";
let extract_exc e =
let _, result, _ = OUnitTest.result_full_of_exception ctxt e in
match result with
Expand All @@ -168,8 +173,7 @@ let tests =
let fn2, lineno2 =
try assert_equal 2 1; "", 0 with e -> extract_exc e
in
let fn_exp = "test/testOtherTests.ml" in
let fn_exp = "test/libtest/testOtherTests.ml" in
assert_equal ~printer:(fun s -> s) fn_exp fn1;
assert_equal ~printer:(fun s -> s) fn_exp fn2;
assert_equal ~printer:string_of_int 3 (lineno2 - lineno1));
]
assert_equal ~printer:string_of_int 3 (lineno2 - lineno1))
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ let () =
TestShared.tests;
TestOUnitBracket.tests;
TestOUnitChooser.tests;
TestOtherTests.test_assert_code_position;
])

8 changes: 8 additions & 0 deletions test/test_byte/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(test
(name test_byte)
(libraries ounit2 ounit2.advanced str libtest)
(package ounit2)
(modes byte)
(deps test_byte.bc)
(action (run env OCAMLRUNPARAM=b %{test})))

41 changes: 41 additions & 0 deletions test/test_byte/test_byte.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(**************************************************************************)
(* 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 () =
run_test_tt_main
("OUnitByte" >:::
[
TestOtherTests.test_assert_code_position;
])

0 comments on commit 4e25966

Please sign in to comment.