Skip to content

Commit

Permalink
Fix ppx_version tests
Browse files Browse the repository at this point in the history
  • Loading branch information
psteckler committed Oct 4, 2023
1 parent 113e0cc commit 8a5a60b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
(package (name ppx_to_enum))
(package (name ppx_util))
(package (name ppx_version))
(package (name ppx_version.runtime))
(package (name precomputed_values))
(package (name promise))
(package (name proof_carrying_data))
Expand Down
3 changes: 0 additions & 3 deletions src/lib/ppx_version/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
;; Don't build tests automatically
(vendored_dirs test)

(library
(name ppx_version)
(public_name ppx_version)
Expand Down
7 changes: 3 additions & 4 deletions src/lib/ppx_version/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ endif

.PHONY: positive-tests negative-tests

# all : positive-tests negative-tests
all : negative-tests
all : positive-tests negative-tests

positive-tests :
# version syntax
@ echo -n "Version syntax, should succeed..."
dune build good_version_syntax.cma ${REDIRECT}
echo "OK"
@ dune build good_version_syntax.cma ${REDIRECT}
@ echo "OK"
# versioning
@ echo -n "Versioned types, should succeed..."
@ dune build versioned_good.cma ${REDIRECT}
Expand Down
16 changes: 16 additions & 0 deletions src/lib/ppx_version/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ppx_version tests
=================

These are tests for the basic features of ppx_version.

There are "positive" tests, where the syntax should be accepted, and
"negative" tests, where the syntax should be rejected.

Run `make` to run all tests. There are also separate targets
"positive-tests" and "negative-tests".

The negative tests succeed if the dune build fails, but the failures
may occur for reasons other than the expected reasons. Ordinarily,
the test output is suppressed. By setting the VERBOSE environment
variable, the output is shown, in order to make sure the failures
are as expected.
41 changes: 19 additions & 22 deletions src/lib/ppx_version/test/dune
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
;;; each library below has an identical preprocess clause, because of this
;;; dune bug: https://github.com/ocaml/dune/issues/1946

;;; should succeed

;; version syntax
(library
(name good_version_syntax)
(preprocess (pps ppx_jane ppx_version ppx_deriving_yojson))
(libraries base.caml core_kernel bin_prot.shape)
(libraries base.caml core_kernel bin_prot.shape ppx_version.runtime)
(modules good_version_syntax))

;; versioning
(library
(name versioned_good)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_good))

;; module versioning
(executable
(name versioned_module_good)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_module_good))

(executable
(name versioned_sig_good)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_sig_good))

;;; should fail
Expand All @@ -37,92 +34,92 @@
(library
(name bad_version_syntax_missing_versioned)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules bad_version_syntax_missing_versioned))

(library
(name bad_versioned_in_functor)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules bad_versioned_in_functor))

(library
(name bad_versioned_in_nested_functor)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules bad_versioned_in_nested_functor))

(library
(name bad_version_syntax_multiple_errors)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules bad_version_syntax_multiple_errors))

;; versioning

(library
(name versioned_bad_module_name)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_bad_module_name))

(library
(name versioned_bad_version_name)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_bad_version_name))

(library
(name versioned_bad_type_name)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_bad_type_name))

(library
(name versioned_bad_option)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_bad_option))

(library
(name versioned_bad_contained_types)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_bad_contained_types))

(library
(name versioned_bad_arrow_type)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_bad_arrow_type))

;; module versioning
(library
(name versioned_module_bad_stable_name)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_module_bad_stable_name))

(library
(name versioned_module_bad_version_name)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_module_bad_version_name))

(library
(name versioned_module_bad_missing_type)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_module_bad_missing_type))

(library
(name versioned_module_bad_version_order)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_module_bad_version_order))

(library
(name versioned_module_bad_missing_to_latest)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_version))
(libraries base.caml core_kernel bin_prot.shape sexplib0)
(libraries base.caml core_kernel bin_prot.shape sexplib0 ppx_version.runtime)
(modules versioned_module_bad_missing_to_latest))

0 comments on commit 8a5a60b

Please sign in to comment.