From 512356f01bb2be74c2214465faf19692755806f7 Mon Sep 17 00:00:00 2001 From: "Guillaume \"Liam\" Petiot" Date: Wed, 20 Mar 2024 12:59:09 +0000 Subject: [PATCH] Only use ppx_expect in tests (#29) --- CHANGES.md | 6 ++ lib/contributions.ml | 100 ---------------------------- lib/dune | 3 +- test/expect/dune | 6 ++ test/expect/main.ml | 152 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 102 deletions(-) create mode 100644 test/expect/dune create mode 100644 test/expect/main.ml diff --git a/CHANGES.md b/CHANGES.md index dbb66b5..15813a7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +## unreleased + +### Fixed + +- `ppx_expect` is now only used in tests (#29, @gpetiot) + ## 1.0.0 ### Added diff --git a/lib/contributions.ml b/lib/contributions.ml index 13d3dce..3db81bd 100644 --- a/lib/contributions.ml +++ b/lib/contributions.ml @@ -205,103 +205,3 @@ let pp f { activity; _ } = | repos -> Fmt.(list ~sep:(cut ++ cut)) pp_repo f repos let pp fs t = Fmt.pf fs "@[%a@]" pp t - -let%expect_test "Contributions.pp" = - let contributions_example = { username = "me"; activity = Repo_map.empty } in - Format.printf "%a" pp contributions_example; - [%expect {| - (no activity) |}] - -let contributions_example = - { - username = "me"; - activity = - Repo_map.empty - |> Repo_map.add "gpetiot/js_of_ocaml" - [ - { - repo = "gpetiot/js_of_ocaml"; - kind = `New_repo; - date = "2024-03-01T10:43:33Z"; - url = "https://github.com/gpetiot/js_of_ocaml"; - title = "Title1"; - body = ""; - }; - ] - |> Repo_map.add "realworldocaml/mdx" - [ - { - repo = "realworldocaml/mdx"; - kind = `Review "APPROVED"; - date = "2024-03-05T11:43:04Z"; - url = - "https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244"; - title = "Title2"; - body = "xxx"; - }; - { - repo = "realworldocaml/mdx"; - kind = `PR; - date = "2024-03-04T17:20:11Z"; - url = "https://github.com/realworldocaml/mdx/pull/450"; - title = "Title3"; - body = "xxx"; - }; - ] - |> Repo_map.add "tarides/okra" - [ - { - repo = "tarides/okra"; - kind = `Review "APPROVED"; - date = "2024-02-28T11:09:41Z"; - url = - "https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361"; - title = "Title4"; - body = "xxx"; - }; - { - repo = "tarides/okra"; - kind = `Issue; - date = "2024-02-27T12:05:04Z"; - url = "https://github.com/tarides/okra/issues/165"; - title = "Title5"; - body = "xxx"; - }; - { - repo = "tarides/okra"; - kind = `Issue_comment; - date = "2024-03-13T11:09:56Z"; - url = - "https://github.com/tarides/okra/issues/114#issuecomment-1994130584"; - title = "Title6"; - body = "xxx"; - }; - ]; - } - -let%expect_test "Contributions.pp" = - Format.printf "%a" pp contributions_example; - [%expect - {| - ### gpetiot/js_of_ocaml - - Created repository [gpetiot/js_of_ocaml](https://github.com/gpetiot/js_of_ocaml). - - ### realworldocaml/mdx - - APPROVED Title2 [#449](https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244). - xxx - - Title3 [#450](https://github.com/realworldocaml/mdx/pull/450). - xxx - - ### tarides/okra - - APPROVED Title4 [#166](https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361). - xxx - - Title5 [#165](https://github.com/tarides/okra/issues/165). - xxx - - Commented on "Title6" [#114](https://github.com/tarides/okra/issues/114#issuecomment-1994130584). - xxx |}] diff --git a/lib/dune b/lib/dune index f99f432..921b990 100644 --- a/lib/dune +++ b/lib/dune @@ -2,6 +2,5 @@ (name get_activity) (public_name get-activity-lib) (libraries astring curly fmt yojson) - (inline_tests) (preprocess - (pps ppx_expect ppx_yojson_conv))) + (pps ppx_yojson_conv))) diff --git a/test/expect/dune b/test/expect/dune new file mode 100644 index 0000000..6cd2354 --- /dev/null +++ b/test/expect/dune @@ -0,0 +1,6 @@ +(library + (name expect) + (inline_tests) + (libraries get-activity-lib) + (preprocess + (pps ppx_expect))) diff --git a/test/expect/main.ml b/test/expect/main.ml new file mode 100644 index 0000000..562cbae --- /dev/null +++ b/test/expect/main.ml @@ -0,0 +1,152 @@ +open Get_activity + +let contributions_example ~user = + let open Contributions in + { + username = user; + activity = + Repo_map.empty + |> Repo_map.add "gpetiot/config.ml" + [ + { + repo = "gpetiot/config.ml"; + kind = `New_repo; + date = "2024-03-02T09:40:41Z"; + url = "https://github.com/gpetiot/config.ml"; + title = "Created new repository"; + body = ""; + }; + ] + |> Repo_map.add "gpetiot/js_of_ocaml" + [ + { + repo = "gpetiot/js_of_ocaml"; + kind = `New_repo; + date = "2024-03-01T10:43:33Z"; + url = "https://github.com/gpetiot/js_of_ocaml"; + title = "Created new repository"; + body = ""; + }; + ] + |> Repo_map.add "ocaml-ppx/ocamlformat" + [ + { + repo = "ocaml-ppx/ocamlformat"; + kind = `PR; + date = "2024-03-05T11:21:22Z"; + url = "https://github.com/ocaml-ppx/ocamlformat/pull/2533"; + title = "Represent the expr sequence as a list"; + body = "xxx"; + }; + ] + |> Repo_map.add "realworldocaml/mdx" + [ + { + repo = "realworldocaml/mdx"; + kind = `Review "APPROVED"; + date = "2024-03-05T11:43:04Z"; + url = + "https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244"; + title = "Add upgrade instructions in the changelog for #446"; + body = "xxx"; + }; + { + repo = "realworldocaml/mdx"; + kind = `PR; + date = "2024-03-04T17:20:11Z"; + url = "https://github.com/realworldocaml/mdx/pull/450"; + title = "Add an 'exec' label to execute include OCaml blocks"; + body = "xxx"; + }; + ] + |> Repo_map.add "tarides/get-activity" + [ + { + repo = "tarides/get-activity"; + kind = `Issue; + date = "2024-03-04T11:55:37Z"; + url = "https://github.com/tarides/get-activity/issues/8"; + title = + "Add the PR/issues comments to the result of okra generate"; + body = "xxx"; + }; + ] + |> Repo_map.add "tarides/okra" + [ + { + repo = "tarides/okra"; + kind = `Review "APPROVED"; + date = "2024-02-28T11:09:41Z"; + url = + "https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361"; + title = "Make README.md more precise"; + body = "xxx"; + }; + { + repo = "tarides/okra"; + kind = `Issue_comment; + date = "2024-03-13T11:09:56Z"; + url = + "https://github.com/tarides/okra/issues/114#issuecomment-1994130584"; + title = "Gitlab: exception when parsing Gitlab's JSON"; + body = "xxx"; + }; + { + repo = "tarides/okra"; + kind = `Issue; + date = "2024-02-27T12:05:04Z"; + url = "https://github.com/tarides/okra/issues/165"; + title = "Make the `get-activity` package known to ocaml-ci"; + body = "xxx"; + }; + ]; + } + +let%expect_test "Contributions.pp" = + let open Contributions in + let contributions_example = { username = "me"; activity = Repo_map.empty } in + Format.printf "%a" pp contributions_example; + [%expect {| + (no activity) |}] + +let%expect_test "Contributions.pp" = + let open Contributions in + Format.printf "%a" pp (contributions_example ~user:"me"); + [%expect + {| + ### gpetiot/config.ml + + Created repository [gpetiot/config.ml](https://github.com/gpetiot/config.ml). + + ### gpetiot/js_of_ocaml + + Created repository [gpetiot/js_of_ocaml](https://github.com/gpetiot/js_of_ocaml). + + ### ocaml-ppx/ocamlformat + + Represent the expr sequence as a list [#2533](https://github.com/ocaml-ppx/ocamlformat/pull/2533). + xxx + + ### realworldocaml/mdx + + APPROVED Add upgrade instructions in the changelog for #446 [#449](https://github.com/realworldocaml/mdx/pull/449#pullrequestreview-1916654244). + xxx + + Add an 'exec' label to execute include OCaml blocks [#450](https://github.com/realworldocaml/mdx/pull/450). + xxx + + ### tarides/get-activity + + Add the PR/issues comments to the result of okra generate [#8](https://github.com/tarides/get-activity/issues/8). + xxx + + ### tarides/okra + + APPROVED Make README.md more precise [#166](https://github.com/tarides/okra/pull/166#pullrequestreview-1905972361). + xxx + + Commented on "Gitlab: exception when parsing Gitlab's JSON" [#114](https://github.com/tarides/okra/issues/114#issuecomment-1994130584). + xxx + + Make the `get-activity` package known to ocaml-ci [#165](https://github.com/tarides/okra/issues/165). + xxx |}]