Skip to content

Commit 1920afa

Browse files
committed
Disable all tests on Windows except manifest
1 parent 11d01da commit 1920afa

4 files changed

Lines changed: 28 additions & 10 deletions

File tree

lib/os.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ let pread_result ?stderr ~pp argv =
174174
child >>= fun r ->
175175
Result.map (fun () -> data) r |> Lwt_result.lift
176176

177-
let pread_all ?stdin ~pp argv =
177+
let pread_all ?stdin ~pp ?(cmd="") argv =
178178
with_pipe_from_child @@ fun ~r:r1 ~w:w1 ->
179179
with_pipe_from_child @@ fun ~r:r2 ~w:w2 ->
180180
let child =
181181
Logs.info (fun f -> f "Exec %a" pp_cmd argv);
182182
!lwt_process_exec ?stdin ~stdout:(`FD_move_safely w1) ~stderr:(`FD_move_safely w2) ~pp
183-
("", Array.of_list argv)
183+
(cmd, Array.of_list argv)
184184
in
185185
let r1 = Lwt_io.(of_fd ~mode:input) r1 in
186186
let r2 = Lwt_io.(of_fd ~mode:input) r2 in

obuilder.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ dev-repo: "git+https://github.com/ocurrent/obuilder.git"
4747
pin-depends: [
4848
["tar.1.2" "git+https://github.com/MisterDA/ocaml-tar.git#47d20548d39337009b6d73309eb2aab346494e76"]
4949
["tar-unix.1.2" "git+https://github.com/MisterDA/ocaml-tar.git#47d20548d39337009b6d73309eb2aab346494e76"]
50+
["lwt.5.4.3" "git+https://github.com/MisterDA/lwt.git#dbcd92b754b389dae9537277f8049a04a06aaffa"]
5051
]

obuilder.opam.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pin-depends: [
22
["tar.1.2" "git+https://github.com/MisterDA/ocaml-tar.git#47d20548d39337009b6d73309eb2aab346494e76"]
33
["tar-unix.1.2" "git+https://github.com/MisterDA/ocaml-tar.git#47d20548d39337009b6d73309eb2aab346494e76"]
4+
["lwt.5.4.3" "git+https://github.com/MisterDA/lwt.git#dbcd92b754b389dae9537277f8049a04a06aaffa"]
45
]

test/test.ml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ let manifest =
566566
let 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 () =
614615
let 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

Comments
 (0)