From 757ad2bddbb53b02fe2564a3492446b91a081aeb Mon Sep 17 00:00:00 2001 From: art-w Date: Thu, 1 Feb 2024 17:47:40 +0100 Subject: [PATCH] fix CI for various architectures (#10) --- db/type_polarity.mli | 95 +++++----- store/storage_ancient.ml | 9 +- test/cram/base_benchmark.t | 4 + test/cram/base_cli.t | 2 +- test/cram/base_odocls.t | 294 ++++++++++++++--------------- test/cram/base_web.t | 40 ++++ test/cram/cli_poly.t/run.t | 4 +- test/cram/module_type_cost.t/run.t | 4 +- test/cram/multi_package.t | 4 +- test/cram/simple.t/run.t | 18 +- test/cram/size_bound.t | 8 +- test/cram_ancient/dune | 2 +- test/cram_static/base_web.t | 10 +- test/cram_static/dune | 2 - test/dune | 9 +- 15 files changed, 269 insertions(+), 236 deletions(-) create mode 100644 test/cram/base_benchmark.t create mode 100644 test/cram/base_web.t diff --git a/db/type_polarity.mli b/db/type_polarity.mli index 0bbcac31..e3cb1322 100644 --- a/db/type_polarity.mli +++ b/db/type_polarity.mli @@ -1,51 +1,52 @@ (** This module provide a way to transform a type into strings, in such a way - that the strings can be used for type search. - -The chosen representation is polarity : we do not represent the [->] or the [*] -constructors, but instead compute the "polarity" of every type name/constructor -like [int] or ['a] that is part of the whole type expression. - -The polarity of a component of a type indicates if it is produced or consumed by -the type. In the type [int -> string], [int] has negative polarity because it is -being consumed, and [string] has positive polarity because it is being produced. -We say that the polarities of [int -> string] are [-int] and [+string]. - -Once you have computed the polarities of the type of an entry [e], you can -register each polarity as corresponding to [e] in the search database. - -Then, when the user queries for a type, we compute the polarities of the query -type, and search for the entries. - -We then return the result corresponding to intersection of each polarity: if the -user queries for [int -> string], we want to have every entry which consumes an -[int] and produces a [string], that is the intersection of the entries -associated to [-int] with the entries associated to [+string]. - -How is polarity computed exactly ? When you have [t -> u], the polarity of [t] -is inversed, and the polarity of [u] stays the same. A good example of this is -the type of {!Stdlib.Out_channel.with_open_gen} : - -{| val with_open_gen : open_flag list -> int -> string -> (t -> 'a) -> 'a |} - -Here the polarities are [-open_flag list], [-int], [-string], [+Out_channel.t], -[-'a] and [+'a]. The fact that we have [+Out_channel.t] might be puzzling at -first, because an [Out_channel.t] is not returned by the function, but -{!Stdlib.Out_channel.with_open_gen} is indeed one of the possible ways to create -an [Out_channel.t]. - -There is however a complication. If the user queries for [int -> int -> string], -then the polarities will be [-int], [-int] and [+string]. An entry of type [int --> string] would be included in the intersection of these polarities. But the -user explicitely asked for two integers to be consumed. To fix this issue, we -track the number of occurences of each polarity. - -The polarities for [int -> int -> string], become [(-int, 2)] and [(+string, -1)], and allows us to filter entries according to this information. - -There is a mechanism for types with parameters like ['a list]. I might explain -it in the future. -TODO : Give an example even if not the full explanation. -*) + that the strings can be used for type search. + + The chosen representation is polarity : we do not represent the [->] or the [*] + constructors, but instead compute the "polarity" of every type name/constructor + like [int] or ['a] that is part of the whole type expression. + + The polarity of a component of a type indicates if it is produced or consumed by + the type. In the type [int -> string], [int] has negative polarity because it is + being consumed, and [string] has positive polarity because it is being produced. + We say that the polarities of [int -> string] are [-int] and [+string]. + + Once you have computed the polarities of the type of an entry [e], you can + register each polarity as corresponding to [e] in the search database. + + Then, when the user queries for a type, we compute the polarities of the query + type, and search for the entries. + + We then return the result corresponding to intersection of each polarity: if the + user queries for [int -> string], we want to have every entry which consumes an + [int] and produces a [string], that is the intersection of the entries + associated to [-int] with the entries associated to [+string]. + + How is polarity computed exactly ? When you have [t -> u], the polarity of [t] + is inversed, and the polarity of [u] stays the same. A good example of this is + the type of {!Stdlib.Out_channel.with_open_gen} : + + {[ + val with_open_gen : open_flag list -> int -> string -> (t -> 'a) -> 'a + ]} + + Here the polarities are [-open_flag list], [-int], [-string], [+Out_channel.t], + [-'a] and [+'a]. The fact that we have [+Out_channel.t] might be puzzling at + first, because an [Out_channel.t] is not returned by the function, but + {!Stdlib.Out_channel.with_open_gen} is indeed one of the possible ways to create + an [Out_channel.t]. + + There is however a complication. If the user queries for [int -> int -> string], + then the polarities will be [-int], [-int] and [+string]. An entry of type [int +tring] would be included in the intersection of these polarities. But the + user explicitely asked for two integers to be consumed. To fix this issue, we + track the number of occurences of each polarity. + + The polarities for [int -> int -> string], become [(-int, 2)] and [(+string, 1)] + and allows us to filter entries according to this information. + + There is a mechanism for types with parameters like ['a list]. I might explain + it in the future. + TODO : Give an example even if not the full explanation. *) module Sign : sig type t = diff --git a/store/storage_ancient.ml b/store/storage_ancient.ml index dce23b62..beb07b13 100644 --- a/store/storage_ancient.ml +++ b/store/storage_ancient.ml @@ -1,4 +1,7 @@ -let base_addr = 0x100000000000n +let base_addr () = + if Sys.word_size > 32 + then Int64.to_nativeint 0x100000000000L + else failwith "TODO: support ancient on 32 bits" type writer = { mutable write_shard : int @@ -7,7 +10,7 @@ type writer = let open_out filename = let handle = Unix.openfile filename Unix.[ O_RDWR; O_TRUNC; O_CREAT ] 0o640 in - let ancient = Ancient.attach handle base_addr in + let ancient = Ancient.attach handle (base_addr ()) in { write_shard = 0; ancient } let save ~db (t : Db.t) = @@ -34,7 +37,7 @@ let load_shards md = let db_open_in db : reader = let filename = db in let handle = Unix.openfile filename Unix.[ O_RDWR ] 0o640 in - let md = Ancient.attach handle base_addr in + let md = Ancient.attach handle (base_addr ()) in { shards = load_shards md } let load db_filename = diff --git a/test/cram/base_benchmark.t b/test/cram/base_benchmark.t new file mode 100644 index 00000000..960ca5d7 --- /dev/null +++ b/test/cram/base_benchmark.t @@ -0,0 +1,4 @@ +This test will fail, it is not deterministic. Please just check that the values +are not crazy and discard the changes + $ ODOCLS=$(find ../docs/odoc/base/ -name '*.odocl' | sort) + $ sherlodoc index --format=js --db=db.js $ODOCLS > /dev/null diff --git a/test/cram/base_cli.t b/test/cram/base_cli.t index eab14102..4dabb1ce 100644 --- a/test/cram/base_cli.t +++ b/test/cram/base_cli.t @@ -1,4 +1,4 @@ - $ export ODOCLS=$(find ../docs/odoc/base/ -name '*.odocl') + $ ODOCLS=$(find ../docs/odoc/base/ -name '*.odocl') $ export SHERLODOC_DB=db.bin $ export SHERLODOC_FORMAT=marshal $ sherlodoc index --index-docstring=false $ODOCLS > /dev/null diff --git a/test/cram/base_odocls.t b/test/cram/base_odocls.t index ac85358c..62145825 100644 --- a/test/cram/base_odocls.t +++ b/test/cram/base_odocls.t @@ -1,151 +1,143 @@ - $ find ../docs/odoc/base/ -name '*.odocl' | sort - ../docs/odoc/base/base.odocl - ../docs/odoc/base/base__.odocl - ../docs/odoc/base/base__Applicative.odocl - ../docs/odoc/base/base__Applicative_intf.odocl - ../docs/odoc/base/base__Array.odocl - ../docs/odoc/base/base__Array0.odocl - ../docs/odoc/base/base__Array_permute.odocl - ../docs/odoc/base/base__Avltree.odocl - ../docs/odoc/base/base__Backtrace.odocl - ../docs/odoc/base/base__Binary_search.odocl - ../docs/odoc/base/base__Binary_searchable.odocl - ../docs/odoc/base/base__Binary_searchable_intf.odocl - ../docs/odoc/base/base__Blit.odocl - ../docs/odoc/base/base__Blit_intf.odocl - ../docs/odoc/base/base__Bool.odocl - ../docs/odoc/base/base__Bool0.odocl - ../docs/odoc/base/base__Buffer.odocl - ../docs/odoc/base/base__Buffer_intf.odocl - ../docs/odoc/base/base__Bytes.odocl - ../docs/odoc/base/base__Bytes0.odocl - ../docs/odoc/base/base__Bytes_tr.odocl - ../docs/odoc/base/base__Char.odocl - ../docs/odoc/base/base__Char0.odocl - ../docs/odoc/base/base__Comparable.odocl - ../docs/odoc/base/base__Comparable_intf.odocl - ../docs/odoc/base/base__Comparator.odocl - ../docs/odoc/base/base__Comparisons.odocl - ../docs/odoc/base/base__Container.odocl - ../docs/odoc/base/base__Container_intf.odocl - ../docs/odoc/base/base__Either.odocl - ../docs/odoc/base/base__Either0.odocl - ../docs/odoc/base/base__Either_intf.odocl - ../docs/odoc/base/base__Equal.odocl - ../docs/odoc/base/base__Error.odocl - ../docs/odoc/base/base__Exn.odocl - ../docs/odoc/base/base__Field.odocl - ../docs/odoc/base/base__Fieldslib.odocl - ../docs/odoc/base/base__Float.odocl - ../docs/odoc/base/base__Float0.odocl - ../docs/odoc/base/base__Floatable.odocl - ../docs/odoc/base/base__Fn.odocl - ../docs/odoc/base/base__Formatter.odocl - ../docs/odoc/base/base__Globalize.odocl - ../docs/odoc/base/base__Hash.odocl - ../docs/odoc/base/base__Hash_intf.odocl - ../docs/odoc/base/base__Hash_set.odocl - ../docs/odoc/base/base__Hash_set_intf.odocl - ../docs/odoc/base/base__Hashable.odocl - ../docs/odoc/base/base__Hashable_intf.odocl - ../docs/odoc/base/base__Hasher.odocl - ../docs/odoc/base/base__Hashtbl.odocl - ../docs/odoc/base/base__Hashtbl_intf.odocl - ../docs/odoc/base/base__Hex_lexer.odocl - ../docs/odoc/base/base__Identifiable.odocl - ../docs/odoc/base/base__Identifiable_intf.odocl - ../docs/odoc/base/base__Import.odocl - ../docs/odoc/base/base__Import0.odocl - ../docs/odoc/base/base__Indexed_container.odocl - ../docs/odoc/base/base__Indexed_container_intf.odocl - ../docs/odoc/base/base__Info.odocl - ../docs/odoc/base/base__Info_intf.odocl - ../docs/odoc/base/base__Int.odocl - ../docs/odoc/base/base__Int0.odocl - ../docs/odoc/base/base__Int32.odocl - ../docs/odoc/base/base__Int63.odocl - ../docs/odoc/base/base__Int63_emul.odocl - ../docs/odoc/base/base__Int64.odocl - ../docs/odoc/base/base__Int_conversions.odocl - ../docs/odoc/base/base__Int_intf.odocl - ../docs/odoc/base/base__Int_math.odocl - ../docs/odoc/base/base__Intable.odocl - ../docs/odoc/base/base__Invariant.odocl - ../docs/odoc/base/base__Invariant_intf.odocl - ../docs/odoc/base/base__Lazy.odocl - ../docs/odoc/base/base__Linked_queue.odocl - ../docs/odoc/base/base__Linked_queue0.odocl - ../docs/odoc/base/base__List.odocl - ../docs/odoc/base/base__List0.odocl - ../docs/odoc/base/base__List1.odocl - ../docs/odoc/base/base__Map.odocl - ../docs/odoc/base/base__Map_intf.odocl - ../docs/odoc/base/base__Maybe_bound.odocl - ../docs/odoc/base/base__Monad.odocl - ../docs/odoc/base/base__Monad_intf.odocl - ../docs/odoc/base/base__Nativeint.odocl - ../docs/odoc/base/base__Nothing.odocl - ../docs/odoc/base/base__Obj_array.odocl - ../docs/odoc/base/base__Obj_local.odocl - ../docs/odoc/base/base__Option.odocl - ../docs/odoc/base/base__Option_array.odocl - ../docs/odoc/base/base__Or_error.odocl - ../docs/odoc/base/base__Ordered_collection_common.odocl - ../docs/odoc/base/base__Ordered_collection_common0.odocl - ../docs/odoc/base/base__Ordering.odocl - ../docs/odoc/base/base__Poly0.odocl - ../docs/odoc/base/base__Popcount.odocl - ../docs/odoc/base/base__Pow_overflow_bounds.odocl - ../docs/odoc/base/base__Ppx_compare_lib.odocl - ../docs/odoc/base/base__Ppx_enumerate_lib.odocl - ../docs/odoc/base/base__Ppx_hash_lib.odocl - ../docs/odoc/base/base__Pretty_printer.odocl - ../docs/odoc/base/base__Printf.odocl - ../docs/odoc/base/base__Queue.odocl - ../docs/odoc/base/base__Queue_intf.odocl - ../docs/odoc/base/base__Random.odocl - ../docs/odoc/base/base__Random_repr.odocl - ../docs/odoc/base/base__Ref.odocl - ../docs/odoc/base/base__Result.odocl - ../docs/odoc/base/base__Sequence.odocl - ../docs/odoc/base/base__Set.odocl - ../docs/odoc/base/base__Set_intf.odocl - ../docs/odoc/base/base__Sexp.odocl - ../docs/odoc/base/base__Sexp_with_comparable.odocl - ../docs/odoc/base/base__Sexpable.odocl - ../docs/odoc/base/base__Sign.odocl - ../docs/odoc/base/base__Sign0.odocl - ../docs/odoc/base/base__Sign_or_nan.odocl - ../docs/odoc/base/base__Source_code_position.odocl - ../docs/odoc/base/base__Source_code_position0.odocl - ../docs/odoc/base/base__Stack.odocl - ../docs/odoc/base/base__Stack_intf.odocl - ../docs/odoc/base/base__Staged.odocl - ../docs/odoc/base/base__String.odocl - ../docs/odoc/base/base__String0.odocl - ../docs/odoc/base/base__Stringable.odocl - ../docs/odoc/base/base__Sys.odocl - ../docs/odoc/base/base__Sys0.odocl - ../docs/odoc/base/base__T.odocl - ../docs/odoc/base/base__Type_equal.odocl - ../docs/odoc/base/base__Uchar.odocl - ../docs/odoc/base/base__Uchar0.odocl - ../docs/odoc/base/base__Uniform_array.odocl - ../docs/odoc/base/base__Unit.odocl - ../docs/odoc/base/base__Variant.odocl - ../docs/odoc/base/base__Variantslib.odocl - ../docs/odoc/base/base__With_return.odocl - ../docs/odoc/base/base__Word_size.odocl - ../docs/odoc/base/base_internalhash_types/base_internalhash_types.odocl - ../docs/odoc/base/caml/caml.odocl - ../docs/odoc/base/md5/md5_lib.odocl - ../docs/odoc/base/page-index.odocl - ../docs/odoc/base/shadow_stdlib/shadow_stdlib.odocl - - - - - - - - + $ find ../docs/odoc/base/ -name '*.odocl' -exec basename '{}' ';' | sort + base.odocl + base__.odocl + base__Applicative.odocl + base__Applicative_intf.odocl + base__Array.odocl + base__Array0.odocl + base__Array_permute.odocl + base__Avltree.odocl + base__Backtrace.odocl + base__Binary_search.odocl + base__Binary_searchable.odocl + base__Binary_searchable_intf.odocl + base__Blit.odocl + base__Blit_intf.odocl + base__Bool.odocl + base__Bool0.odocl + base__Buffer.odocl + base__Buffer_intf.odocl + base__Bytes.odocl + base__Bytes0.odocl + base__Bytes_tr.odocl + base__Char.odocl + base__Char0.odocl + base__Comparable.odocl + base__Comparable_intf.odocl + base__Comparator.odocl + base__Comparisons.odocl + base__Container.odocl + base__Container_intf.odocl + base__Either.odocl + base__Either0.odocl + base__Either_intf.odocl + base__Equal.odocl + base__Error.odocl + base__Exn.odocl + base__Field.odocl + base__Fieldslib.odocl + base__Float.odocl + base__Float0.odocl + base__Floatable.odocl + base__Fn.odocl + base__Formatter.odocl + base__Globalize.odocl + base__Hash.odocl + base__Hash_intf.odocl + base__Hash_set.odocl + base__Hash_set_intf.odocl + base__Hashable.odocl + base__Hashable_intf.odocl + base__Hasher.odocl + base__Hashtbl.odocl + base__Hashtbl_intf.odocl + base__Hex_lexer.odocl + base__Identifiable.odocl + base__Identifiable_intf.odocl + base__Import.odocl + base__Import0.odocl + base__Indexed_container.odocl + base__Indexed_container_intf.odocl + base__Info.odocl + base__Info_intf.odocl + base__Int.odocl + base__Int0.odocl + base__Int32.odocl + base__Int63.odocl + base__Int63_emul.odocl + base__Int64.odocl + base__Int_conversions.odocl + base__Int_intf.odocl + base__Int_math.odocl + base__Intable.odocl + base__Invariant.odocl + base__Invariant_intf.odocl + base__Lazy.odocl + base__Linked_queue.odocl + base__Linked_queue0.odocl + base__List.odocl + base__List0.odocl + base__List1.odocl + base__Map.odocl + base__Map_intf.odocl + base__Maybe_bound.odocl + base__Monad.odocl + base__Monad_intf.odocl + base__Nativeint.odocl + base__Nothing.odocl + base__Obj_array.odocl + base__Obj_local.odocl + base__Option.odocl + base__Option_array.odocl + base__Or_error.odocl + base__Ordered_collection_common.odocl + base__Ordered_collection_common0.odocl + base__Ordering.odocl + base__Poly0.odocl + base__Popcount.odocl + base__Pow_overflow_bounds.odocl + base__Ppx_compare_lib.odocl + base__Ppx_enumerate_lib.odocl + base__Ppx_hash_lib.odocl + base__Pretty_printer.odocl + base__Printf.odocl + base__Queue.odocl + base__Queue_intf.odocl + base__Random.odocl + base__Random_repr.odocl + base__Ref.odocl + base__Result.odocl + base__Sequence.odocl + base__Set.odocl + base__Set_intf.odocl + base__Sexp.odocl + base__Sexp_with_comparable.odocl + base__Sexpable.odocl + base__Sign.odocl + base__Sign0.odocl + base__Sign_or_nan.odocl + base__Source_code_position.odocl + base__Source_code_position0.odocl + base__Stack.odocl + base__Stack_intf.odocl + base__Staged.odocl + base__String.odocl + base__String0.odocl + base__Stringable.odocl + base__Sys.odocl + base__Sys0.odocl + base__T.odocl + base__Type_equal.odocl + base__Uchar.odocl + base__Uchar0.odocl + base__Uniform_array.odocl + base__Unit.odocl + base__Variant.odocl + base__Variantslib.odocl + base__With_return.odocl + base__Word_size.odocl + base_internalhash_types.odocl + caml.odocl + md5_lib.odocl + page-index.odocl + shadow_stdlib.odocl diff --git a/test/cram/base_web.t b/test/cram/base_web.t new file mode 100644 index 00000000..448ddd4c --- /dev/null +++ b/test/cram/base_web.t @@ -0,0 +1,40 @@ + $ ODOCLS=$(find ../docs/odoc/base/ -name '*.odocl' | sort) + $ cat $ODOCLS > megaodocl +$ du -sh megaodocl +13M megaodocl + $ sherlodoc index --index-docstring=true --index-name=true --type-search=true --format=js --db=db.js $ODOCLS > /dev/null + + $ gzip -k db.js + +We want to compare the compressed size with the size of the odocl. The search +database contains information than the odocl, but the information is organised +in queryable way, so a size increase is expected. It should just be reasonable. + $ gzip -k megaodocl + +Marshal size changes between OCaml versions +$ du -s db.js db.js.gz +2112 db.js +1596 db.js.gz + + $ for f in $(find . -name '*.odocl'); do + > odoc html-generate --search-uri=db.js --search-uri=sherlodoc.js --output-dir html $f + > done + $ odoc support-files -o html + $ cp db.js html/ +The --no-preserve flag is here so that copying to /tmp will not fail because of +a previous run. .js files built by dune are read only. + $ sherlodoc js html/sherlodoc.js +$ du -sh html/sherlodoc.js +104K html/sherlodoc.js + $ ls html + db.js + fonts + highlight.pack.js + katex.min.css + katex.min.js + odoc.css + odoc_search.js + sherlodoc.js +indent to see results +$ cp -r html /tmp +$ firefox /tmp/html/base/index.html diff --git a/test/cram/cli_poly.t/run.t b/test/cram/cli_poly.t/run.t index 4b840d93..266a7711 100644 --- a/test/cram/cli_poly.t/run.t +++ b/test/cram/cli_poly.t/run.t @@ -4,8 +4,8 @@ $ odoc link -I . main.odoc $ odoc link -I . page-page.odoc $ cat $(find . -name '*.odocl') > megaodocl - $ du -sh megaodocl - 4.0K megaodocl +$ du -sh megaodocl +4.0K megaodocl $ export SHERLODOC_DB=db.bin $ export SHERLODOC_FORMAT=marshal $ sherlodoc index $(find . -name '*.odocl') diff --git a/test/cram/module_type_cost.t/run.t b/test/cram/module_type_cost.t/run.t index a9158525..5be645e7 100644 --- a/test/cram/module_type_cost.t/run.t +++ b/test/cram/module_type_cost.t/run.t @@ -2,8 +2,8 @@ $ odoc compile -I . main.cmti $ odoc link -I . main.odoc $ cat $(find . -name '*.odocl') > megaodocl - $ du -sh megaodocl - 4.0K megaodocl +$ du -sh megaodocl +4.0K megaodocl $ export SHERLODOC_DB=db.bin $ export SHERLODOC_FORMAT=marshal $ sherlodoc index $(find . -name '*.odocl') diff --git a/test/cram/multi_package.t b/test/cram/multi_package.t index 1f44eb2c..f93590e7 100644 --- a/test/cram/multi_package.t +++ b/test/cram/multi_package.t @@ -1,5 +1,5 @@ - $ export ODOCLS=$(find ../docs/odoc/ -name '*.odocl' | sort) - $ echo $ODOCLS | wc -w + $ ODOCLS=$(find ../docs/odoc/ -name '*.odocl' | sort) + $ echo "$ODOCLS" | awk 'END { print NR }' 142 $ export SHERLODOC_DB=db.bin $ export SHERLODOC_FORMAT=marshal diff --git a/test/cram/simple.t/run.t b/test/cram/simple.t/run.t index 22c3459a..145698ae 100644 --- a/test/cram/simple.t/run.t +++ b/test/cram/simple.t/run.t @@ -4,26 +4,21 @@ $ odoc link -I . main.odoc $ odoc link -I . page-page.odoc $ cat $(find . -name '*.odocl') > megaodocl - $ du -sh megaodocl - 12K megaodocl - $ sherlodoc index --format=js --db=db.js $(find . -name '*.odocl') 2> /dev/null - -Here cat is used to remove weird permissions on executable built by dune - $ sherlodoc js sherlodoc.js +$ du -sh megaodocl +12K megaodocl $ mkdir html - $ cp sherlodoc.js html - $ cp db.js html + $ sherlodoc index --format=js --db=html/db.js $(find . -name '*.odocl') 2> /dev/null + $ sherlodoc js html/sherlodoc.js $ odoc support-files -o html $ for f in $(find . -name '*.odocl' | sort); do > echo $f ; > cd html ; > odoc html-generate --search-uri db.js --search-uri sherlodoc.js --output-dir . ../$f ; > cd .. - > done + > done | sort ./main.odocl ./page-page.odocl $ ls | sort - db.js html main.cmi main.cmo @@ -35,7 +30,6 @@ Here cat is used to remove weird permissions on executable built by dune page-page.odoc page-page.odocl page.mld - sherlodoc.js $ ls html | sort db.js fonts @@ -58,13 +52,11 @@ Here cat is used to remove weird permissions on executable built by dune ./html/page/Main/module-type-Signature/index.html ./html/page/index.html $ find . -name "*.js" -type f | sort - ./db.js ./html/db.js ./html/highlight.pack.js ./html/katex.min.js ./html/odoc_search.js ./html/sherlodoc.js - ./sherlodoc.js Indent to see results $ cp -r html /tmp diff --git a/test/cram/size_bound.t b/test/cram/size_bound.t index 0b97dbda..2d7b2c53 100644 --- a/test/cram/size_bound.t +++ b/test/cram/size_bound.t @@ -1,11 +1,11 @@ -This tests the sherlodoc.js is not bigger than 120000 bytes. We test a threshold +This tests that sherlodoc.js is not bigger than 120000 bytes. We test a threshold of the size because the precise size depends on specific ocaml and dependencies versions. This test should pass on every version. If it fails, we can either -update the threshold to be a larg enough or forbid certain dependency versions +update the threshold to be large enough or forbid certain dependency versions in the opam file. $ sherlodoc js sherlodoc.js - $ if [ "$(stat --printf="%s" sherlodoc.js)" -gt 120000 ]; then - > stat --printf="%s" sherlodoc.js + $ if [ "$(du sherlodoc.js | cut -f 1)" -gt 120000 ]; then + > du sherlodoc.js > else > echo "All good! "; > fi diff --git a/test/cram_ancient/dune b/test/cram_ancient/dune index 9e980dd5..693a24fd 100644 --- a/test/cram_ancient/dune +++ b/test/cram_ancient/dune @@ -1,3 +1,3 @@ (cram -(enabled_if %{lib-available:ancient} ) + (enabled_if %{lib-available:ancient}) (deps %{bin:odoc} %{bin:sherlodoc})) diff --git a/test/cram_static/base_web.t b/test/cram_static/base_web.t index 198b4dd3..11aa91d4 100644 --- a/test/cram_static/base_web.t +++ b/test/cram_static/base_web.t @@ -1,7 +1,7 @@ $ export ODOCLS=$(find ../docs/odoc/base/ -name '*.odocl') $ cat $ODOCLS > megaodocl - $ du -sh megaodocl - 5.4M megaodocl +$ du -sh megaodocl +5.4M megaodocl $ sherlodoc index --index-docstring=true --index-name=true --type-search=true --format=js --db=db.js $ODOCLS > /dev/null $ gzip -k db.js @@ -10,9 +10,9 @@ We want to compare the compressed size with the size of the odocl. The search database contains information than the odocl, but the information is organised in queryable way, so a size increase is expected. It should just be reasonable. - $ du -s *.js *.gz - 2064 db.js - 1560 db.js.gz +$ du -s *.js *.gz +2108 db.js +1592 db.js.gz $ for f in $(find . -name '*.odocl'); do > odoc html-generate --search-uri=db.js --search-uri=sherlodoc.js --output-dir html $f diff --git a/test/cram_static/dune b/test/cram_static/dune index 0913ad95..54d19fea 100644 --- a/test/cram_static/dune +++ b/test/cram_static/dune @@ -1,8 +1,6 @@ (cram (enabled_if (and - (= %{version:brr} 0.0.6) (= %{version:menhirLib} 20230608) - (= %{version:js_of_ocaml} 5.6.0) (= %{ocaml_version} 4.14.1))) (deps ../docs %{bin:odoc} %{bin:sherlodoc})) diff --git a/test/dune b/test/dune index 5b35e17c..94a91be7 100644 --- a/test/dune +++ b/test/dune @@ -1,7 +1,10 @@ (rule - (target (dir docs)) - (deps (package base)) + (target + (dir docs)) + (deps + (package base)) (action (progn (run mkdir -p docs) - (run odig odoc --no-pkg-deps --cache-dir=docs base)))) + (run odig odoc --cache-dir=docs --no-pkg-deps --quiet base) + (run rm docs/html/base/_doc-dir))))