2014-01-06 2 views
1

소프트웨어를 업데이트 한 실수로 OUnit 테스트를 실행할 수 없습니다.모듈 케이스 이름 혼란

간단한 REPL 세션으로 문제를 해결할 수 있다고 생각합니다. 내가 잘못 뭘하는지

$ ocaml -I /opt/local/lib/ocaml/site-lib/oUnit 
     OCaml version 4.01.0 

# Ounit.assert_equal;; 
Error: Wrong file naming: /opt/local/lib/ocaml/site-lib/oUnit/ounit.cmi 
contains the compiled interface for 
Ounit when OUnit was expected 
# OUnit.assert_equal;; 
Error: Reference to undefined global `OUnit' 

어떤 아이디어?

나는 파일 시스템이 기본 case-insensitive/case-preserving 인 Mac 랩톱에서이 파일을 실행하고 있지만 포함 경로의 경우에는 딩크가 도움이되지 않습니다. 당신의 OS가 파일 이름에 경우를 구분하지 않기 때문에

ocamlbuild \ 
    -libs \ 
    nums,str,unix,oUnit,graph \ 
    -cflags \ 
    -g,-w,+a-4,-warn-error,+a-4,-I,/opt/local/lib/ocaml/site-lib/oUnit,-I,/opt/local/lib/ocaml/site-lib/ocamlgraph \ 
    -lflags \ 
    -g,-I,/opt/local/lib/ocaml/site-lib/oUnit,-I,/opt/local/lib/ocaml/site-lib/ocamlgraph \ 
    ./AllTests.native 

Error: No implementations provided for the following modules: 
    OUnitCore referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitLoggerStd referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitUtils referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitConf referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitAssert referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitBracket referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitTest referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitRunner referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitChooser referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitLogger referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2), 
     /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit) 
    OUnitTestData referenced from /opt/local/lib/ocaml/site-lib/oUnit/oUnit.cmxa(OUnit2) 
Command exited with code 2. 
Compilation unsuccessful after building 646 targets (645 cached) in 00:00:02. 

답변

3

첫 번째 오류가 아마도하지만 OCaml의 작업을 수행합니다 :


내 더 큰 문제는 이렇게 명단

$ 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은 함수의 존재를 알고 있지만 코드가로드되어 있지 않습니다.

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> 
+0

감사에 의해 생성되는

ocamlbuild \ -use-ocamlfind \ -libs graph \ -pkgs str,unix,ounit \ -cflags -g,-w,+a-4,-warn-error,+a-4,-I,/opt/local/lib/ocaml/site-lib/ocamlgraph \ -lflags -g,-I,/opt/local/lib/ocaml/site-lib/ocamlgraph \ ./AllTests.native 

입니다. 내 REPL이 문제 전체를 재현하지 않는 것처럼 보입니다. 'ocamlbuild'를 링크 시키려면 어떻게해야할까요? '-libs'리스트에'ounitadvanced'가 필요합니까? –

0

내가 모든 경로 혼란을 주위에 작동하는 것 같다 -use-ocamlfind를 사용하여 내 ocamlbuild 호출을 변경하여 문제를 해결 : 당신이 의존하는 라이브러리와 사람들을로드하는 경우는 액세스 할 수 있습니다.

또한 모든 OCaml 모듈을 제거하고 대신 OPAM을 설치 한 다음 OPAM을 통해 OUnit 및 다른 버전을 설치하고 다시 로그인하여 내 환경을 깨끗하게 유지합니다.

지금 나를 위해 작동 빌드 명령을 내 업데이트 빌드 스크립트

(* 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;;