The unpac monorepo manager self-hosting as a monorepo using unpac

Track B0_testing.

+40 -77
+40 -77
test/test_fpath.ml
··· 10 let eq = Test.eq (module Fpath) 11 let v = Fpath.v 12 13 - let of_string () = 14 Test.test "Fpath.{v,of_string}" @@ fun () -> 15 - let eq = Test.eq (Test.Eq.result ~ok:(module Fpath) ~error:Test.Eq.true') in 16 let ok s = Ok (v s) in 17 let error = Error (`Msg "any") in 18 eq (Fpath.of_string "/\x00") error ~__POS__; ··· 70 end; 71 () 72 73 - let dir_sep () = 74 Test.test "Fpath.dir_sep" @@ fun () -> 75 Test.string Fpath.dir_sep (if windows then "\\" else "/") ~__POS__; 76 () 77 78 - let is_seg () = 79 Test.test "Fpath.is_seg" @@ fun () -> 80 Test.bool (Fpath.is_seg "abc") true ~__POS__; 81 Test.bool (Fpath.is_seg "ab/c") false ~__POS__; ··· 83 if windows then Test.bool (Fpath.is_seg "ab\\c") false ~__POS__; 84 () 85 86 - let add_seg () = 87 Test.test "Fpath.add_seg" @@ fun () -> 88 Test.invalid_arg ~__POS__ (fun () -> Fpath.add_seg (v "a/b/c") "a\x00o"); 89 Test.invalid_arg ~__POS__ (fun () -> Fpath.add_seg (v "a/b/c") "a/o"); ··· 105 eq (Fpath.add_seg (v "..") "") (v "../") ~__POS__; 106 () 107 108 - let append () = 109 Test.test "Fpath.append" @@ fun () -> 110 eq (Fpath.append (v "/a/b/") (v "e/f")) (v "/a/b/e/f") ~__POS__; 111 eq (Fpath.append (v "/a/b") (v "e/f")) (v "/a/b/e/f") ~__POS__; ··· 126 end; 127 () 128 129 - let split_volume () = 130 Test.test "Fpath.split_volume" @@ fun () -> 131 let eq_split ?__POS__:pos p vol q = 132 Test.block ?__POS__:pos @@ fun () -> ··· 165 end; 166 () 167 168 - let segs () = 169 Test.test "Fpath.segs" @@ fun () -> 170 - let eq = Test.eq (Test.Eq.(list string)) in 171 eq (Fpath.segs @@ v "/a/b/") [""; "a"; "b"; ""] ~__POS__; 172 eq (Fpath.segs @@ v "/a/b") [""; "a"; "b"] ~__POS__; 173 eq (Fpath.segs @@ v "a/b/") ["a"; "b"; ""] ~__POS__; ··· 213 end; 214 () 215 216 - let is_dir_path () = 217 Test.test "Fpath.is_dir_path" @@ fun () -> 218 Test.bool (Fpath.is_dir_path (v ".")) true ~__POS__; 219 Test.bool (Fpath.is_dir_path (v "..")) true ~__POS__; ··· 232 end; 233 () 234 235 - let is_file_path () = 236 Test.test "Fpath.is_file_path" @@ fun () -> 237 Test.bool (Fpath.is_file_path (v ".")) false ~__POS__; 238 Test.bool (Fpath.is_file_path (v "..")) false ~__POS__; ··· 251 end; 252 () 253 254 - let to_dir_path () = 255 Test.test "Fpath.to_dir_path" @@ fun () -> 256 eq (Fpath.to_dir_path @@ v ".") (v "./") ~__POS__; 257 eq (Fpath.to_dir_path @@ v "..") (v "../") ~__POS__; ··· 276 end; 277 () 278 279 - let filename () = 280 Test.test "Fpath.filename" @@ fun () -> 281 Test.string (Fpath.filename @@ v ".") "" ~__POS__; 282 Test.string (Fpath.filename @@ v "./") "" ~__POS__; ··· 312 end; 313 () 314 315 - let split_base () = 316 Test.test "Fpath.split_base" @@ fun () -> 317 let eq_split ?__POS__:pos p (d, b) = 318 Test.block ?__POS__:pos @@ fun () -> ··· 361 end; 362 () 363 364 - let base () = 365 Test.test "Fpath.base" @@ fun () -> 366 eq (Fpath.base @@ v ".") (v ".") ~__POS__; 367 eq (Fpath.base @@ v "./") (v "./") ~__POS__; ··· 404 end; 405 () 406 407 - let basename () = 408 Test.test "Fpath.basename" @@ fun () -> 409 Test.string (Fpath.basename @@ v ".") "" ~__POS__; 410 Test.string (Fpath.basename @@ v "..") "" ~__POS__; ··· 436 end; 437 () 438 439 - let parent () = 440 Test.test "Fpath.parent" @@ fun () -> 441 eq (Fpath.parent @@ v ".") (v "./../") ~__POS__; 442 eq (Fpath.parent @@ v "..") (v "../../") ~__POS__; ··· 478 end; 479 () 480 481 - let rem_empty_seg () = 482 Test.test "Fpath.rem_empty_seg" @@ fun () -> 483 eq (Fpath.rem_empty_seg @@ v ".") (v ".") ~__POS__; 484 eq (Fpath.rem_empty_seg @@ v "..") (v "..") ~__POS__; ··· 513 end; 514 () 515 516 - let normalize () = 517 Test.test "Fpath.normalize" @@ fun () -> 518 eq (Fpath.normalize @@ v ".") (v "./") ~__POS__; 519 eq (Fpath.normalize @@ v "..") (v "../") ~__POS__; ··· 578 end; 579 () 580 581 - let is_prefix () = 582 Test.test "Fpath.is_prefix" @@ fun () -> 583 Test.bool (Fpath.is_prefix (v "/a/b") (v "/a/b")) true ~__POS__; 584 Test.bool (Fpath.is_prefix (v "/a/b") (v "/a/bc")) false ~__POS__; ··· 604 end; 605 () 606 607 - let find_prefix () = 608 Test.test "Fpath.find_prefix" @@ fun () -> 609 - let eq = Test.eq Test.Eq.(option (module Fpath)) in 610 let find_prefix ?__POS__:pos p0 p1 r = 611 Test.block ?__POS__:pos @@ fun () -> 612 eq (Fpath.find_prefix p0 p1) r ~__POS__; ··· 657 end; 658 () 659 660 - let rem_prefix () = 661 Test.test "Fpath.rem_prefix" @@ fun () -> 662 - let eq = Test.eq Test.Eq.(option (module Fpath)) in 663 eq (Fpath.rem_prefix (v "a/b/") (v "a/b")) None ~__POS__; 664 eq (Fpath.rem_prefix (v "a/b/") (v "a/b/")) None ~__POS__; 665 eq (Fpath.rem_prefix (v "a/b") (v "a/b")) None ~__POS__; ··· 684 end; 685 () 686 687 - let relativize () = 688 Test.test "Fpath.relativize" @@ fun () -> 689 - let eq_opt = Test.eq Test.Eq.(option (module Fpath)) in 690 let relativize ?__POS__:pos root p result = 691 Test.block ?__POS__:pos @@ fun () -> 692 match Fpath.relativize ~root p with ··· 767 end; 768 () 769 770 - let is_rooted () = 771 Test.test "Fpath.is_rooted" @@ fun () -> 772 Test.bool (Fpath.is_rooted ~root:(v "a/b") (v "a/b")) false ~__POS__; 773 Test.bool (Fpath.is_rooted ~root:(v "a/b") (v "a/b/")) true ~__POS__; ··· 787 Test.bool (Fpath.is_rooted ~root:(v "/") (v "/..")) true ~__POS__; 788 () 789 790 - let is_abs_rel () = 791 Test.test "Fpath.is_abs_rel" @@ fun () -> 792 let is_abs ?__POS__:pos bool p = 793 Test.block ?__POS__:pos @@ fun () -> ··· 822 end; 823 () 824 825 - let is_root () = 826 Test.test "Fpath.is_root" @@ fun () -> 827 Test.bool (Fpath.is_root (v "/")) true ~__POS__; 828 Test.bool (Fpath.is_root (v "/..")) false ~__POS__; ··· 845 end; 846 () 847 848 - let is_current_dir () = 849 Test.test "Fpath.is_current_dir" @@ fun () -> 850 Test.bool (Fpath.is_current_dir (v ".")) true ~__POS__; 851 Test.bool (Fpath.is_current_dir ~prefix:true (v ".")) true ~__POS__; ··· 871 end; 872 () 873 874 - let is_parent_dir () = 875 Test.test "Fpath.is_parent_dir" @@ fun () -> 876 Test.bool (Fpath.is_parent_dir (v ".")) false ~__POS__; 877 Test.bool (Fpath.is_parent_dir (v "./")) false ~__POS__; ··· 895 end; 896 () 897 898 - let is_dotfile () = 899 Test.test "Fpath.is_dotfile" @@ fun () -> 900 Test.bool (Fpath.is_dotfile (v ".")) false ~__POS__; 901 Test.bool (Fpath.is_dotfile (v "..")) false ~__POS__; ··· 926 end; 927 () 928 929 - let get_ext () = 930 Test.test "Fpath.get_ext" @@ fun () -> 931 let eq_ext ?__POS__:pos ?multi p e = 932 Test.block ?__POS__:pos @@ fun () -> ··· 995 eq_ext ~multi:true "./.a.." ".." ~__POS__; 996 () 997 998 - let has_ext () = 999 Test.test "Fpath.has_ext" @@ fun () -> 1000 let has_ext ?__POS__:pos e p bool = 1001 Test.block ?__POS__:pos @@ fun () -> ··· 1052 has_ext "..a" ".." false ~__POS__; 1053 () 1054 1055 - let exists_ext () = 1056 Test.test "Fpath.exists_ext" @@ fun () -> 1057 let exists_ext ?__POS__:pos ?multi p bool = 1058 Test.block ?__POS__:pos @@ fun () -> ··· 1080 exists_ext "a/." false ~__POS__; 1081 () 1082 1083 - let add_ext () = 1084 Test.test "Fpath.add_ext" @@ fun () -> 1085 Test.invalid_arg (fun () -> Fpath.add_ext "/" (v "a/b/c")); 1086 let eq_add_ext ?__POS__:pos ext p p' = ··· 1106 eq_add_ext ".a" "/" "/" ~__POS__; 1107 () 1108 1109 - let rem_ext () = 1110 Test.test "Fpath.rem_ext" @@ fun () -> 1111 let eq_rem_ext ?__POS__:pos ?multi p p' = 1112 Test.block ?__POS__:pos @@ fun () -> ··· 1137 eq_rem_ext ~multi:true "/.tar" "/.tar" ~__POS__; 1138 () 1139 1140 - let set_ext () = 1141 Test.test "Fpath.set_ext" @@ fun () -> 1142 Test.invalid_arg ~__POS__ (fun () -> (Fpath.set_ext "/") (v "a/b/c")); 1143 let eq_set_ext ?__POS__:pos ?multi ext p p' = ··· 1158 eq_set_ext ~multi:true "" "f.tar.gz" "f" ~__POS__; 1159 () 1160 1161 - let split_ext () = 1162 Test.test "Fpath.split_ext" @@ fun () -> 1163 let eq_split ?__POS__:pos ?multi p q ext = 1164 Test.block ?__POS__:pos @@ fun () -> ··· 1184 eq_split ~multi:true "/.tar.gz/.." "/.tar.gz/.." "" ~__POS__; 1185 () 1186 1187 - let main () = 1188 - Test.main @@ fun () -> 1189 - of_string (); 1190 - dir_sep (); 1191 - is_seg (); 1192 - add_seg (); 1193 - append (); 1194 - split_volume (); 1195 - segs (); 1196 - is_dir_path (); 1197 - is_file_path (); 1198 - to_dir_path (); 1199 - filename (); 1200 - split_base (); 1201 - base (); 1202 - basename (); 1203 - parent (); 1204 - rem_empty_seg (); 1205 - normalize (); 1206 - is_prefix (); 1207 - find_prefix (); 1208 - rem_prefix (); 1209 - relativize (); 1210 - is_rooted (); 1211 - is_abs_rel (); 1212 - is_root (); 1213 - is_current_dir (); 1214 - is_parent_dir (); 1215 - is_dotfile (); 1216 - get_ext (); 1217 - has_ext (); 1218 - exists_ext (); 1219 - add_ext (); 1220 - rem_ext (); 1221 - set_ext (); 1222 - split_ext (); 1223 - () 1224 - 1225 let () = if !Sys.interactive then () else exit (main ())
··· 10 let eq = Test.eq (module Fpath) 11 let v = Fpath.v 12 13 + let of_string = 14 Test.test "Fpath.{v,of_string}" @@ fun () -> 15 + let eq = Test.(eq (T.result' ~ok:(module Fpath) ~error:T.true')) in 16 let ok s = Ok (v s) in 17 let error = Error (`Msg "any") in 18 eq (Fpath.of_string "/\x00") error ~__POS__; ··· 70 end; 71 () 72 73 + let dir_sep = 74 Test.test "Fpath.dir_sep" @@ fun () -> 75 Test.string Fpath.dir_sep (if windows then "\\" else "/") ~__POS__; 76 () 77 78 + let is_seg = 79 Test.test "Fpath.is_seg" @@ fun () -> 80 Test.bool (Fpath.is_seg "abc") true ~__POS__; 81 Test.bool (Fpath.is_seg "ab/c") false ~__POS__; ··· 83 if windows then Test.bool (Fpath.is_seg "ab\\c") false ~__POS__; 84 () 85 86 + let add_seg = 87 Test.test "Fpath.add_seg" @@ fun () -> 88 Test.invalid_arg ~__POS__ (fun () -> Fpath.add_seg (v "a/b/c") "a\x00o"); 89 Test.invalid_arg ~__POS__ (fun () -> Fpath.add_seg (v "a/b/c") "a/o"); ··· 105 eq (Fpath.add_seg (v "..") "") (v "../") ~__POS__; 106 () 107 108 + let append = 109 Test.test "Fpath.append" @@ fun () -> 110 eq (Fpath.append (v "/a/b/") (v "e/f")) (v "/a/b/e/f") ~__POS__; 111 eq (Fpath.append (v "/a/b") (v "e/f")) (v "/a/b/e/f") ~__POS__; ··· 126 end; 127 () 128 129 + let split_volume = 130 Test.test "Fpath.split_volume" @@ fun () -> 131 let eq_split ?__POS__:pos p vol q = 132 Test.block ?__POS__:pos @@ fun () -> ··· 165 end; 166 () 167 168 + let segs = 169 Test.test "Fpath.segs" @@ fun () -> 170 + let eq = Test.(eq T.(list string)) in 171 eq (Fpath.segs @@ v "/a/b/") [""; "a"; "b"; ""] ~__POS__; 172 eq (Fpath.segs @@ v "/a/b") [""; "a"; "b"] ~__POS__; 173 eq (Fpath.segs @@ v "a/b/") ["a"; "b"; ""] ~__POS__; ··· 213 end; 214 () 215 216 + let is_dir_path = 217 Test.test "Fpath.is_dir_path" @@ fun () -> 218 Test.bool (Fpath.is_dir_path (v ".")) true ~__POS__; 219 Test.bool (Fpath.is_dir_path (v "..")) true ~__POS__; ··· 232 end; 233 () 234 235 + let is_file_path = 236 Test.test "Fpath.is_file_path" @@ fun () -> 237 Test.bool (Fpath.is_file_path (v ".")) false ~__POS__; 238 Test.bool (Fpath.is_file_path (v "..")) false ~__POS__; ··· 251 end; 252 () 253 254 + let to_dir_path = 255 Test.test "Fpath.to_dir_path" @@ fun () -> 256 eq (Fpath.to_dir_path @@ v ".") (v "./") ~__POS__; 257 eq (Fpath.to_dir_path @@ v "..") (v "../") ~__POS__; ··· 276 end; 277 () 278 279 + let filename = 280 Test.test "Fpath.filename" @@ fun () -> 281 Test.string (Fpath.filename @@ v ".") "" ~__POS__; 282 Test.string (Fpath.filename @@ v "./") "" ~__POS__; ··· 312 end; 313 () 314 315 + let split_base = 316 Test.test "Fpath.split_base" @@ fun () -> 317 let eq_split ?__POS__:pos p (d, b) = 318 Test.block ?__POS__:pos @@ fun () -> ··· 361 end; 362 () 363 364 + let base = 365 Test.test "Fpath.base" @@ fun () -> 366 eq (Fpath.base @@ v ".") (v ".") ~__POS__; 367 eq (Fpath.base @@ v "./") (v "./") ~__POS__; ··· 404 end; 405 () 406 407 + let basename = 408 Test.test "Fpath.basename" @@ fun () -> 409 Test.string (Fpath.basename @@ v ".") "" ~__POS__; 410 Test.string (Fpath.basename @@ v "..") "" ~__POS__; ··· 436 end; 437 () 438 439 + let parent = 440 Test.test "Fpath.parent" @@ fun () -> 441 eq (Fpath.parent @@ v ".") (v "./../") ~__POS__; 442 eq (Fpath.parent @@ v "..") (v "../../") ~__POS__; ··· 478 end; 479 () 480 481 + let rem_empty_seg = 482 Test.test "Fpath.rem_empty_seg" @@ fun () -> 483 eq (Fpath.rem_empty_seg @@ v ".") (v ".") ~__POS__; 484 eq (Fpath.rem_empty_seg @@ v "..") (v "..") ~__POS__; ··· 513 end; 514 () 515 516 + let normalize = 517 Test.test "Fpath.normalize" @@ fun () -> 518 eq (Fpath.normalize @@ v ".") (v "./") ~__POS__; 519 eq (Fpath.normalize @@ v "..") (v "../") ~__POS__; ··· 578 end; 579 () 580 581 + let is_prefix = 582 Test.test "Fpath.is_prefix" @@ fun () -> 583 Test.bool (Fpath.is_prefix (v "/a/b") (v "/a/b")) true ~__POS__; 584 Test.bool (Fpath.is_prefix (v "/a/b") (v "/a/bc")) false ~__POS__; ··· 604 end; 605 () 606 607 + let find_prefix = 608 Test.test "Fpath.find_prefix" @@ fun () -> 609 + let eq = Test.(eq T.(option (module Fpath))) in 610 let find_prefix ?__POS__:pos p0 p1 r = 611 Test.block ?__POS__:pos @@ fun () -> 612 eq (Fpath.find_prefix p0 p1) r ~__POS__; ··· 657 end; 658 () 659 660 + let rem_prefix = 661 Test.test "Fpath.rem_prefix" @@ fun () -> 662 + let eq = Test.(eq T.(option (module Fpath))) in 663 eq (Fpath.rem_prefix (v "a/b/") (v "a/b")) None ~__POS__; 664 eq (Fpath.rem_prefix (v "a/b/") (v "a/b/")) None ~__POS__; 665 eq (Fpath.rem_prefix (v "a/b") (v "a/b")) None ~__POS__; ··· 684 end; 685 () 686 687 + let relativize = 688 Test.test "Fpath.relativize" @@ fun () -> 689 + let eq_opt = Test.(eq (T.option (module Fpath))) in 690 let relativize ?__POS__:pos root p result = 691 Test.block ?__POS__:pos @@ fun () -> 692 match Fpath.relativize ~root p with ··· 767 end; 768 () 769 770 + let is_rooted = 771 Test.test "Fpath.is_rooted" @@ fun () -> 772 Test.bool (Fpath.is_rooted ~root:(v "a/b") (v "a/b")) false ~__POS__; 773 Test.bool (Fpath.is_rooted ~root:(v "a/b") (v "a/b/")) true ~__POS__; ··· 787 Test.bool (Fpath.is_rooted ~root:(v "/") (v "/..")) true ~__POS__; 788 () 789 790 + let is_abs_rel = 791 Test.test "Fpath.is_abs_rel" @@ fun () -> 792 let is_abs ?__POS__:pos bool p = 793 Test.block ?__POS__:pos @@ fun () -> ··· 822 end; 823 () 824 825 + let is_root = 826 Test.test "Fpath.is_root" @@ fun () -> 827 Test.bool (Fpath.is_root (v "/")) true ~__POS__; 828 Test.bool (Fpath.is_root (v "/..")) false ~__POS__; ··· 845 end; 846 () 847 848 + let is_current_dir = 849 Test.test "Fpath.is_current_dir" @@ fun () -> 850 Test.bool (Fpath.is_current_dir (v ".")) true ~__POS__; 851 Test.bool (Fpath.is_current_dir ~prefix:true (v ".")) true ~__POS__; ··· 871 end; 872 () 873 874 + let is_parent_dir = 875 Test.test "Fpath.is_parent_dir" @@ fun () -> 876 Test.bool (Fpath.is_parent_dir (v ".")) false ~__POS__; 877 Test.bool (Fpath.is_parent_dir (v "./")) false ~__POS__; ··· 895 end; 896 () 897 898 + let is_dotfile = 899 Test.test "Fpath.is_dotfile" @@ fun () -> 900 Test.bool (Fpath.is_dotfile (v ".")) false ~__POS__; 901 Test.bool (Fpath.is_dotfile (v "..")) false ~__POS__; ··· 926 end; 927 () 928 929 + let get_ext = 930 Test.test "Fpath.get_ext" @@ fun () -> 931 let eq_ext ?__POS__:pos ?multi p e = 932 Test.block ?__POS__:pos @@ fun () -> ··· 995 eq_ext ~multi:true "./.a.." ".." ~__POS__; 996 () 997 998 + let has_ext = 999 Test.test "Fpath.has_ext" @@ fun () -> 1000 let has_ext ?__POS__:pos e p bool = 1001 Test.block ?__POS__:pos @@ fun () -> ··· 1052 has_ext "..a" ".." false ~__POS__; 1053 () 1054 1055 + let exists_ext = 1056 Test.test "Fpath.exists_ext" @@ fun () -> 1057 let exists_ext ?__POS__:pos ?multi p bool = 1058 Test.block ?__POS__:pos @@ fun () -> ··· 1080 exists_ext "a/." false ~__POS__; 1081 () 1082 1083 + let add_ext = 1084 Test.test "Fpath.add_ext" @@ fun () -> 1085 Test.invalid_arg (fun () -> Fpath.add_ext "/" (v "a/b/c")); 1086 let eq_add_ext ?__POS__:pos ext p p' = ··· 1106 eq_add_ext ".a" "/" "/" ~__POS__; 1107 () 1108 1109 + let rem_ext = 1110 Test.test "Fpath.rem_ext" @@ fun () -> 1111 let eq_rem_ext ?__POS__:pos ?multi p p' = 1112 Test.block ?__POS__:pos @@ fun () -> ··· 1137 eq_rem_ext ~multi:true "/.tar" "/.tar" ~__POS__; 1138 () 1139 1140 + let set_ext = 1141 Test.test "Fpath.set_ext" @@ fun () -> 1142 Test.invalid_arg ~__POS__ (fun () -> (Fpath.set_ext "/") (v "a/b/c")); 1143 let eq_set_ext ?__POS__:pos ?multi ext p p' = ··· 1158 eq_set_ext ~multi:true "" "f.tar.gz" "f" ~__POS__; 1159 () 1160 1161 + let split_ext = 1162 Test.test "Fpath.split_ext" @@ fun () -> 1163 let eq_split ?__POS__:pos ?multi p q ext = 1164 Test.block ?__POS__:pos @@ fun () -> ··· 1184 eq_split ~multi:true "/.tar.gz/.." "/.tar.gz/.." "" ~__POS__; 1185 () 1186 1187 + let main () = Test.main @@ fun () -> Test.autorun () 1188 let () = if !Sys.interactive then () else exit (main ())