From 35d76e6e803388554f620c78398c6ee4109bfb7a Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Fri, 1 Mar 2024 09:12:41 -0800 Subject: [PATCH] test C program to check we can find the ocaml headers (#15) Summary: Pull Request resolved: https://github.com/facebook/ocaml-scripts/pull/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 --- .github/workflows/run-tests.yml | 14 +++++++++----- test/BUCK.test | 17 +++++++++++++++-- test/{test_unix.ml => unix.ml} | 0 test/version.c | 13 +++++++++++++ 4 files changed, 37 insertions(+), 7 deletions(-) rename test/{test_unix.ml => unix.ml} (100%) create mode 100644 test/version.c diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bfb1a93..2c67de0 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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 diff --git a/test/BUCK.test b/test/BUCK.test index 3317e26..238b13d 100644 --- a/test/BUCK.test +++ b/test/BUCK.test @@ -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 diff --git a/test/test_unix.ml b/test/unix.ml similarity index 100% rename from test/test_unix.ml rename to test/unix.ml diff --git a/test/version.c b/test/version.c new file mode 100644 index 0000000..f323c12 --- /dev/null +++ b/test/version.c @@ -0,0 +1,13 @@ +#include + +#include + +char const* ocaml_version() { + return OCAML_VERSION_STRING; +} + +int main() { + printf("The OCaml toolchain, version %s\n", ocaml_version()); + + return 0; +}