Merge pull request #945 from rgrinberg/fallback-dune

Disable fallback in dune files
This commit is contained in:
Rudi Grinberg 2018-07-03 16:24:27 +07:00 committed by GitHub
commit e77367eb2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 5 deletions

View File

@ -1129,7 +1129,9 @@ module Rule = struct
field "deps" (list Dep_conf.t) ~default:[] >>= fun deps ->
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
map_validate
(field_b "fallback" >>= fun fallback ->
(field_b
~check:(Syntax.renamed_in Stanza.syntax (1, 0) ~to_:"(mode fallback)")
"fallback" >>= fun fallback ->
field_o "mode" Mode.t >>= fun mode ->
return (fallback, mode))
~f:(function

View File

@ -481,9 +481,10 @@ module Of_sexp = struct
| None ->
(None, add_known name state)
let field_b name =
let field_b ?check name =
field name ~default:false
(eos >>= function
(Option.value check ~default:(return ()) >>= fun () ->
eos >>= function
| true -> return true
| _ -> bool)

View File

@ -216,7 +216,7 @@ module Of_sexp : sig
-> 'a t
-> 'a option fields_parser
val field_b : string -> bool fields_parser
val field_b : ?check:(unit t) -> string -> bool fields_parser
(** A field that can appear multiple times *)
val multi_field

View File

@ -124,7 +124,7 @@ let renamed_in t ver ~to_ =
else begin
desc () >>= fun (loc, what) ->
Loc.fail loc
"%s was renamed to '%s' in %s of %s" what to_
"%s was renamed to '%s' in the %s version of %s" what to_
(Version.to_string ver) t.desc
end

View File

@ -128,6 +128,14 @@
test-cases/exec-cmd
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name fallback-dune)
(deps (package dune) (source_tree test-cases/fallback-dune))
(action
(chdir
test-cases/fallback-dune
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name findlib)
(deps (package dune) (source_tree test-cases/findlib))
@ -606,6 +614,7 @@
(alias env)
(alias exclude-missing-module)
(alias exec-cmd)
(alias fallback-dune)
(alias findlib)
(alias findlib-error)
(alias force-test)
@ -678,6 +687,7 @@
(alias env)
(alias exclude-missing-module)
(alias exec-cmd)
(alias fallback-dune)
(alias findlib)
(alias findlib-error)
(alias force-test)

View File

@ -0,0 +1,4 @@
(rule
(fallback)
(targets)
(action (with-stdout-to foo.txt (echo "testing"))))

View File

@ -0,0 +1,4 @@
(rule
(fallback false)
(targets)
(action (with-stdout-to foo.txt (echo "testing"))))

View File

@ -0,0 +1,5 @@
(rule
((fallback)
(targets (foo.txt))
(action (with-stdout-to foo.txt (echo "testing")))))

View File

@ -0,0 +1,20 @@
fallback isn't allowed in dune
$ dune build --root dune1
Info: creating file dune-project with this contents: (lang dune 1.0)
File "dune", line 2, characters 1-11:
Error: 'fallback' was renamed to '(mode fallback)' in the 1.0 version of the dune language
[1]
2nd fallback form isn't allowed either
$ dune build --root dune2
Info: creating file dune-project with this contents: (lang dune 1.0)
File "dune", line 2, characters 1-17:
Error: 'fallback' was renamed to '(mode fallback)' in the 1.0 version of the dune language
[1]
But it is allowed in jbuilder
$ jbuilder build --root jbuild
Entering directory 'jbuild'