Skip to content

Commit 097e915

Browse files
committed
add ppx_inline_test
1 parent 4628c88 commit 097e915

18 files changed

+163
-78
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ _build/
1818
# oasis generated files
1919
setup.data
2020
setup.log
21+
22+
.DS_store

bin/.merlin

+12
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,30 @@ PKG base
88
PKG base.caml
99
PKG base.shadow_stdlib
1010
PKG bigarray
11+
PKG bin_prot
12+
PKG bin_prot.shape
1113
PKG bytes
1214
PKG cmdliner
15+
PKG fieldslib
16+
PKG ppx_assert.runtime-lib
17+
PKG ppx_bench.runtime-lib
1318
PKG ppx_compare.runtime-lib
19+
PKG ppx_expect.collector
20+
PKG ppx_expect.common
21+
PKG ppx_expect.config
1422
PKG ppx_hash.runtime-lib
23+
PKG ppx_inline_test.config
24+
PKG ppx_inline_test.runtime-lib
1525
PKG re
1626
PKG re.emacs
1727
PKG re.str
1828
PKG result
1929
PKG sexp_pretty
2030
PKG sexplib
2131
PKG sexplib.0
32+
PKG typerep
2233
PKG unix
34+
PKG variantslib
2335
S ../src/cli
2436
S ../src/filesystem
2537
S ../src/jbuilder

src/cli/.merlin

+12
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,30 @@ PKG base
77
PKG base.caml
88
PKG base.shadow_stdlib
99
PKG bigarray
10+
PKG bin_prot
11+
PKG bin_prot.shape
1012
PKG bytes
1113
PKG cmdliner
14+
PKG fieldslib
15+
PKG ppx_assert.runtime-lib
16+
PKG ppx_bench.runtime-lib
1217
PKG ppx_compare.runtime-lib
18+
PKG ppx_expect.collector
19+
PKG ppx_expect.common
20+
PKG ppx_expect.config
1321
PKG ppx_hash.runtime-lib
22+
PKG ppx_inline_test.config
23+
PKG ppx_inline_test.runtime-lib
1424
PKG re
1525
PKG re.emacs
1626
PKG re.str
1727
PKG result
1828
PKG sexp_pretty
1929
PKG sexplib
2030
PKG sexplib.0
31+
PKG typerep
2132
PKG unix
33+
PKG variantslib
2234
S ../filesystem
2335
S ../jbuilder
2436
S ../project

src/filesystem/.merlin

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
B ../../_build/default/src/filesystem
22
FLG -open Ogen_filesystem -w -40
3+
FLG -ppx '/Users/holyshared/Documents/projects/ocaml-gen/_build/default/.ppx/ppx_jane+ppx_driver.runner/ppx.exe --as-ppx --cookie '\''library-name="ogen_filesystem"'\'''
4+
PKG base
5+
PKG base.caml
6+
PKG base.shadow_stdlib
37
PKG bigarray
8+
PKG bin_prot
9+
PKG bin_prot.shape
10+
PKG fieldslib
11+
PKG ppx_assert.runtime-lib
12+
PKG ppx_bench.runtime-lib
13+
PKG ppx_compare.runtime-lib
14+
PKG ppx_expect.collector
15+
PKG ppx_expect.common
16+
PKG ppx_expect.config
17+
PKG ppx_hash.runtime-lib
18+
PKG ppx_inline_test.config
19+
PKG ppx_inline_test.runtime-lib
420
PKG sexplib
521
PKG sexplib.0
22+
PKG typerep
623
PKG unix
24+
PKG variantslib

src/filesystem/file.ml

+10
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ let create ?content ~path =
6565
open_write path
6666
|> bind ~f:(write_string ~s:(to_string content))
6767
|> bind ~f:close
68+
69+
let%test_module _ = (module struct
70+
exception Assert_error of string
71+
let%test_unit "create a new file" =
72+
let temp_dir = Filename.get_temp_dir_name () in
73+
let test_file = temp_dir ^ "/" ^ "test.txt" in
74+
match create ~content:"ok" ~path:test_file with
75+
| Ok f -> assert ((path f) = test_file)
76+
| Error e -> raise (Assert_error (string_of_error e))
77+
end)

src/filesystem/jbuild

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
(library (
44
(public_name ogen.file_system)
55
(name ogen_filesystem)
6+
(library_flags -linkall)
67
(libraries (sexplib))
8+
(preprocess (pps (ppx_jane ppx_driver.runner)))
79
))

src/jbuilder/.merlin

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
B ../../_build/default/src/filesystem
22
B ../../_build/default/src/jbuilder
33
FLG -open Ogen_jbuilder -w -40
4-
FLG -ppx '/Users/holyshared/Documents/projects/ocaml-gen/_build/default/.ppx/ppx_sexp_conv+ppx_type_conv+ppx_driver.runner/ppx.exe --as-ppx --cookie '\''library-name="ogen_jbuilder"'\'''
4+
FLG -ppx '/Users/holyshared/Documents/projects/ocaml-gen/_build/default/.ppx/ppx_jane+ppx_sexp_conv+ppx_type_conv+ppx_driver.runner/ppx.exe --as-ppx --cookie '\''library-name="ogen_jbuilder"'\'''
55
PKG base
66
PKG base.caml
77
PKG base.shadow_stdlib
88
PKG bigarray
9+
PKG bin_prot
10+
PKG bin_prot.shape
911
PKG bytes
12+
PKG fieldslib
13+
PKG ppx_assert.runtime-lib
14+
PKG ppx_bench.runtime-lib
1015
PKG ppx_compare.runtime-lib
16+
PKG ppx_expect.collector
17+
PKG ppx_expect.common
18+
PKG ppx_expect.config
1119
PKG ppx_hash.runtime-lib
20+
PKG ppx_inline_test.config
21+
PKG ppx_inline_test.runtime-lib
1222
PKG re
1323
PKG re.emacs
1424
PKG re.str
1525
PKG sexp_pretty
1626
PKG sexplib
1727
PKG sexplib.0
28+
PKG typerep
1829
PKG unix
30+
PKG variantslib
1931
S ../filesystem

src/jbuilder/jbuild

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
(library (
44
(public_name ogen.jbuilder)
55
(name ogen_jbuilder)
6+
(library_flags -linkall)
67
(libraries (sexplib sexp_pretty ogen.file_system))
7-
(preprocess (pps (ppx_type_conv ppx_sexp_conv ppx_driver.runner)))
8+
(preprocess (pps (ppx_jane ppx_type_conv ppx_sexp_conv ppx_driver.runner)))
89
))

src/jbuilder/library.ml

+15
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,18 @@ let of_sexp = t_of_sexp
3535
let to_string t =
3636
let open Sexp_pretty in
3737
Pretty_print.sexp_to_string (sexp_of_config_format ("library", t))
38+
39+
let%test_module _ = (module struct
40+
let%test_unit "configuration of library" =
41+
let name_by s = create ~name:s ~pub_name:s in
42+
let lib_conf = name_by "test" () in
43+
assert ((name lib_conf) = "test");
44+
assert ((public_name lib_conf) = (Some "test"));
45+
assert ((libraries lib_conf) = None)
46+
47+
let%test_unit "configuration to string" =
48+
let name_by s = create ~name:s ~pub_name:s () in
49+
let expected = "(library (\n (name test)\n (public_name test)))\n" in
50+
let acutual = to_string (name_by "test") in
51+
assert (acutual = expected)
52+
end)

src/project/.merlin

+12
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,27 @@ PKG base
66
PKG base.caml
77
PKG base.shadow_stdlib
88
PKG bigarray
9+
PKG bin_prot
10+
PKG bin_prot.shape
911
PKG bytes
12+
PKG fieldslib
13+
PKG ppx_assert.runtime-lib
14+
PKG ppx_bench.runtime-lib
1015
PKG ppx_compare.runtime-lib
16+
PKG ppx_expect.collector
17+
PKG ppx_expect.common
18+
PKG ppx_expect.config
1119
PKG ppx_hash.runtime-lib
20+
PKG ppx_inline_test.config
21+
PKG ppx_inline_test.runtime-lib
1222
PKG re
1323
PKG re.emacs
1424
PKG re.str
1525
PKG sexp_pretty
1626
PKG sexplib
1727
PKG sexplib.0
28+
PKG typerep
1829
PKG unix
30+
PKG variantslib
1931
S ../filesystem
2032
S ../jbuilder

test/.merlin

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
B ../_build/default/src/cli
2+
B ../_build/default/src/filesystem
3+
B ../_build/default/src/jbuilder
4+
B ../_build/default/src/project
5+
B ../_build/default/test
6+
FLG -w -40 -open Ogen_all -w -40
7+
PKG base
8+
PKG base.caml
9+
PKG base.shadow_stdlib
10+
PKG bigarray
11+
PKG bin_prot
12+
PKG bin_prot.shape
13+
PKG bytes
14+
PKG cmdliner
15+
PKG fieldslib
16+
PKG ppx_assert.runtime-lib
17+
PKG ppx_bench.runtime-lib
18+
PKG ppx_compare.runtime-lib
19+
PKG ppx_expect.collector
20+
PKG ppx_expect.common
21+
PKG ppx_expect.config
22+
PKG ppx_hash.runtime-lib
23+
PKG ppx_inline_test.config
24+
PKG ppx_inline_test.runner.lib
25+
PKG ppx_inline_test.runtime-lib
26+
PKG re
27+
PKG re.emacs
28+
PKG re.str
29+
PKG result
30+
PKG sexp_pretty
31+
PKG sexplib
32+
PKG sexplib.0
33+
PKG typerep
34+
PKG unix
35+
PKG variantslib
36+
S .
37+
S ../src/cli
38+
S ../src/filesystem
39+
S ../src/jbuilder
40+
S ../src/project

test/jbuild

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(library (
2+
(name ogen_all)
3+
(libraries (ogen.cli ogen.file_system ogen.jbuilder ogen.project))
4+
(library_flags -linkall)
5+
(preprocess (pps (ppx_jane ppx_driver.runner)))
6+
))
7+
8+
(executable (
9+
(name test_runner)
10+
(libraries (ppx_inline_test.runner.lib ogen_all))
11+
))
12+
13+
(alias
14+
((name runtest)
15+
(deps (test_runner.exe))
16+
(action (run ${<} inline-test-runner ogen_filesystem -diff-cmd "diff -u --label actual --label expected"))))
17+
18+
(alias
19+
((name runtest)
20+
(deps (test_runner.exe))
21+
(action (run ${<} inline-test-runner ogen_jbuilder -diff-cmd "diff -u --label actual --label expected"))))
22+
23+
(jbuild_version 1)

test/test_runner.ml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Ppx_inline_test_lib.Runtime.exit ()

tests/.merlin

-24
This file was deleted.

tests/file_test.ml

-13
This file was deleted.

tests/jbuild

-11
This file was deleted.

tests/jbuilder_library_test.ml

-21
This file was deleted.

tests/test.ml

-7
This file was deleted.

0 commit comments

Comments
 (0)