Skip to content

Commit c35e8e2

Browse files
committed
xapi-log: remove circular dependency on tests
unfortunately threadext uses this log package, define a with_lock in xapi-log tests to avoid using the former. Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent a3a7ca4 commit c35e8e2

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

dune-project

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@
231231
logs
232232
mtime
233233
xapi-backtrace
234-
(xapi-stdext-pervasives (= :version))
235-
(xapi-stdext-threads (and :with-test (= :version)))))
234+
(xapi-stdext-pervasives (= :version))))
236235

237236
(package
238237
(name xapi-idl))

ocaml/libs/log/test/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(executable
22
(name log_test)
3-
(libraries log xapi-stdext-threads threads.posix xapi-backtrace))
3+
(libraries log threads.posix xapi-backtrace))
44

55
(cram
66
(package xapi-log)

ocaml/libs/log/test/log_test.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ let a = [||]
66

77
let buggy () = a.(1) <- 0
88

9+
let with_lock mutex f =
10+
let finally () = Mutex.unlock mutex in
11+
Mutex.lock mutex ; Fun.protect ~finally f
12+
913
let () =
1014
Printexc.record_backtrace true ;
1115
Debug.log_to_stdout () ;
1216
()
1317
|> Debug.with_thread_associated "main" @@ fun () ->
14-
try Xapi_stdext_threads.Threadext.Mutex.execute m buggy
18+
try with_lock m buggy
1519
with e ->
1620
D.log_backtrace e ;
1721
D.warn "Got exception: %s" (Printexc.to_string e)

ocaml/libs/log/test/log_test.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[|error||0 |main|backtrace] 1/4 log_test.exe Raised at file ocaml/libs/log/test/log_test.ml, line 7
44
[|error||0 |main|backtrace] 2/4 log_test.exe Called from file fun.ml, line 33
55
[|error||0 |main|backtrace] 3/4 log_test.exe Called from file fun.ml, line 38
6-
[|error||0 |main|backtrace] 4/4 log_test.exe Called from file ocaml/libs/log/test/log_test.ml, line 14
6+
[|error||0 |main|backtrace] 4/4 log_test.exe Called from file ocaml/libs/log/test/log_test.ml, line 18
77
[|error||0 |main|backtrace]
88
[| warn||0 |main|log_test.ml] Got exception: Invalid_argument("index out of bounds")
99

opam/xapi-log.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ depends: [
1616
"mtime"
1717
"xapi-backtrace"
1818
"xapi-stdext-pervasives" {= version}
19-
"xapi-stdext-threads" {with-test & = version}
2019
"odoc" {with-doc}
2120
]
2221
build: [

0 commit comments

Comments
 (0)