Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #31

Merged
merged 9 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2.1.2 [???]
* Fix named section position [#31 @rjbou]

2.1.1 [17 Nov 2020]
* New types with more complete positions [#24 @rjbou]
* Deprecation of all old functions [#24 @rjbou]
* Add tests [#28 @rjbou]

2.1.0 [26 Aug 2020]
* Don't add a newline at the start of strings with newlines [#18 @dra27]
* Report starting position of strings correctly [#19 @rjbou]
Expand Down
26 changes: 17 additions & 9 deletions opam-file-format.opam
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
opam-version: "2.0"
version: "2.1.1"
version: "2.1.2"
synopsis: "Parser and printer for the opam file syntax"
maintainer: "Louis Gesbert <louis.gesbert@ocamlpro.com>"
authors: "Louis Gesbert <louis.gesbert@ocamlpro.com>"
homepage: "https://opam.ocaml.org"
bug-reports: "/~https://github.com/ocaml/opam-file-format/issues"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
dev-repo: "git+/~https://github.com/ocaml/opam-file-format"
build: [
[make "byte" {!ocaml-native} "all" {ocaml-native}] {!dune:installed}
["dune" "build" "-p" name "-j" jobs "@install" "@doc" {with-doc}] {dune:installed}
["dune" "runtest" "-p" name "-j" jobs] {with-test & dune:installed}
]
depopts: "dune" { > "1.11.4" }
install: [make "install" "PREFIX=%{prefix}%"] {!dune:installed}
synopsis: "Parser and printer for the opam file syntax"
depends: [
"ocaml"
"alcotest" {with-test}
]
depopts: "dune" { > "2.0.0" }
build: [
[ make
"byte" {!ocaml:native}
"all" {ocaml:native} ]
{!dune:installed | dune:version <= "2.0.0"}
[ "dune" "build" "-p" name "-j" jobs "@install"
"@doc" {with-doc} ]
{dune:installed & dune:version > "2.0.0"}
[ "dune" "runtest" "-p" name "-j" jobs ]
{with-test & dune:installed & dune:version > "2.0.0"}
]
install:
[ make "install" "PREFIX=%{prefix}%" ]
{!dune:installed | dune:version <= "2.0.0"}
3 changes: 3 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

(ocamlyacc opamBaseParser)
(ocamllex opamLexer)

(env (dev
(flags (:standard -warn-error -A))))
2 changes: 1 addition & 1 deletion src/opamBaseParser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ item:
Section ({section_kind = { pos = get_pos 1; pelem = $1 };
section_name = Some { pos = get_pos 2; pelem = $2 };
section_items =
{ pos = get_pos_full ~s:2 4; pelem = $4 };
{ pos = get_pos_full ~s:3 5; pelem = $4 };
})
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(test
(name tests)
(deps sample.opam)
(package opam-file-format)
(libraries alcotest opam-file-format))
13 changes: 11 additions & 2 deletions tests/fullpos.ml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ module Opamfile = struct
in
A.testable opamfile_fmt opamfile_equals

let ofile_pos_testable =
let opamfile_fmt : opamfile Fmt.t = fun ppf f ->
Format.fprintf ppf "%s" (OpamPrinter.FullPos.opamfile f)
in
let opamfile_equals o1 o2 =
o1.file_contents = o2.file_contents
in
A.testable opamfile_fmt opamfile_equals

let test_printer t () =
List.iter (fun (name, str, ofile) ->
A.check A.string name str (print_ofile ofile))
Expand Down Expand Up @@ -470,7 +479,7 @@ module Opamfile = struct
Some { pos = spos (4, 8) (4, 15);
pelem = "thing" };
section_items =
{ pos = spos (4, 8) (5, 29);
{ pos = spos (4, 16) (6, 1);
pelem =
[{ pos = spos (5, 2) (5, 29);
pelem =
Expand All @@ -485,7 +494,7 @@ module Opamfile = struct
];
in
let content = {file_contents; file_name = filename} in
A.check ofile_testable "sample" content (OpamParser.FullPos.file filename)
A.check ofile_pos_testable "sample" content (OpamParser.FullPos.file filename)

let tests =
[
Expand Down