首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模块用例名称混淆

模块用例名称混淆
EN

Stack Overflow用户
提问于 2014-01-06 05:00:23
回答 2查看 874关注 0票数 1

我犯了更新软件的错误,现在我不能运行任何OUnit测试。

我想我已经成功地将问题归结为一个简单的REPL会话。

$ ocaml -I /opt/local/lib/ OCaml /site/ Ounit ocaml version 4.01.0 #Ounit.assert_equal;错误:错误的文件命名: /opt/local/lib/ocaml/site-lib/ OUnit /ounit.cmi包含OUnit编译后的接口,预期OUnit为# Ounit.assert_equal;;错误:引用未定义的全局“OUnit”

知道我做错什么了吗?

我是在拥有默认case-insensitive/case-preserving文件系统的Mac笔记本电脑上运行这一程序的,但是使用包含路径的情况并不会有帮助。

因此,我更大的问题体现在:

ocamlbuild \ -libs \num,str,unix,oUnit,-cflags \ -g,-w,+a-4,-警告-错误,+a-4,-I,/opt/local/lib/ocaml/site-lib/oUnit,-I,/opt/local/lib/ocaml/site-lib/ocaml\ -lflags \ -g,-I,/opt/lib/ocaml/site-lib/oUnit,-I,/opt/local/lib/ocaml/site-lib/ocamlgraph \./AllTests.本机错误:没有为以下模块提供实现:从/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),引用的OUnitCore/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitLoggerStd引用自/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),的/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitUtils/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitConf引用自/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitAssert引用/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitBracket引用自/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitTest引用/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitRunner引用/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitChooser引用/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) OUnitLogger引用/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2),从/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit)命令引用的/opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2) OUnitTestData与代码2一起退出。编译失败后,在00:00:02构建了646个目标(645缓存)。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-06 05:40:59

您的第一个错误可能是因为您的操作系统没有区分文件名中的大小写,但是OCaml区分了:

代码语言:javascript
复制
$ ocamlobjinfo `ocamlfind query oUnit`/oUnit.cmi
File /mnt/home/jun/.opam/system/lib/oUnit/oUnit.cmi
Unit name: OUnit
Interfaces imported:
    cb146e345f0b34fc8ad4b5afe69d1f20    OUnit
    ...

您可以看到模块名为"Ounit“,而不是"OUnit”。

第二个错误很明显是因为库尚未加载到REPL中。REPL知道函数的存在,但没有加载代码。如果加载库及其所依赖的库,则可以访问该库:

代码语言:javascript
复制
ocaml -I `ocamlfind query oUnit` unix.cma oUnitAdvanced.cma oUnit.cma
        OCaml version 4.01.0

# OUnit.assert_equal;;
- : ?cmp:('a -> 'a -> bool) ->
    ?printer:('a -> string) ->
    ?pp_diff:(Format.formatter -> 'a * 'a -> unit) ->
    ?msg:string -> 'a -> 'a -> unit
= <fun>
票数 4
EN

Stack Overflow用户

发布于 2014-01-07 17:34:24

我通过将ocamlbuild调用更改为使用-use-ocamlfind来解决这个问题,这似乎解决了所有路径混淆的问题。

我还卸载了所有的OCaml模块,然后安装了OPAM,然后通过OPAM安装了OUnit和其他模块,并重新登录,这样我的环境就很原始了。

现在对我起作用的构建命令是

使用-ocamlfind\ -libs图\ -pkgs str,unix,ounit \ -cflags -g,-w,+a-4,-警告-错误,+a-4,-I,/opt/local/ocaml/site-lib/ocamlGraph\ -lflags -g,-I,/opt/local/ocaml/site-lib/ocamlgraph\.

,它由我更新的构建脚本生成。

代码语言:javascript
复制
(* Usage: ocaml make.ml [<ModuleToBuild>.{byte,native}] *)

#load "unix.cma";;

let args = match Array.to_list Sys.argv with
  | []      -> failwith "no program on argv"
  | _::[]   -> ["AllTests.byte"]
  | _::argv -> argv

let library_paths = [
  (* TODO: Figure out why `opam install ocamlgraph` fails *)
  "-I"; "/opt/local/lib/ocaml/site-lib/ocamlgraph";
]

(* If the -p flag is first in the argument list, then replace it
   with a host of flags that enable profiling via ocamlprof. *)
let args, c_opt_flags, l_opt_flags =
  match args with
    | "-p"::rest ->
      (* Treat the targets as debug and profile targets. *)
      "-tags"::"debug,profile"
      (* Use profiling versions of the compilers which instrument
         various flow control constructs with entry counters. *)
      ::"-ocamlc"::"ocamlcp"
      ::"-ocamlopt"::"ocamloptp"
      ::rest,
      (* Instrument all available points. *)
      ["-P"; "a"],
      (* Link with a wrapper that dumps profiling data if program
         exits noramlly. *)
      ["-p"]
    | _ -> args, [], []

let standard_flags = [
  "-use-ocamlfind";
  (* TODO: Figure out why `opam install ocamlgraph` fails *)
  "-libs"; "graph";
  "-pkgs"; "str,unix,ounit";  (* TODO: graph *)
  "-cflags"; (String.concat "," (
    [
      "-g";
      "-w"; "+a-4";
      "-warn-error"; "+a-4";
    ]
    @ c_opt_flags
    @ library_paths));
  "-lflags"; (String.concat "," (
    [
      "-g";
    ]
    @ l_opt_flags
    @ library_paths));
]

let build_command = "ocamlbuild"

let argv = build_command::(standard_flags @ args)

let _ = begin
  Printf.printf "%s\n" (String.concat " \\\n\t" argv);
  flush stdout;
  Unix.execvp build_command (Array.of_list argv);
end;;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20943273

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档