From 24fab9d480fbe70fc24956520e1fdfb2ac2af911 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Mon, 4 Mar 2019 15:16:45 +0100 Subject: [PATCH 1/4] dune upgrade --- bin/dune | 10 ++++++++++ bin/jbuild | 11 ----------- dune-project | 2 ++ fat-filesystem.opam | 6 +++--- src/dune | 8 ++++++++ src/jbuild | 9 --------- test/dune | 11 +++++++++++ test/jbuild | 10 ---------- 8 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 bin/dune delete mode 100644 bin/jbuild create mode 100644 dune-project create mode 100644 src/dune delete mode 100644 src/jbuild create mode 100644 test/dune delete mode 100644 test/jbuild diff --git a/bin/dune b/bin/dune new file mode 100644 index 0000000..a6887ff --- /dev/null +++ b/bin/dune @@ -0,0 +1,10 @@ +(executables + (names main) + (libraries fat-filesystem mirage-block-unix cmdliner mirage-fs-lwt + io-page-unix)) + +(install + (section bin) + (package fat-filesystem) + (files + (main.exe as fat))) diff --git a/bin/jbuild b/bin/jbuild deleted file mode 100644 index 16c85bb..0000000 --- a/bin/jbuild +++ /dev/null @@ -1,11 +0,0 @@ -(jbuild_version 1) - -(executables - ((names (main)) - (libraries (fat-filesystem mirage-block-unix cmdliner mirage-fs-lwt io-page-unix) -))) - -(install - ((section bin) - (package fat-filesystem) - (files ((main.exe as fat))))) diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..f9f5639 --- /dev/null +++ b/dune-project @@ -0,0 +1,2 @@ +(lang dune 1.0) +(name fat-filesystem) diff --git a/fat-filesystem.opam b/fat-filesystem.opam index d496d16..393e798 100644 --- a/fat-filesystem.opam +++ b/fat-filesystem.opam @@ -7,11 +7,11 @@ dev-repo: "https://github.com/mirage/ocaml-fat.git" doc: "https://mirage.github.io/ocaml-fat/" build: [ - ["jbuilder" "subst" "-p" name "--name" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] ] depends: [ - "jbuilder" {build & >="1.0+beta7"} + "dune" {build & >= "1.0"} "cstruct" {>= "3.0.0"} "ppx_tools" {build} "ppx_cstruct" {build} diff --git a/src/dune b/src/dune new file mode 100644 index 0000000..b32f8ef --- /dev/null +++ b/src/dune @@ -0,0 +1,8 @@ +(library + (name fat_filesystem) + (public_name fat-filesystem) + (libraries cstruct re re.str mirage-fs mirage-block-lwt mirage-fs-lwt lwt + result rresult astring) + (wrapped false) + (preprocess + (pps ppx_cstruct))) diff --git a/src/jbuild b/src/jbuild deleted file mode 100644 index f877570..0000000 --- a/src/jbuild +++ /dev/null @@ -1,9 +0,0 @@ -(jbuild_version 1) - -(library - ((name fat_filesystem) - (public_name fat-filesystem) - (libraries (cstruct re re.str mirage-fs mirage-block-lwt mirage-fs-lwt lwt result rresult astring)) - (wrapped false) - (preprocess (pps (ppx_cstruct))) -)) diff --git a/test/dune b/test/dune new file mode 100644 index 0000000..072a48f --- /dev/null +++ b/test/dune @@ -0,0 +1,11 @@ +(executables + (libraries fat-filesystem lwt lwt.unix cstruct alcotest mirage-fs-lwt + mirage-block-unix io-page.unix mirage-block-lwt) + (names test)) + +(alias + (name runtest) + (deps + (:< test.exe)) + (action + (run %{<}))) diff --git a/test/jbuild b/test/jbuild deleted file mode 100644 index 74c65c5..0000000 --- a/test/jbuild +++ /dev/null @@ -1,10 +0,0 @@ -(jbuild_version 1) - -(executables - ((libraries (fat-filesystem lwt lwt.unix cstruct alcotest mirage-fs-lwt mirage-block-unix io-page.unix mirage-block-lwt)) - (names (test)))) - -(alias - ((name runtest) - (deps (test.exe)) - (action (run ${<})))) From 9bcd518777c2c3ada435bdaf3cd20b74edae7ffd Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Mon, 4 Mar 2019 15:17:40 +0100 Subject: [PATCH 2/4] Use dune in Makefile --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2e121f6..86e5278 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,16 @@ .PHONY: build clean test build: - jbuilder build @install --dev + dune build test: - jbuilder runtest --dev + dune runtest install: - jbuilder install + dune install uninstall: - jbuilder uninstall + dune uninstall clean: rm -rf _build From c2bda63ca1274abd790b22774f5a63a373ba22b2 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Mon, 4 Mar 2019 15:18:58 +0100 Subject: [PATCH 3/4] Use a test stanza --- test/dune | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/test/dune b/test/dune index 072a48f..0da7ff4 100644 --- a/test/dune +++ b/test/dune @@ -1,11 +1,4 @@ -(executables +(test (libraries fat-filesystem lwt lwt.unix cstruct alcotest mirage-fs-lwt mirage-block-unix io-page.unix mirage-block-lwt) - (names test)) - -(alias - (name runtest) - (deps - (:< test.exe)) - (action - (run %{<}))) + (name test)) From 6f992c9a1dcc75531db11e02648c0ba663296d2e Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Mon, 4 Mar 2019 15:22:30 +0100 Subject: [PATCH 4/4] Run test from _build --- test/dune | 3 ++- test/test.ml | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/dune b/test/dune index 0da7ff4..5489e32 100644 --- a/test/dune +++ b/test/dune @@ -1,4 +1,5 @@ (test (libraries fat-filesystem lwt lwt.unix cstruct alcotest mirage-fs-lwt mirage-block-unix io-page.unix mirage-block-lwt) - (name test)) + (name test) + (deps (glob_files *.dat))) diff --git a/test/test.ml b/test/test.ml index ad5c576..aa91564 100644 --- a/test/test.ml +++ b/test/test.ml @@ -62,7 +62,7 @@ let print_int_list xs = "[" ^ ( String.concat "; " (List.map string_of_int xs) ) let test_root_list () = let open Fat_name in let t = - read_whole_file "test/root.dat" >>= fun bytes -> + read_whole_file "root.dat" >>= fun bytes -> let all = list bytes in Alcotest.(check int) __LOC__ 5 (List.length all); let x = List.nth all 1 in @@ -108,16 +108,16 @@ let fat_format = Alcotest.testable (Fmt.of_to_string Fat_format.to_string) (=) let test_chains () = let t = let open Fat_boot_sector in - read_sector "test/bootsector.dat" >>= fun bytes -> + read_sector "bootsector.dat" >>= fun bytes -> let boot = match unmarshal bytes with | Error x -> failwith x | Ok x -> x in Alcotest.(check (result fat_format string)) __LOC__ (Ok Fat_format.FAT16) (Fat_boot_sector.detect_format boot); - read_whole_file "test/root.dat" >>= fun bytes -> + read_whole_file "root.dat" >>= fun bytes -> let open Fat_name in let all = list bytes in - read_whole_file "test/fat.dat" >>= fun fat -> + read_whole_file "fat.dat" >>= fun fat -> let expected = [0; 0; 0; 2235; 3] in let actual = List.map (fun x -> (snd (x.dos)).start_cluster) all in @@ -138,7 +138,7 @@ let test_chains () = let test_parse_boot_sector () = let t = let open Fat_boot_sector in - read_sector "test/bootsector.dat" >>= fun bytes -> + read_sector "bootsector.dat" >>= fun bytes -> let x = match unmarshal bytes with | Error x -> failwith x | Ok x -> x in @@ -371,5 +371,4 @@ let suite = [ ] @ write_tests let () = - Unix.chdir "../../../"; Alcotest.run "fat" ["tests", suite]