-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make alcotest-lwt compatible with jsoo #348
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ | |
fmt | ||
alcotest.engine | ||
alcotest | ||
(re_export lwt.unix) ;; Unused dependency added for convenience to consumers | ||
)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Testing `test/e2e/alcotest-lwt/failing/async_failure.ml'. | ||
This run has ID `<uuid>'. | ||
|
||
> [FAIL] all 0 one. | ||
[OK] all 1 two. | ||
|
||
┌──────────────────────────────────────────────────────────────────────────────┐ | ||
│ [FAIL] all 0 one. │ | ||
└──────────────────────────────────────────────────────────────────────────────┘ | ||
freeing all resources | ||
[failure] All is broken | ||
Logs saved to `<build-context>/_build/_tests/<test-dir>/all.000.output'. | ||
────────────────────────────────────────────────────────────────────────────── | ||
|
||
Full test results in `<build-context>/_build/_tests/<test-dir>'. | ||
1 failure! in <test-duration>s. 2 tests run. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,11 @@ let free () = | |
let test_lwt switch () = | ||
Lwt_switch.add_hook (Some switch) free; | ||
Lwt.async (fun () -> failwith "All is broken"); | ||
Lwt_unix.sleep 10. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the reason for this 10 seconds sleep ? |
||
Lwt.pause () | ||
|
||
let () = | ||
let open Alcotest_lwt in | ||
Lwt_main.run | ||
Alcotest_test_helper.wakeup_until_resolved | ||
@@ run __FILE__ | ||
[ | ||
( "all", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Testing `test/e2e/alcotest-lwt/failing/fail_with.ml'. | ||
This run has ID `<uuid>'. | ||
|
||
> [FAIL] all 0 one. | ||
[OK] all 1 two. | ||
|
||
┌──────────────────────────────────────────────────────────────────────────────┐ | ||
│ [FAIL] all 0 one. │ | ||
└──────────────────────────────────────────────────────────────────────────────┘ | ||
[failure] should fail | ||
Logs saved to `<build-context>/_build/_tests/<test-dir>/all.000.output'. | ||
────────────────────────────────────────────────────────────────────────────── | ||
|
||
Full test results in `<build-context>/_build/_tests/<test-dir>'. | ||
1 failure! in <test-duration>s. 2 tests run. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Testing `Results should be in JSON, since --json is passed'. | ||
This run has ID `<uuid>'. | ||
|
||
{ | ||
"success": 1, | ||
"failures": 0, | ||
"time": <test-duration> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
let () = | ||
let open Alcotest_lwt in | ||
Lwt_main.run | ||
Alcotest_test_helper.wakeup_until_resolved | ||
@@ run "Results should be in JSON, since --json is passed" | ||
[ ("test", [ test_case "alpha" `Quick (fun _ () -> Lwt.return_unit) ]) ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let rec wakeup_until_resolved p = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be explained somewhere that to make the tests work with js we use a custom lwt event loop. |
||
Lwt.wakeup_paused (); | ||
match Lwt.poll p with | ||
| Some x -> x | ||
| None -> | ||
if Lwt.paused_count () > 0 then wakeup_until_resolved p | ||
else failwith "unresolved promise" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(library | ||
(name alcotest_test_helper) | ||
(libraries lwt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a breaking change.. I don't know how many packages depend on lwt.unix being re-exported though.