@@ -566,6 +566,7 @@ let manifest =
566566let test_copy generate =
567567 Lwt_io. with_temp_dir ~prefix: " test-copy-bash-" @@ fun src_dir ->
568568 Lwt_io. (with_file ~mode: output) (src_dir / " file" ) (fun ch -> Lwt_io. write ch " file-data" ) >> = fun () ->
569+ let root = if Sys. unix then " /root" else " C:/Windows" in
569570 (* Files *)
570571 let f1hash = Sha256. (string " file-data" |> to_hex) in
571572 generate ~exclude: [] ~src_dir " file" >> = fun r ->
@@ -581,19 +582,19 @@ let test_copy generate =
581582 generate ~exclude: [] ~src_dir " ../file" >> = fun r ->
582583 Alcotest. (check manifest) " Parent" (Error (`Msg {| Can't use .. in source paths! (in " ../file" )| })) r;
583584 (* Symlinks *)
584- Unix. symlink " / root" (src_dir / " link" );
585+ Unix. symlink ~to_dir: true root (src_dir / " link" );
585586 generate ~exclude: [] ~src_dir " link" >> = fun r ->
586- Alcotest. (check manifest) " Link" (Ok (`Symlink ((" link" , " / root" )))) r;
587+ Alcotest. (check manifest) " Link" (Ok (`Symlink ((" link" , root)))) r;
587588 generate ~exclude: [] ~src_dir " link/file" >> = fun r ->
588589 Alcotest. (check manifest) " Follow link" (Error (`Msg {| Not a regular file : link (in "link/file" )|})) r;
589590 (* Directories *)
590591 generate ~exclude: [" file" ] ~src_dir " " >> = fun r ->
591592 Alcotest. (check manifest) " Tree"
592- (Ok (`Dir (" " , [`Symlink (" link" , " / root" )]))) r;
593+ (Ok (`Dir (" " , [`Symlink (" link" , root)]))) r;
593594 generate ~exclude: [] ~src_dir " ." >> = fun r ->
594595 Alcotest. (check manifest) " Tree"
595596 (Ok (`Dir (" " , [`File (" file" , f1hash);
596- `Symlink (" link" , " / root" )]))) r;
597+ `Symlink (" link" , root)]))) r;
597598 Unix. mkdir (src_dir / " dir1" ) 0o700 ;
598599 Unix. mkdir (src_dir / " dir1" / " dir2" ) 0o700 ;
599600 Lwt_io. (with_file ~mode: output) (src_dir / " dir1" / " dir2" / " file2" ) (fun ch -> Lwt_io. write ch " file2" ) >> = fun () ->
@@ -614,19 +615,22 @@ let test_copy_ocaml _switch () =
614615let test_copy_bash _switch () =
615616 Os. lwt_process_exec := Os. default_exec;
616617 let generate ~exclude ~src_dir src =
618+ Os. pread [" cygpath" ; " -m" ; " /usr/bin/bash" ] >> = fun bash ->
619+ let bash = String. trim bash in
620+ Os. pread [" cygpath" ; " -m" ; src_dir] >> = fun src_dir ->
617621 let manifest_bash =
618622 Printf. sprintf " exec %s %S %S %d %s %d %s"
619623 " ./manifest.bash"
620- src_dir
624+ ( String. trim src_dir)
621625 " /"
622626 (List. length exclude)
623627 (String. concat " " (List. map Filename. quote exclude))
624628 1
625629 (Filename. quote src)
626630 in
627- let argv = [ " /bin/bash " ; " --login" ; " -c" ; manifest_bash ] in
631+ let argv = [ " --login" ; " -c" ; manifest_bash ] in
628632 let pp f = Os. pp_cmd f argv in
629- Os. pread_all ~pp argv >> = fun (n , stdout , stderr ) ->
633+ Os. pread_all ~pp ~cmd: bash argv >> = fun (n , stdout , stderr ) ->
630634 if n = 0 then
631635 Lwt_result. return @@ Manifest. t_of_sexp (Sexplib.Sexp. of_string stdout)
632636 else if n = 1 then
@@ -688,7 +692,7 @@ let test_cache_id () =
688692(* Lwt_io.(with_file ~mode:output) (src_dir / "dir" / "file2") (fun ch -> Lwt_io.write ch "file2-data") >>= fun () -> *)
689693(* Tar_lwt_unix. *)
690694
691- let () =
695+ let main_unix () =
692696 let open Alcotest_lwt in
693697 Lwt_main. run begin
694698 run " OBuilder" [
@@ -720,3 +724,15 @@ let () =
720724 ];
721725 ]
722726 end
727+
728+ let main_win32 () =
729+ let open Alcotest_lwt in
730+ Lwt_main. run begin
731+ run " OBuilder" [
732+ " manifest" , [
733+ test_case " Copy using manifest.bash" `Quick test_copy_bash;
734+ ];
735+ ]
736+ end
737+
738+ let () = if Sys. win32 then main_win32 () else main_unix ()
0 commit comments