%undefine _package_note_flags

# Break a circular dependency on ocaml-ppx-jane
%bcond_with test

Name:           ocaml-ppx-expect
Version:        0.15.1
Release:        1%{?dist}
Summary:        Framework for writing tests in OCaml

License:        MIT
URL:            https://github.com/janestreet/ppx_expect
Source0:        %{url}/archive/v%{version}/ppx_expect-%{version}.tar.gz

BuildRequires:  ocaml >= 4.08.0
BuildRequires:  ocaml-base-devel >= 0.15
BuildRequires:  ocaml-dune >= 2.0.0
BuildRequires:  ocaml-ppx-here-devel >= 0.15
BuildRequires:  ocaml-ppx-inline-test-devel >= 0.15
BuildRequires:  ocaml-ppxlib-devel >= 0.23.0
BuildRequires:  ocaml-re-devel >= 1.8.0
BuildRequires:  ocaml-stdio-devel >= 0.15

%if %{with test}
BuildRequires:  ocaml-ppx-jane-devel
%endif

%description
Ppx_expect is a framework for writing tests in OCaml, similar to Cram
(https://bitheap.org/cram/).  Ppx_expect mimics the existing inline
tests framework with the `let%%expect_test` construct.  The body of an
expect-test can contain output-generating code, interleaved with
`%%expect` extension expressions to denote the expected output.

When run, these tests will pass iff the output matches what was
expected.  If a test fails, a corrected file with the suffix
".corrected" will be produced with the actual output, and the
`inline_tests_runner` will output a diff.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       ocaml-base-devel%{?_isa}
Requires:       ocaml-ppx-here-devel%{?_isa}
Requires:       ocaml-ppx-inline-test-devel%{?_isa}
Requires:       ocaml-ppxlib-devel%{?_isa}
Requires:       ocaml-re-devel%{?_isa}
Requires:       ocaml-stdio-devel%{?_isa}

%description    devel
The %{name}-devel package contains libraries and signature
files for developing applications that use %{name}.

%prep
%autosetup -n ppx_expect-%{version}

%build
%dune_build

# Relink the stublib with Fedora linker flags
cd _build/default/collector
ocamlmklib -g -ldopt '%{build_ldflags}' -o expect_test_collector_stubs \
  $(ar t libexpect_test_collector_stubs.a)
cd -

%install
%dune_install

%if %{with test}
%check
%dune_check
%endif

%files -f .ofiles
%doc CHANGES.md README.org
%license LICENSE.md

%files devel -f .ofiles-devel

%changelog
* Tue Nov  1 2022 Jerry James <loganjerry@gmail.com> - 0.15.1-1
- Version 0.15.1

* Thu Aug 18 2022 Jerry James <loganjerry@gmail.com> - 0.15.0-7
- Rebuild for ocaml-ppxlib 0.27.0

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed Jul 20 2022 Jerry James <loganjerry@gmail.com> - 0.15.0-5
- Use new OCaml macros

* Sun Jun 19 2022 Richard W.M. Jones <rjones@redhat.com> - 0.15.0-5
- OCaml 4.14.0 rebuild

* Mon Feb 28 2022 Jerry James <loganjerry@gmail.com> - 0.15.0-4
- Version 0.15.0 rerelease

* Fri Feb 04 2022 Richard W.M. Jones <rjones@redhat.com> - 0.15.0-3
- OCaml 4.13.1 rebuild to remove package notes

* Thu Feb  3 2022 Jerry James <loganjerry@gmail.com> - 0.15.0-3
- Conditionally build docs to avoid circular dependency on odoc

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Dec 31 2021 Jerry James <loganjerry@gmail.com> - 0.15.0-1
- Initial RPM