Skip to content

Commit

Permalink
CI: More wasm tests on window (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo authored Jan 17, 2025
1 parent 450d837 commit 3ab3b05
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 8 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/build-wasm_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
ocaml-compiler: "5.2"
separate_compilation: true
jane_street_tests: true
all_jane_street_tests: false
all_jane_street_tests: true
- os: ubuntu-latest
ocaml-compiler: "5.2"
separate_compilation: true
Expand Down Expand Up @@ -136,57 +136,68 @@ jobs:
run: opam exec -- dune build @runtest-wasm --profile with-effects

- name: Run Base tests
if: ${{ matrix.all_jane_street_tests || matrix.os == 'windows-latest' }}
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/base
run: opam exec -- dune runtest

- name: Run Base bigstring tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/base_bigstring
run: opam exec -- dune runtest

- name: Run Core tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/core
run: opam exec -- dune runtest

- name: Run Bignum tests
if: ${{ matrix.all_jane_street_tests || matrix.os == 'windows-latest' }}
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/bignum
run: opam exec -- dune runtest

- name: Run Bin_prot tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/bin_prot
run: opam exec -- dune runtest

- name: Run String_dict tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/string_dict
run: opam exec -- dune runtest

- name: Run Zarith tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/zarith_stubs_js
run: opam exec -- dune runtest

- name: Run Virtual_dom tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/virtual_dom
run: opam exec -- dune runtest

- name: Run Bonsai tests
if: matrix.all_jane_street_tests
if: ${{ matrix.all_jane_street_tests && matrix.os != 'windows-latest' }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/bonsai_test
run: opam exec -- dune runtest

- name: Run Bonsai web tests
if: matrix.all_jane_street_tests
if: ${{ matrix.all_jane_street_tests && matrix.os != 'windows-latest' }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/bonsai_web_test
run: opam exec -- dune runtest

- name: Run Bonsai web components' tests
if: matrix.all_jane_street_tests
if: ${{ matrix.all_jane_street_tests && matrix.os != 'windows-latest' }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
working-directory: ./janestreet/lib/bonsai_web_components
run: opam exec -- dune runtest

Expand Down
108 changes: 106 additions & 2 deletions tools/ci_setup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let dune_workspace =
(_
(env-vars (TESTING_FRAMEWORK inline-test))
(js_of_ocaml (enabled_if false))
(flags :standard -warn-error -7-8-27-30-32-34-37-49-52-55 -w -67-69)))
(flags :standard -warn-error -7-8-27-30-32-34-37-49-52-55 -w -7-27-30-32-34-37-49-52-55-58-67-69)))
|}

let node_wrapper =
Expand Down Expand Up @@ -126,8 +126,111 @@ index c6d09fb..61b1e5b 100644
let t' = require_no_allocation (fun () -> abs t) in
|bignum}
)
; ( "bin_prot"
, {|
diff --git a/test/dune b/test/dune
index 6c0ef2f..9968f59 100644
--- a/test/dune
+++ b/test/dune
@@ -5,11 +5,3 @@
float_array base.md5 sexplib splittable_random stdio)
(preprocess
(pps ppx_jane)))
-
-(rule
- (alias runtest)
- (deps core/blob_stability_tests.ml integers_repr_tests_64bit.ml
- integers_repr_tests_js.ml integers_repr_tests_wasm.ml)
- (action
- (bash
- "diff <(\necho '869e6b3143f14201f406eac9c05c4cdb core/blob_stability_tests.ml'\necho '2db396dfced6ae8d095f308acb4c80eb integers_repr_tests_64bit.ml'\necho '9f7b6332177a4ae9547d37d17008d7ef integers_repr_tests_js.ml'\necho '22f653bfba79ce30c22fe378c596df54 integers_repr_tests_wasm.ml'\n ) <(md5sum %{deps})")))
|}
)
; ( "base_bigstring"
, {|
diff --git a/src/base_bigstring_stubs.c b/src/base_bigstring_stubs.c
index 164c393..6cf4835 100644
--- a/src/base_bigstring_stubs.c
+++ b/src/base_bigstring_stubs.c
@@ -17,6 +17,50 @@
#include <assert.h>
#include <stdint.h>

+
+static inline void * mymemrchr(const void * s, int c, size_t n)
+{
+ const unsigned char * p = (const unsigned char *)s + n;
+
+ while (n--) {
+ if (*(--p) == (unsigned char) c) {
+ return (void *)p;
+ }
+ }
+
+ return NULL;
+}
+static inline void *mymemmem(const void *haystack, size_t haystack_len,
+ const void *needle, size_t needle_len)
+{
+ const char *begin = haystack;
+ const char *last_possible = begin + haystack_len - needle_len;
+ const char *tail = needle;
+ char point;
+
+ /*
+ * The first occurrence of the empty string is deemed to occur at
+ * the beginning of the string.
+ */
+ if (needle_len == 0)
+ return (void *)begin;
+
+ /*
+ * Sanity check, otherwise the loop might search through the whole
+ * memory.
+ */
+ if (haystack_len < needle_len)
+ return NULL;
+
+ point = *tail++;
+ for (; begin <= last_possible; begin++) {
+ if (*begin == point && !memcmp(begin + 1, tail, needle_len - 1))
+ return (void *)begin;
+ }
+
+ return NULL;
+}
+
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define bswap_16 OSSwapInt16
@@ -239,7 +283,7 @@ CAMLprim value bigstring_rfind(value v_str, value v_needle,
char *start, *r;

start = get_bstr(v_str, v_pos);
- r = (char*) memrchr(start, Int_val(v_needle), Long_val(v_len));
+ r = (char*) mymemrchr(start, Int_val(v_needle), Long_val(v_len));

return ptr_to_offset(start, v_pos, r);
}
@@ -250,7 +294,7 @@ CAMLprim value bigstring_memmem(value v_haystack, value v_needle,
{
const char *haystack = get_bstr(v_haystack, v_haystack_pos);
const char *needle = get_bstr(v_needle, v_needle_pos);
- const char *result = memmem(haystack, Long_val(v_haystack_len),
+ const char *result = mymemmem(haystack, Long_val(v_haystack_len),
needle, Long_val(v_needle_len));

return ptr_to_offset(haystack, v_haystack_pos, result);
|}
)
]

let removes =
[ "core/core/test/test_sys.ml"
; "core/core/test/test_sys.mli"
; "core/core/test/test_timezone.ml"
; "core/core/test/test_timezone.mli"
]
(****)

let read_opam_file filename =
Expand Down Expand Up @@ -279,4 +382,5 @@ let () =
| WSTOPPED n -> "stop", n
in
failwith (Printf.sprintf "%s %d while patching %s" name i dir))
patches
patches;
List.iter (fun p -> Sys.remove (Printf.sprintf "%s/lib/%s" jane_root p)) removes

0 comments on commit 3ab3b05

Please sign in to comment.