pax_global_header00006660000000000000000000000064131642561310014514gustar00rootroot0000000000000052 comment=b7c3ec917c6eeb0825e52772732b0e1f4f6e69fe ocamlmod-0.0.9/000077500000000000000000000000001316425613100133155ustar00rootroot00000000000000ocamlmod-0.0.9/.gitignore000066400000000000000000000001261316425613100153040ustar00rootroot00000000000000/_build/ /setup.data /setup.log /dist/ /test.byte /ocamlmod.byte /src/ocamlmodConf.ml ocamlmod-0.0.9/AUTHORS.txt000066400000000000000000000002041316425613100151770ustar00rootroot00000000000000(* OASIS_START *) (* DO NOT EDIT (digest: c13049d3d35083abd390f10254143726) *) Authors of ocamlmod Sylvain Le Gall (* OASIS_STOP *) ocamlmod-0.0.9/CHANGES.txt000066400000000000000000000012571316425613100151330ustar00rootroot000000000000002017-10-01 Sylvain Le Gall * Version 0.0.9 * Update setup.ml to use latest OASIS 0.4.10, compatible with safe-string (Closes: #1759) 2015-09-02 Sylvain Le Gall * Version 0.0.8 * Include file test/data/test01.mod (Close: #1238) 2013-12-13 Sylvain Le Gall * Version 0.0.7 * Implement a -version command line options. 2013-11-22 Sylvain Le Gall * Version 0.0.6 * Reupload because of mismatch in GODI 2013-11-11 Sylvain Le Gall * Version 0.0.5 * Remove end of line blank in generated files when using odn. ocamlmod-0.0.9/INSTALL.txt000066400000000000000000000015621316425613100151700ustar00rootroot00000000000000(* OASIS_START *) (* DO NOT EDIT (digest: cd2633d1935ac8a0c14492c48d9e0ff9) *) This is the INSTALL file for the ocamlmod distribution. This package uses OASIS to generate its build system. See section OASIS for full information. Dependencies ============ In order to compile this package, you will need: * ocaml * findlib * oUnit (>= 1.1.1) for executable test Installing ========== 1. Uncompress the source archive and go to the root of the package 2. Run 'ocaml setup.ml -configure' 3. Run 'ocaml setup.ml -build' 4. Run 'ocaml setup.ml -install' Uninstalling ============ 1. Go to the root of the package 2. Run 'ocaml setup.ml -uninstall' OASIS ===== OASIS is a program that generates a setup.ml file using a simple '_oasis' configuration file. The generated setup only depends on the standard OCaml installation: no additional library is required. (* OASIS_STOP *) ocamlmod-0.0.9/Makefile000066400000000000000000000076211316425613100147630ustar00rootroot00000000000000################################################################################ # ocamlmod: Generate OCaml modules from source files # # # # Copyright (C) 2011, OCamlCore SARL # # Copyright (C) 2013, Sylvain Le Gall # # # # This library is free software; you can redistribute it and/or modify it # # under the terms of the GNU Lesser General Public License as published by # # the Free Software Foundation; either version 2.1 of the License, or (at # # your option) any later version, with the OCaml static compilation # # exception. # # # # This library is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # # or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with this library; if not, write to the Free Software Foundation, # # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################################################################################ default: test # OASIS_START # DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954) SETUP = ocaml setup.ml build: setup.data $(SETUP) -build $(BUILDFLAGS) doc: setup.data build $(SETUP) -doc $(DOCFLAGS) test: setup.data build $(SETUP) -test $(TESTFLAGS) all: $(SETUP) -all $(ALLFLAGS) install: setup.data $(SETUP) -install $(INSTALLFLAGS) uninstall: setup.data $(SETUP) -uninstall $(UNINSTALLFLAGS) reinstall: setup.data $(SETUP) -reinstall $(REINSTALLFLAGS) clean: $(SETUP) -clean $(CLEANFLAGS) distclean: $(SETUP) -distclean $(DISTCLEANFLAGS) setup.data: $(SETUP) -configure $(CONFIGUREFLAGS) configure: $(SETUP) -configure $(CONFIGUREFLAGS) .PHONY: build doc test all install uninstall reinstall clean distclean configure # OASIS_STOP # Precommit target # Check style of code. PRECOMMIT_ARGS= \ --exclude myocamlbuild.ml \ --exclude setup.ml \ --exclude README.txt \ --exclude INSTALL.txt \ --exclude Makefile \ --exclude configure \ --exclude _tags precommit: -@if command -v OCamlPrecommit > /dev/null; then \ OCamlPrecommit $(PRECOMMIT_ARGS); \ else \ echo "Skipping precommit checks.";\ fi precommit-full: OCamlPrecommit --full $(PRECOMMIT_ARGS) test: precommit .PHONY: precommit # Fix perms target # Fix missing permission for darcs VCS files. fix-perms: # TODO: chmod +x doc-dist.sh .PHONY: fix-perms # Headache target # Fix license header of file. headache: find ./ \ -name _darcs -prune -false \ -o -name .git -prune -false \ -o -name .svn -prune -false \ -o -name _build -prune -false \ -o -name dist -prune -false \ -o -name '*[^~]' -type f \ | xargs /usr/bin/headache -h _header -c _headache.config .PHONY: headache # Deploy target # Deploy/release the software. deploy: headache fix-perms # TODO: create a plugin to create documentation. # oasis doc-dist admin-gallu-deploy --verbose \ --forge_upload --forge_group ocamlmod --forge_user gildor-admin # TODO: when oasis doc-dist will work, re-add. # --forge_extra_file "dist/ocamlmod-doc-$(shell oasis query version).tar.gz" # TODO: create a plugin to send announcement. # oasis announce admin-gallu-oasis-increment \ --setup_run --setup_args "-setup-update dynamic" --use_vcs .PHONY: deploy ocamlmod-0.0.9/README.txt000066400000000000000000000004131316425613100150110ustar00rootroot00000000000000(* OASIS_START *) (* DO NOT EDIT (digest: 517254fd407fd9b404639e19e8c9f2b4) *) This is the README file for the ocamlmod distribution. Generate OCaml modules from source files See the files INSTALL.txt for building and installation instructions. (* OASIS_STOP *) ocamlmod-0.0.9/_headache.config000066400000000000000000000063501316425613100163710ustar00rootroot00000000000000################################################################################ # ocamlmod: Generate OCaml modules from source files # # # # Copyright (C) 2011, OCamlCore SARL # # Copyright (C) 2013, Sylvain Le Gall # # # # This library is free software; you can redistribute it and/or modify it # # under the terms of the GNU Lesser General Public License as published by # # the Free Software Foundation; either version 2.1 of the License, or (at # # your option) any later version, with the OCaml static compilation # # exception. # # # # This library is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # # or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more # # details. # # # # You should have received a copy of the GNU Lesser General Public License # # along with this library; if not, write to the Free Software Foundation, # # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################################################################################ | "setup.ml" -> no | "myocamlbuild.ml" -> no | ".*\.txt" -> no | ".*\.txt-exp" -> no | ".*\.html" -> no | ".*\.patch" -> no | ".*\.mkd" -> no | ".*\.mod" -> no | ".*\.mlify" -> no | "configure" -> no | ".*\.sh" -> skip match:"#!.*" | ".*\.sh" -> frame open:"#" line:"#" close:"#" | ".*\.ml\.ab" -> frame open:"(*" line:"*" close:"*)" margin:" " | ".*\.mli?" -> skip match:"(\*pp .* \*)" | ".*\.mli?" -> frame open:"(*" line:"*" close:"*)" margin:" " | "_headache\.config" -> frame open:"#" line:"#" close:"#" | "META" -> frame open:"#" line:"#" close:"#" | ".*\.js" -> frame open:"/*" line:"*" close:"*/" margin:" " | ".*\.css" -> frame open:"/*" line:"*" close:"*/" margin:" " | "_oasis" -> no | "_header" -> no | ".*\.swp" -> no | ".*\.po" -> no | ".*\.po.bak" -> no | ".*\.mo" -> no | "POTFILES" -> no | "LINGUAS" -> no | ".*\.pot" -> no | ".*\.png" -> no | ".*\.mllib" -> no | ".*\.itarget" -> no | ".*\.itarget.in" -> no | ".*\.odocl" -> no | "_tags" -> no | "\.boring" -> no | "\.gitignore" -> no | ".*\.pdf" -> no | "setup\.log" -> no | "setup\.data" -> no | ".*\.data" -> no | ".*\.tar\.gz" -> no | ".*\.tar\.gz\.asc" -> no | ".*\.lua" -> no ocamlmod-0.0.9/_header000066400000000000000000000015161316425613100146320ustar00rootroot00000000000000ocamlmod: Generate OCaml modules from source files Copyright (C) 2011, OCamlCore SARL Copyright (C) 2013, Sylvain Le Gall This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version, with the OCaml static compilation exception. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ocamlmod-0.0.9/_oasis000066400000000000000000000010731316425613100145160ustar00rootroot00000000000000OASISFormat: 0.3 Name: ocamlmod Version: 0.0.9 Synopsis: Generate OCaml modules from source files Authors: Sylvain Le Gall License: LGPL-2.1 with OCaml linking exception Plugins: DevFiles (0.2), META (0.2), StdFiles (0.2) FilesAB: src/ocamlmodConf.ml.ab BuildTools: ocamlbuild Executable ocamlmod Path: src MainIs: ocamlmod.ml BuildDepends: str Executable test Path: test MainIs: test.ml BuildDepends: oUnit (>= 2.0.0), str Install: false Build$: flag(tests) Test main Command: $test ocamlmod-0.0.9/ardivink.lua000066400000000000000000000007551316425613100156360ustar00rootroot00000000000000oasis = require("oasis") ci = require("ci") dist = require("dist") ci.init() oasis.init() dist.init() ci.prependenv("PATH", "/usr/opt/godi/bin") ci.prependenv("PATH", "/usr/opt/godi/sbin") ci.putenv("OUNIT_OUTPUT_HTML_DIR", dist.make_filename("ounit-log-$(suite_name).html")) ci.putenv("OUNIT_OUTPUT_JUNIT_FILE", dist.make_filename("junit-$(suite_name).xml")) ci.putenv("OUNIT_OUTPUT_FILE", dist.make_filename("ounit-log-$(suite_name)-$(shard_id).txt")) oasis.std_process("--enable-tests") ocamlmod-0.0.9/configure000077500000000000000000000005531316425613100152270ustar00rootroot00000000000000#!/bin/sh # OASIS_START # DO NOT EDIT (digest: dc86c2ad450f91ca10c931b6045d0499) set -e FST=true for i in "$@"; do if $FST; then set -- FST=false fi case $i in --*=*) ARG=${i%%=*} VAL=${i##*=} set -- "$@" "$ARG" "$VAL" ;; *) set -- "$@" "$i" ;; esac done ocaml setup.ml -configure "$@" # OASIS_STOP ocamlmod-0.0.9/setup.ml000066400000000000000000000071711316425613100150150ustar00rootroot00000000000000(********************************************************************************) (* ocamlmod: generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (********************************************************************************) (* setup.ml generated for the first time by OASIS v0.2.0 *) (* OASIS_START *) (* DO NOT EDIT (digest: 9852805d5c19ca1cb6abefde2dcea323) *) (******************************************************************************) (* OASIS: architecture for building OCaml libraries and applications *) (* *) (* Copyright (C) 2011-2013, Sylvain Le Gall *) (* Copyright (C) 2008-2011, OCamlCore SARL *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) let () = try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") with Not_found -> () ;; #use "topfind";; #require "oasis.dynrun";; open OASISDynRun;; (* OASIS_STOP *) let () = setup ();; ocamlmod-0.0.9/src/000077500000000000000000000000001316425613100141045ustar00rootroot00000000000000ocamlmod-0.0.9/src/ocamlbuild-rules.ml000066400000000000000000000041471316425613100177070ustar00rootroot00000000000000(******************************************************************************) (* ocamlmod: Generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* Copyright (C) 2013, Sylvain Le Gall *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) let ocamlmod_str = "ocamlmod";; let ocamlmod = A ocamlmod_str;; rule "ocamlmod: %.mod -> %.ml" ~prod:"%.ml" ~deps:["%.mod"; ocamlmod_str] begin fun env build -> let modfn = env "%.mod" in let dirname = Pathname.dirname modfn in depends_from_file env build ~fmod:(fun fn -> dirname/fn) modfn; Cmd(S[ocamlmod; P(modfn)]) end ;; ocamlmod-0.0.9/src/ocamlmod.ml000066400000000000000000000133671316425613100162430ustar00rootroot00000000000000(******************************************************************************) (* ocamlmod: Generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* Copyright (C) 2013, Sylvain Le Gall *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) (** Tool to transform a source module into an OCaml module @author Sylvain Le Gall *) let dump_ml chn_out fn = (* filename that should be used to point to source file *) let real_fn = let pwd = Sys.getcwd () in let pwd = (* Translate file from build directory to source * directory *) if Filename.basename pwd = "_build" then Filename.dirname pwd else pwd in Filename.concat pwd fn in let () = (* Warn if not a .ml file *) if not (Filename.check_suffix fn ".ml") then prerr_endline ("'"^fn^"' doesn't end with .ml") in let modname = String.capitalize (Filename.basename (Filename.chop_suffix fn ".ml")) in let export_extract chn_out fn = let is_rgxp s_rgxp = let rgxp = Str.regexp s_rgxp in fun s -> Str.string_match rgxp s 0 in let with_odn = Str.regexp " +with +odn\\($\\| \\)" in let type_conv_path = Str.regexp "TYPE_CONV_PATH +\"[^\"]*\"" in let is_export_end = is_rgxp "(\\* +END +EXPORT +\\*)" in let is_export_start = is_rgxp "(\\* +START +EXPORT +\\*)" in let is_beg_comment = is_rgxp "(\\*.*" in let line_num = ref 0 in let chn_in = open_in fn in let input_line () = incr line_num; input_line chn_in in let rec skip_header line = if is_export_start line then start_export (input_line ()) else if is_beg_comment line then skip_header (input_line ()) else start_export line and skip_export line = if is_export_start line then start_export (input_line ()) else skip_export (input_line ()) and start_export line = Printf.fprintf chn_out "# %d %S\n" !line_num fn; parse_body line and parse_body line = if is_export_end line then skip_export (input_line ()) else begin let line = (* Remove ODN elements *) List.fold_left (fun str rgxp -> Str.global_replace rgxp "" str) line [with_odn; type_conv_path] in if line = "" then Printf.fprintf chn_out "\n" else Printf.fprintf chn_out " %s\n" line; parse_body (input_line ()) end in begin try skip_header (input_line ()); with End_of_file -> () end; close_in chn_in in Printf.fprintf chn_out "module %s = struct\n" modname; export_extract chn_out fn; Printf.fprintf chn_out "end\n\n" let process chn_in curdir chn_out = try while true do let fn = input_line chn_in in let real_fn = if Filename.is_relative fn then Filename.concat curdir fn else fn in if not (Sys.file_exists real_fn) then failwith ("Cannot find file '"^real_fn^"'"); dump_ml chn_out real_fn done with End_of_file -> () let process_modfile ?out_fn fn = let out_fn = match out_fn with | None -> (Filename.chop_extension fn)^".ml" | Some fn -> fn in let chn_out = open_out out_fn in let chn_in = open_in fn in process chn_in (Filename.dirname fn) chn_out; close_in chn_in; close_out chn_out let () = let lst = ref [] in let output = ref None in Arg.parse ["-o", Arg.String (fun str -> output := Some str), "fn Output file."; "-version", Arg.Unit (fun () -> print_endline OcamlmodConf.version; exit 0), " Print version and exit."; ] (fun fn -> lst := fn :: !lst) "OCaml module generator written by Sylvain Le Gall"; match !output, !lst with | _, [] -> failwith "Need at least one .mod file." | Some out_fn, [in_fn] -> process_modfile ~out_fn in_fn | Some _, lst -> failwith "Cannot use -o with multiple .mod files." | None, lst -> List.iter process_modfile (List.rev lst) ocamlmod-0.0.9/src/ocamlmodConf.ml.ab000066400000000000000000000033051316425613100174210ustar00rootroot00000000000000(******************************************************************************) (* ocamlmod: Generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* Copyright (C) 2013, Sylvain Le Gall *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) let version = "$(pkg_version)" ocamlmod-0.0.9/test/000077500000000000000000000000001316425613100142745ustar00rootroot00000000000000ocamlmod-0.0.9/test/data/000077500000000000000000000000001316425613100152055ustar00rootroot00000000000000ocamlmod-0.0.9/test/data/A.ml000066400000000000000000000034571316425613100157300ustar00rootroot00000000000000(******************************************************************************) (* ocamlmod: Generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* Copyright (C) 2013, Sylvain Le Gall *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) type t = { arecord: int } with odn (* END EXPORT *) (* SHOULD NOT BE THERE *) (* START EXPORT *) (* SHOULD BE THERE *) ocamlmod-0.0.9/test/data/B.ml000066400000000000000000000032711316425613100157230ustar00rootroot00000000000000(******************************************************************************) (* ocamlmod: Generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* Copyright (C) 2013, Sylvain Le Gall *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) (* Another file *) ocamlmod-0.0.9/test/data/test01.mod000066400000000000000000000000121316425613100170170ustar00rootroot00000000000000A.ml B.ml ocamlmod-0.0.9/test/test.ml000066400000000000000000000064461316425613100156170ustar00rootroot00000000000000(******************************************************************************) (* ocamlmod: Generate OCaml modules from source files *) (* *) (* Copyright (C) 2011, OCamlCore SARL *) (* Copyright (C) 2013, Sylvain Le Gall *) (* *) (* This library is free software; you can redistribute it and/or modify it *) (* under the terms of the GNU Lesser General Public License as published by *) (* the Free Software Foundation; either version 2.1 of the License, or (at *) (* your option) any later version, with the OCaml static compilation *) (* exception. *) (* *) (* This library is distributed in the hope that it will be useful, but *) (* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) (* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) (* details. *) (* *) (* You should have received a copy of the GNU Lesser General Public License *) (* along with this library; if not, write to the Free Software Foundation, *) (* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) (******************************************************************************) open OUnit2 let ocamlmod = Conf.make_exec "ocamlmod" let () = run_test_tt_main ("ocamlmod">:: (fun test_ctxt -> let fn, chn = bracket_tmpfile test_ctxt in let () = close_out chn in let () = assert_command ~ctxt:test_ctxt (ocamlmod test_ctxt) [(in_testdata_dir test_ctxt ["test01.mod"]); "-o"; fn] in let lst = let lst = ref [] in let chn = open_in fn in let () = try while true do lst := (input_line chn) :: !lst done with End_of_file -> close_in chn in List.rev !lst in let find_reg reg = let reg = Str.regexp reg in List.exists (fun str -> if Str.string_match reg str 0 then begin logf test_ctxt `Info "%S" str; true end else begin false end) lst in List.iter (fun line -> logf test_ctxt `Info "%S" line) lst; ignore "(*"; assert_bool "Contains SHOULD BE THERE" (find_reg " *(\\* SHOULD BE THERE \\*)"); ignore "(*"; assert_bool "Doesn't contain SHOULD NOT BE THERE" (not (find_reg " *(\\* SHOULD NOT BE THERE \\*)")); assert_bool "Doesn't contain with odn" (not (find_reg ".*with *odn")); assert_bool "No blank at end of line." (not (find_reg ".* *$")); ()))