Skip to content

Commit

Permalink
test C program to check we can find the ocaml headers (#15)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #15

Test Plan: https://github.com/shayne-fletcher/ocaml-scripts/actions/runs/8104512093

Reviewed By: bigfootjon

Differential Revision: D54416893

Pulled By: shayne-fletcher

fbshipit-source-id: f64e37bc0c554afed620e764c07cdeb0b876ef0a
  • Loading branch information
shayne-fletcher authored and facebook-github-bot committed Mar 1, 2024
1 parent 916bb9f commit 35d76e6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ jobs:
os: [ubuntu, macos]
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: facebook/install-dotslash@latest
- run: sudo apt-get update && sudo apt-get install opam
if: matrix.os == 'ubuntu'
- run: brew install opam
if: matrix.os == 'macos'
- run: |-
opam init --compiler=5.1.1 --disable-sandboxing -y
opam install ocamlfind
opam init --color=always --compiler=5.1.1 --disable-sandboxing -y
opam install --color=always ocamlfind
opam env | sed -e "s/ export .*//g" -e "s/'//g" -e "s/\;//g" >> $GITHUB_ENV
- run: |-
mkdir -p third-party/ocaml
cd third-party/ocaml
ln -s "$OPAM_SWITCH_PREFIX" opam
- run: |-
(cd third-party/ocaml && ln -s "$OPAM_SWITCH_PREFIX" opam)
python3 dromedary.py -s "$(basename $OPAM_SWITCH_PREFIX)" -o third-party/ocaml/BUCK.test
cat third-party/ocaml/BUCK.test
- run: |-
PATH=$(pwd):$PATH; export PATH
buck2 run root//test:version -v 2
17 changes: 15 additions & 2 deletions test/BUCK.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Example commands to generate 'third-party/ocaml/BUCK.test'.
# ```
# mkdir -p third-party/ocaml
# python3 ~/project/ocaml-scripts/dromedary.py -s "$(basename $OPAM_SWITCH_PREFIX)" -o ~/project/ocaml-scripts/third-party/ocaml/BUCK.test
# ```

_SUPPORTED = not host_info().os.is_windows

# buildifier: disable=no-effect
cxx_binary(
name = "version",
srcs = ["version.c"],
deps = ["root//third-party/ocaml:ocaml-dev"],
) if _SUPPORTED else None

# buildifier: disable=no-effect
ocaml_binary(
name = "test-unix",
srcs = ["test_unix.ml"],
name = "unix",
srcs = ["unix.ml"],
deps = ["root//third-party/ocaml:unix"],
) if _SUPPORTED else None
File renamed without changes.
13 changes: 13 additions & 0 deletions test/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>

#include <caml/version.h>

char const* ocaml_version() {
return OCAML_VERSION_STRING;
}

int main() {
printf("The OCaml toolchain, version %s\n", ocaml_version());

return 0;
}

0 comments on commit 35d76e6

Please sign in to comment.