Compare commits
7 Commits
f33-riscv6
...
rawhide
Author | SHA1 | Date | |
---|---|---|---|
|
78a0fb606c | ||
|
6423c203c9 | ||
|
21f35b7b47 | ||
|
c5e415b766 | ||
|
469dd7cfa1 | ||
|
fdc55979c1 | ||
|
23d81e9d0c |
@ -4,15 +4,23 @@
|
|||||||
|
|
||||||
%global srcname ppx-assert
|
%global srcname ppx-assert
|
||||||
%global upname ppx_assert
|
%global upname ppx_assert
|
||||||
|
%global upstream_version 0.14.0
|
||||||
|
|
||||||
Name: ocaml-%{srcname}
|
Name: ocaml-%{srcname}
|
||||||
Version: 0.14.0
|
Version: 0.15.0
|
||||||
Release: 3%{?dist}
|
Release: 0.git78f9989.1%{?dist}
|
||||||
Summary: Assert-like extension nodes that raise useful errors on failure
|
Summary: Assert-like extension nodes that raise useful errors on failure
|
||||||
|
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://github.com/janestreet/%{upname}
|
URL: https://github.com/janestreet/%{upname}
|
||||||
Source0: %{url}/archive/v%{version}/%{upname}-%{version}.tar.gz
|
Source0: %{url}/archive/v%{upstream_version}/%{upname}-%{upstream_version}.tar.gz
|
||||||
|
|
||||||
|
# Include all changes from upstream since 0.14 was released.
|
||||||
|
# Upstream doesn't apparently believe in commit messages, and
|
||||||
|
# the individual patches don't make any sense, so bundle this
|
||||||
|
# as a single diff.
|
||||||
|
# git diff 3993004 > ppx_assert_0.14_0.15.patch
|
||||||
|
Patch1: ppx_assert_0.14_0.15.patch
|
||||||
|
|
||||||
BuildRequires: ocaml >= 4.04.2
|
BuildRequires: ocaml >= 4.04.2
|
||||||
BuildRequires: ocaml-base-devel >= 0.14
|
BuildRequires: ocaml-base-devel >= 0.14
|
||||||
@ -42,10 +50,10 @@ The %{name}-devel package contains libraries and signature
|
|||||||
files for developing applications that use %{name}.
|
files for developing applications that use %{name}.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{upname}-%{version}
|
%autosetup -n %{upname}-%{upstream_version} -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
dune build %{?_smp_mflags} --display=verbose
|
dune build %{?_smp_mflags} --display=verbose --profile release
|
||||||
dune build %{?_smp_mflags} @doc
|
dune build %{?_smp_mflags} @doc
|
||||||
|
|
||||||
%install
|
%install
|
||||||
@ -104,6 +112,24 @@ dune runtest
|
|||||||
%{_libdir}/ocaml/%{upname}/*/*.mli
|
%{_libdir}/ocaml/%{upname}/*/*.mli
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Mar 2 23:22:54 GMT 2021 Richard W.M. Jones <rjones@redhat.com> - 0.15.0-0.git78f9989.1
|
||||||
|
- Package latest upstream for OCaml 4.12.
|
||||||
|
|
||||||
|
* Mon Mar 1 23:22:54 GMT 2021 Richard W.M. Jones <rjones@redhat.com> - 0.14.0-8
|
||||||
|
- OCaml 4.12.0 build
|
||||||
|
|
||||||
|
* Sat Feb 20 2021 Jerry James <loganjerry@gmail.com> - 0.14.0-7
|
||||||
|
- Rebuild for ocaml-base 0.14.1
|
||||||
|
|
||||||
|
* Wed Feb 3 2021 Richard W.M. Jones <rjones@redhat.com> - 0.14.0-6
|
||||||
|
- Bump and rebuild for updated ocaml Dynlink dependency.
|
||||||
|
|
||||||
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.0-5
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
|
|
||||||
|
* Mon Dec 7 2020 Jerry James <loganjerry@gmail.com> - 0.14.0-4
|
||||||
|
- Rebuild for ocaml-ppxlib 0.15.0
|
||||||
|
|
||||||
* Tue Sep 01 2020 Richard W.M. Jones <rjones@redhat.com> - 0.14.0-3
|
* Tue Sep 01 2020 Richard W.M. Jones <rjones@redhat.com> - 0.14.0-3
|
||||||
- OCaml 4.11.1 rebuild
|
- OCaml 4.11.1 rebuild
|
||||||
|
|
||||||
|
222
ppx_assert_0.14_0.15.patch
Normal file
222
ppx_assert_0.14_0.15.patch
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
diff --git a/LICENSE.md b/LICENSE.md
|
||||||
|
index 858593c..fe0f3a4 100644
|
||||||
|
--- a/LICENSE.md
|
||||||
|
+++ b/LICENSE.md
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
-Copyright (c) 2015--2020 Jane Street Group, LLC <opensource@janestreet.com>
|
||||||
|
+Copyright (c) 2015--2021 Jane Street Group, LLC <opensource@janestreet.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
diff --git a/README.md b/README.md
|
||||||
|
index ae04c8d..3606fa2 100644
|
||||||
|
--- a/README.md
|
||||||
|
+++ b/README.md
|
||||||
|
@@ -1,7 +1,7 @@
|
||||||
|
ppx\_assert
|
||||||
|
===========
|
||||||
|
|
||||||
|
-Assert-like extension nodes that raise useful errors on failure.
|
||||||
|
+Extension nodes to compare value and raise useful errors if they differ.
|
||||||
|
|
||||||
|
This ppx rewriter defines 3 extension nodes.
|
||||||
|
|
||||||
|
@@ -51,11 +51,12 @@ then an exception containing the value shown using `[%sexp_of: typ]` is thrown.
|
||||||
|
Intended usage
|
||||||
|
--------------
|
||||||
|
|
||||||
|
-These assertions are very useful when testing. Compared to using `assert (x = y)`, you can
|
||||||
|
-see the values that are not equal, and the assertion is not turned off by
|
||||||
|
-`-noassert`. Compared to using the various `assert_bool` or `assert_string` functions you
|
||||||
|
-can find in various unit testing libraries, it works with any sexpable and comparable type
|
||||||
|
-for zero effort. For instance, tests commonly look like this:
|
||||||
|
+These assertions are very useful when testing. Compared to using `assert (x = y)`, errors
|
||||||
|
+display the values that are not equal. Also, there is no mechanism to remove these tests
|
||||||
|
+in production builds like `-noassert` does for `assert`. Compared to using the various
|
||||||
|
+`assert_bool` or `assert_string` functions you can find in various unit testing libraries,
|
||||||
|
+it works with any sexpable and comparable type for zero effort. For instance, tests
|
||||||
|
+commonly look like this:
|
||||||
|
|
||||||
|
```ocaml
|
||||||
|
let%test_unit "List.length" =
|
||||||
|
diff --git a/ppx_assert.opam b/ppx_assert.opam
|
||||||
|
index 87edd15..997c1b3 100644
|
||||||
|
--- a/ppx_assert.opam
|
||||||
|
+++ b/ppx_assert.opam
|
||||||
|
@@ -1,5 +1,4 @@
|
||||||
|
opam-version: "2.0"
|
||||||
|
-version: "v0.14.0"
|
||||||
|
maintainer: "opensource@janestreet.com"
|
||||||
|
authors: ["Jane Street Group, LLC <opensource@janestreet.com>"]
|
||||||
|
homepage: "https://github.com/janestreet/ppx_assert"
|
||||||
|
@@ -11,14 +10,14 @@ build: [
|
||||||
|
["dune" "build" "-p" name "-j" jobs]
|
||||||
|
]
|
||||||
|
depends: [
|
||||||
|
- "ocaml" {>= "4.04.2"}
|
||||||
|
- "base" {>= "v0.14" & < "v0.15"}
|
||||||
|
- "ppx_cold" {>= "v0.14" & < "v0.15"}
|
||||||
|
- "ppx_compare" {>= "v0.14" & < "v0.15"}
|
||||||
|
- "ppx_here" {>= "v0.14" & < "v0.15"}
|
||||||
|
- "ppx_sexp_conv" {>= "v0.14" & < "v0.15"}
|
||||||
|
+ "ocaml" {>= "4.08.0"}
|
||||||
|
+ "base"
|
||||||
|
+ "ppx_cold"
|
||||||
|
+ "ppx_compare"
|
||||||
|
+ "ppx_here"
|
||||||
|
+ "ppx_sexp_conv"
|
||||||
|
"dune" {>= "2.0.0"}
|
||||||
|
- "ppxlib" {>= "0.11.0"}
|
||||||
|
+ "ppxlib" {>= "0.15.0" & < "0.18.0"}
|
||||||
|
]
|
||||||
|
synopsis: "Assert-like extension nodes that raise useful errors on failure"
|
||||||
|
description: "
|
||||||
|
diff --git a/runtime-lib/runtime.ml b/runtime-lib/runtime.ml
|
||||||
|
index cb05ebd..a05f36a 100644
|
||||||
|
--- a/runtime-lib/runtime.ml
|
||||||
|
+++ b/runtime-lib/runtime.ml
|
||||||
|
@@ -25,9 +25,7 @@ type 'a test_result
|
||||||
|
|
||||||
|
exception E of string * Sexp.t [@@deriving sexp]
|
||||||
|
|
||||||
|
-let failwith message sexp = raise (E (message, sexp))
|
||||||
|
-
|
||||||
|
-let fail_in_sexp_style ~message ~pos ~here ~tag body =
|
||||||
|
+let exn_sexp_style ~message ~pos ~here ~tag body =
|
||||||
|
let message =
|
||||||
|
match message with
|
||||||
|
| None -> tag
|
||||||
|
@@ -45,16 +43,19 @@ let fail_in_sexp_style ~message ~pos ~here ~tag body =
|
||||||
|
end
|
||||||
|
)
|
||||||
|
in
|
||||||
|
- failwith message sexp
|
||||||
|
+ (* Here and in other places we return exceptions, rather than directly raising, and
|
||||||
|
+ instead raise at the latest moment possible, so backtrace don't include noise from
|
||||||
|
+ these functions that construct exceptions. *)
|
||||||
|
+ E (message, sexp)
|
||||||
|
|
||||||
|
-let [@cold] test_pred_failed ~message ~pos ~here ~sexpifier t =
|
||||||
|
- fail_in_sexp_style ~message ~pos ~here ~tag:"predicate failed" [
|
||||||
|
+let [@cold] exn_test_pred ~message ~pos ~here ~sexpifier t =
|
||||||
|
+ exn_sexp_style ~message ~pos ~here ~tag:"predicate failed" [
|
||||||
|
Sexp.List [Sexp.Atom "Value"; sexpifier t]
|
||||||
|
]
|
||||||
|
|
||||||
|
let test_pred ~pos ~sexpifier ~here ?message predicate t =
|
||||||
|
if not (predicate t) then
|
||||||
|
- test_pred_failed ~message ~pos ~here ~sexpifier t
|
||||||
|
+ raise (exn_test_pred ~message ~pos ~here ~sexpifier t)
|
||||||
|
|
||||||
|
let r_diff : (from_:string -> to_:string -> unit) option ref = ref None
|
||||||
|
let set_diff_function f = r_diff := f
|
||||||
|
@@ -81,8 +82,8 @@ let test_result_or_eq ~sexpifier ~comparator ?equal ~expect ~got =
|
||||||
|
then `Pass
|
||||||
|
else test_result_or_eq_failed ~sexpifier ~expect ~got
|
||||||
|
|
||||||
|
-let [@cold] test_eq_failed ~message ~pos ~here ~t1 ~t2 =
|
||||||
|
- fail_in_sexp_style ~message ~pos ~here ~tag:"comparison failed" [
|
||||||
|
+let [@cold] exn_test_eq ~message ~pos ~here ~t1 ~t2 =
|
||||||
|
+ exn_sexp_style ~message ~pos ~here ~tag:"comparison failed" [
|
||||||
|
t1;
|
||||||
|
Sexp.Atom "vs";
|
||||||
|
t2;
|
||||||
|
@@ -91,10 +92,10 @@ let [@cold] test_eq_failed ~message ~pos ~here ~t1 ~t2 =
|
||||||
|
let test_eq ~pos ~sexpifier ~comparator ~here ?message ?equal t1 t2 =
|
||||||
|
match test_result_or_eq ~sexpifier ~comparator ?equal ~expect:t1 ~got:t2 with
|
||||||
|
| `Pass -> ()
|
||||||
|
- | `Fail (t1, t2) -> test_eq_failed ~message ~pos ~here ~t1 ~t2
|
||||||
|
+ | `Fail (t1, t2) -> raise (exn_test_eq ~message ~pos ~here ~t1 ~t2)
|
||||||
|
|
||||||
|
-let [@cold] test_result_failed ~message ~pos ~here ~expect ~got =
|
||||||
|
- fail_in_sexp_style ~message ~pos ~here ~tag:"got unexpected result" [
|
||||||
|
+let [@cold] exn_test_result ~message ~pos ~here ~expect ~got =
|
||||||
|
+ exn_sexp_style ~message ~pos ~here ~tag:"got unexpected result" [
|
||||||
|
Sexp.List [Sexp.Atom "expected"; expect];
|
||||||
|
Sexp.List [Sexp.Atom "got"; got];
|
||||||
|
]
|
||||||
|
@@ -102,4 +103,4 @@ let [@cold] test_result_failed ~message ~pos ~here ~expect ~got =
|
||||||
|
let test_result ~pos ~sexpifier ~comparator ~here ?message ?equal ~expect ~got =
|
||||||
|
match test_result_or_eq ~sexpifier ~comparator ?equal ~expect ~got with
|
||||||
|
| `Pass -> ()
|
||||||
|
- | `Fail (expect, got) -> test_result_failed ~message ~pos ~here ~expect ~got
|
||||||
|
+ | `Fail (expect, got) -> raise (exn_test_result ~message ~pos ~here ~expect ~got)
|
||||||
|
diff --git a/runtime-lib/runtime.mli b/runtime-lib/runtime.mli
|
||||||
|
index aeb39e9..4e051d7 100644
|
||||||
|
--- a/runtime-lib/runtime.mli
|
||||||
|
+++ b/runtime-lib/runtime.mli
|
||||||
|
@@ -18,7 +18,7 @@ type 'a test_eq
|
||||||
|
-> unit
|
||||||
|
|
||||||
|
type 'a test_result
|
||||||
|
- = ?here:Lexing.position list
|
||||||
|
+ = ?here:Lexing.position list
|
||||||
|
-> ?message:string
|
||||||
|
-> ?equal:('a -> 'a -> bool)
|
||||||
|
-> expect:'a
|
||||||
|
diff --git a/src/ppx_assert.ml b/src/ppx_assert.ml
|
||||||
|
index 2bf9887..84abad4 100644
|
||||||
|
--- a/src/ppx_assert.ml
|
||||||
|
+++ b/src/ppx_assert.ml
|
||||||
|
@@ -3,10 +3,10 @@ open Ppxlib
|
||||||
|
let expand_test_pred ~loc:_ ~path:_ typ =
|
||||||
|
let loc = { typ.ptyp_loc with loc_ghost = true } in
|
||||||
|
[%expr fun ?(here= []) ?message predicate t ->
|
||||||
|
- let pos = [%e Ppx_here_expander.lift_position_as_string ~loc] in
|
||||||
|
- let sexpifier = [%e Ppx_sexp_conv_expander.Sexp_of.core_type typ] in
|
||||||
|
- Ppx_assert_lib.Runtime.test_pred
|
||||||
|
- ~pos ~sexpifier ~here ?message predicate t
|
||||||
|
+ let pos = [%e Ppx_here_expander.lift_position_as_string ~loc] in
|
||||||
|
+ let sexpifier = [%e Ppx_sexp_conv_expander.Sexp_of.core_type typ] in
|
||||||
|
+ Ppx_assert_lib.Runtime.test_pred
|
||||||
|
+ ~pos ~sexpifier ~here ?message predicate t
|
||||||
|
]
|
||||||
|
;;
|
||||||
|
|
||||||
|
@@ -14,28 +14,28 @@ let expand_test_pred ~loc:_ ~path:_ typ =
|
||||||
|
let expand_test_eq ~loc:_ ~path:_ typ =
|
||||||
|
let loc = { typ.ptyp_loc with loc_ghost = true } in
|
||||||
|
[%expr fun ?(here= []) ?message ?equal t1 t2 ->
|
||||||
|
- let pos = [%e Ppx_here_expander.lift_position_as_string ~loc] in
|
||||||
|
- let sexpifier = [%e Ppx_sexp_conv_expander.Sexp_of.core_type typ] in
|
||||||
|
- let comparator =
|
||||||
|
- [%e Merlin_helpers.hide_expression
|
||||||
|
- (Ppx_compare_expander.Compare.core_type typ) ]
|
||||||
|
- in
|
||||||
|
- Ppx_assert_lib.Runtime.test_eq
|
||||||
|
- ~pos ~sexpifier ~comparator ~here ?message ?equal t1 t2
|
||||||
|
+ let pos = [%e Ppx_here_expander.lift_position_as_string ~loc] in
|
||||||
|
+ let sexpifier = [%e Ppx_sexp_conv_expander.Sexp_of.core_type typ] in
|
||||||
|
+ let comparator =
|
||||||
|
+ [%e Merlin_helpers.hide_expression
|
||||||
|
+ (Ppx_compare_expander.Compare.core_type typ) ]
|
||||||
|
+ in
|
||||||
|
+ Ppx_assert_lib.Runtime.test_eq
|
||||||
|
+ ~pos ~sexpifier ~comparator ~here ?message ?equal t1 t2
|
||||||
|
]
|
||||||
|
;;
|
||||||
|
|
||||||
|
let expand_test_result ~loc:_ ~path:_ typ =
|
||||||
|
let loc = { typ.ptyp_loc with loc_ghost = true } in
|
||||||
|
[%expr fun ?(here= []) ?message ?equal ~expect got ->
|
||||||
|
- let pos = [%e Ppx_here_expander.lift_position_as_string ~loc] in
|
||||||
|
- let sexpifier = [%e Ppx_sexp_conv_expander.Sexp_of.core_type typ] in
|
||||||
|
- let comparator =
|
||||||
|
- [%e Merlin_helpers.hide_expression
|
||||||
|
- (Ppx_compare_expander.Compare.core_type typ) ]
|
||||||
|
- in
|
||||||
|
- Ppx_assert_lib.Runtime.test_result
|
||||||
|
- ~pos ~sexpifier ~comparator ~here ?message ?equal ~expect ~got
|
||||||
|
+ let pos = [%e Ppx_here_expander.lift_position_as_string ~loc] in
|
||||||
|
+ let sexpifier = [%e Ppx_sexp_conv_expander.Sexp_of.core_type typ] in
|
||||||
|
+ let comparator =
|
||||||
|
+ [%e Merlin_helpers.hide_expression
|
||||||
|
+ (Ppx_compare_expander.Compare.core_type typ) ]
|
||||||
|
+ in
|
||||||
|
+ Ppx_assert_lib.Runtime.test_result
|
||||||
|
+ ~pos ~sexpifier ~comparator ~here ?message ?equal ~expect ~got
|
||||||
|
]
|
||||||
|
;;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user