Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Cstruct
on: [push, pull_request]
jobs:
# cstruct and its runtime siblings build on modern OCaml, including 5.x.
build:
name: ${{ matrix.ocaml-compiler }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -10,33 +9,14 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
ocaml-compiler:
- "5.3"
- "5.5"
- "5.1"
- "4.14"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
- run: >-
opam install ./cstruct.opam ./cstruct-sexp.opam ./cstruct-unix.opam
./cstruct-lwt.opam --deps-only
- run: opam exec -- dune build -p cstruct,cstruct-sexp,cstruct-unix,cstruct-lwt

# ppx_cstruct (ocaml-migrate-parsetree) and cstruct-async (async) do not build
# on OCaml 5.x, so run the full build and test on 4.14.
test:
name: full build + test (4.14) / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "4.14"
- run: opam install . --deps-only --with-test
- run: opam exec -- dune build
- run: opam exec -- dune build @all
- run: opam exec -- dune runtest
1 change: 1 addition & 0 deletions async/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
(name async_cstruct)
(wrapped false)
(public_name cstruct-async)
(allow_overlapping_dependencies)
(libraries core cstruct async async_unix))
6 changes: 3 additions & 3 deletions cstruct-async.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ build: [
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "3.17"}
"async" {>= "v0.9.0" & < "v0.17.0"}
"async_unix" {>= "v0.9.0" & < "v0.17.0"}
"core" {>= "v0.9.0" & < "v0.17.0"}
"async" {>= "v0.9.0"}
"async_unix" {>= "v0.9.0"}
"core" {>= "v0.9.0"}
"cstruct" {=version}
]
synopsis: "Access C-like structures directly from OCaml"
Expand Down
4 changes: 1 addition & 3 deletions ppx_cstruct.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ depends: [
"dune" {>= "3.17"}
"cstruct" {=version}
"ounit" {with-test}
"ppxlib" {>= "0.16.0"}
"ppxlib" {>= "0.28.0"}
"ppx_sexp_conv" {with-test}
"sexplib" {>="v0.9.0"}
"cstruct-sexp" {with-test}
"cppo" {with-test}
"cstruct-unix" {with-test & =version}
"ocaml-migrate-parsetree" {>= "2.1.0" & with-test}
"lwt_ppx" {>= "2.0.2" & with-test}
]
synopsis: "Access C-like structures directly from OCaml"
Expand Down
11 changes: 7 additions & 4 deletions ppx_test/errors/dune
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
(executable
(name pp)
(modules pp)
(preprocess
(action
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file})))
(libraries ppx_cstruct ocaml-migrate-parsetree))
(libraries ppx_cstruct))

(executable
(name gen_tests)
(modules gen_tests))

(env
(_
(env-vars
(OCAML_COLOR never)
(OCAML_ERROR_STYLE short))))

(include dune.inc)

(rule
Expand Down
80 changes: 48 additions & 32 deletions ppx_test/errors/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
(targets cenum_id_payload.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -18,8 +19,9 @@
(targets cenum_invalid_type.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -32,8 +34,9 @@
(targets cenum_no_attribute.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -46,8 +49,9 @@
(targets cenum_not_a_variant.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -60,8 +64,9 @@
(targets cenum_unknown_attribute.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -74,8 +79,9 @@
(targets cstruct_attribute_payload.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -88,8 +94,9 @@
(targets cstruct_duplicate_field.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -102,8 +109,9 @@
(targets cstruct_len_int32.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -116,8 +124,9 @@
(targets cstruct_len_not_int.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -130,8 +139,9 @@
(targets cstruct_len_zero.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -144,8 +154,9 @@
(targets cstruct_multiple_len.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -158,8 +169,9 @@
(targets cstruct_not_a_record.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -172,8 +184,9 @@
(targets cstruct_not_an_identifier.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -186,8 +199,9 @@
(targets cstruct_several_attributes.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -200,8 +214,9 @@
(targets cstruct_unknown_endian.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand All @@ -214,8 +229,9 @@
(targets cstruct_unknown_type.ml.errors)
(action
(progn
(with-stderr-to %{targets}
(run ./pp.exe -no-color --impl %{input}))
(with-accepted-exit-codes 1
(with-stderr-to %{targets}
(run ./pp.exe --impl %{input})))
(bash "sed -i.bak '1d' %{targets}"))))
(rule
(alias runtest)
Expand Down
5 changes: 3 additions & 2 deletions ppx_test/errors/gen_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ let output_stanzas name =
(targets %s.errors)
(action
(progn
(with-stderr-to %%{targets}
(run ./pp.exe -no-color --impl %%{input}))
(with-accepted-exit-codes 1
(with-stderr-to %%{targets}
(run ./pp.exe --impl %%{input})))
(bash "sed -i.bak '1d' %%{targets}"))))
(rule
(alias runtest)
Expand Down
10 changes: 0 additions & 10 deletions ppx_test/errors/pp.ml
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
(* we can just use exit from 4.07 onwards, but 4.06
* and earlier executed at_exit recursively *)
external sys_exit : int -> 'a = "caml_sys_exit"
let () = at_exit (fun () -> sys_exit 0)

#if OCAML_VERSION >= (4,8,0)
let () = Clflags.(error_style := Some Short)
#endif

let () = Clflags.(color := Some Never)
let () = Ppxlib.Driver.standalone ()
Loading