mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
remove qtest makefile and use a script instead
This commit is contained in:
parent
2939dcbf1d
commit
9f48725a06
4 changed files with 72 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -7,6 +7,5 @@ _build
|
|||
TAGS
|
||||
*.docdir
|
||||
setup.*
|
||||
qtest*
|
||||
*.html
|
||||
.merlin
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
|
||||
|
||||
QTEST_PREAMBLE='open CCFun;;'
|
||||
DONTTEST=$(wildcard ../src/**/*.cppo.*) $(wildcard ../src/**/*Labels*)
|
||||
QTESTABLE=$(filter-out $(DONTTEST), \
|
||||
$(wildcard ../src/core/*.ml) \
|
||||
$(wildcard ../src/core/*.mli) \
|
||||
$(wildcard ../src/data/*.ml) \
|
||||
$(wildcard ../src/data/*.mli) \
|
||||
$(wildcard ../src/string/*.ml) \
|
||||
$(wildcard ../src/string/*.mli) \
|
||||
$(wildcard ../src/unix/*.ml) \
|
||||
$(wildcard ../src/unix/*.mli) \
|
||||
$(wildcard ../src/sexp/*.ml) \
|
||||
$(wildcard ../src/sexp/*.mli) \
|
||||
$(wildcard ../src/iter/*.ml) \
|
||||
$(wildcard ../src/iter/*.mli) \
|
||||
$(wildcard ../src/bigarray/*.ml) \
|
||||
$(wildcard ../src/bigarray/*.mli) \
|
||||
$(wildcard ../src/threads/*.ml) \
|
||||
$(wildcard ../src/threads/*.mli) \
|
||||
)
|
||||
|
||||
qtest-gen:
|
||||
@if which qtest > /dev/null ; then \
|
||||
echo "generate qtest"; \
|
||||
qtest extract --preamble $(QTEST_PREAMBLE) \
|
||||
-o run_qtest.ml \
|
||||
$(QTESTABLE) 2> /dev/null ; \
|
||||
else touch qtest/run_qtest.ml ; \
|
||||
fi
|
||||
12
qtest/jbuild
12
qtest/jbuild
|
|
@ -1,15 +1,21 @@
|
|||
|
||||
(executable
|
||||
((name make)
|
||||
(modules (make))
|
||||
))
|
||||
|
||||
(rule
|
||||
((targets (run_qtest.ml))
|
||||
(deps ((file Makefile)))
|
||||
(fallback)
|
||||
(deps (make.bc))
|
||||
;(libraries (qtest qcheck))
|
||||
(action
|
||||
(run make qtest-gen))
|
||||
(run ${exe:make.bc} -target ${@}))
|
||||
))
|
||||
|
||||
(executable
|
||||
((name run_qtest)
|
||||
(modes (native))
|
||||
(modules (run_qtest))
|
||||
(libraries (sequence gen qcheck containers containers.unix
|
||||
containers.data containers.thread containers.iter
|
||||
containers.sexp))
|
||||
|
|
|
|||
63
qtest/make.ml
Normal file
63
qtest/make.ml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
let str_sub ?(offset=0) ~sub:s' s =
|
||||
let open String in
|
||||
let rec aux i =
|
||||
i<length s && (aux_sub i 0 || aux (i+1))
|
||||
and aux_sub i j =
|
||||
if j = length s' then true
|
||||
else if i+j >= length s then false
|
||||
else get s (i+j) = get s' j && aux_sub i (j+1)
|
||||
in
|
||||
aux offset
|
||||
|
||||
let is_suffix ~sub s =
|
||||
str_sub ~offset:(String.length s - String.length sub) ~sub s
|
||||
|
||||
let is_code file = is_suffix ~sub:".ml" file || is_suffix ~sub:".mli" file
|
||||
|
||||
let do_not_test file =
|
||||
assert (not (is_suffix ~sub:"make.ml" file));
|
||||
str_sub ~sub:"Label" file ||
|
||||
is_suffix ~sub:"containers.ml" file ||
|
||||
is_suffix ~sub:"containers_top.ml" file ||
|
||||
is_suffix ~sub:"mkflags.ml" file
|
||||
|
||||
let prefix = "src"
|
||||
let dirs = List.map (fun s-> Filename.concat prefix s)
|
||||
|
||||
let list_files dir : string list =
|
||||
let rec f ~prefix acc file =
|
||||
let file = Filename.concat prefix file in
|
||||
if Sys.is_directory file then (
|
||||
Array.fold_left (f ~prefix:file) acc (Sys.readdir file)
|
||||
) else (
|
||||
if is_code file && not (do_not_test file) then file :: acc else acc
|
||||
)
|
||||
in
|
||||
f ~prefix:"" [] dir
|
||||
|
||||
let run_qtest target =
|
||||
let files =
|
||||
list_files "../src/"
|
||||
|> List.map (Printf.sprintf "'%s'")
|
||||
|> String.concat " "
|
||||
in
|
||||
let cmd =
|
||||
Printf.sprintf "qtest extract --preamble 'open CCFun;;' -o %S %s 2>/dev/null"
|
||||
target files
|
||||
in
|
||||
exit (Sys.command cmd)
|
||||
|
||||
let () =
|
||||
let target = ref "" in
|
||||
Arg.parse ["-target", Arg.Set_string target, " set target"]
|
||||
(fun _ -> ()) "make.ml -target file";
|
||||
if !target="" then failwith "please specify a target";
|
||||
if Sys.command "which qtest > /dev/null" <> 0 then (
|
||||
(* create empty file *)
|
||||
let out = open_out !target in
|
||||
output_string out "";
|
||||
close_out out;
|
||||
) else (
|
||||
run_qtest !target
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue