Remvoe -skip-platforms from cram.mll

It can be supported via enabled-if now

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-07-31 13:47:46 +02:00
parent 3f2d260be7
commit bd1c57c03a
6 changed files with 49 additions and 74 deletions

View File

@ -1,2 +1,2 @@
(lang dune 1.0)
(lang dune 1.1)
(name dune)

View File

@ -100,17 +100,15 @@ and postprocess tbl b = parse
let () =
let skip_versions = ref [] in
let skip_platforms = ref [] in
let expect_test = ref None in
let args =
(Platform.argv skip_platforms)
:: [ "-skip-versions"
, Arg.String (fun s -> skip_versions := parse_skip_versions s)
, "Comma separated versions of ocaml where to skip test"
; "-test"
, Arg.String (fun s -> expect_test := Some s)
, "expect test file"
] in
[ "-skip-versions"
, Arg.String (fun s -> skip_versions := parse_skip_versions s)
, "Comma separated versions of ocaml where to skip test"
; "-test"
, Arg.String (fun s -> expect_test := Some s)
, "expect test file"
] in
Configurator.main ~args ~name:"cram" (fun configurator ->
let expect_test =
match !expect_test with
@ -123,12 +121,6 @@ and postprocess tbl b = parse
if List.exists !skip_versions ~f:(fun (op, v') ->
test op ocaml_version v') then
exit 0;
let platform =
Configurator.ocaml_config_var_exn configurator "system" in
if List.exists !skip_platforms ~f:(fun p ->
Platform.to_string p = platform
) then
exit 0;
end;
Test_common.run_expect_test expect_test ~f:(fun file_contents lexbuf ->
let items = file lexbuf in

View File

@ -1,20 +1,15 @@
(ignored_subdirs (test-cases))
(library
(name platform)
(modules platform)
(libraries stdune))
(executable
(name cram)
(modules cram)
(libraries test_common platform dune configurator))
(libraries test_common dune configurator))
(ocamllex cram)
(executable
(name gen_tests)
(libraries stdune platform usexp)
(libraries stdune usexp)
(modules gen_tests))
(include dune.inc)

View File

@ -52,9 +52,8 @@
(action
(chdir
test-cases/configurator
(progn
(run %{exe:cram.exe} -skip-platforms win -test run.t)
(diff? run.t run.t.corrected)))))
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected))))
(enabled_if (<> %{ocaml-config:system} win)))
(alias
(name copy_files)
@ -315,9 +314,8 @@
(action
(chdir
test-cases/github764
(progn
(run %{exe:cram.exe} -skip-platforms win -test run.t)
(diff? run.t run.t.corrected)))))
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected))))
(enabled_if (<> %{ocaml-config:system} win)))
(alias
(name github784)
@ -535,15 +533,10 @@
(chdir
test-cases/output-obj
(progn
(run
%{exe:cram.exe}
-skip-versions
<4.06.0
-skip-platforms
macosx,win
-test
run.t)
(diff? run.t run.t.corrected)))))
(run %{exe:cram.exe} -skip-versions <4.06.0 -test run.t)
(diff? run.t run.t.corrected))))
(enabled_if
(and (<> %{ocaml-config:system} macosx) (<> %{ocaml-config:system} win))))
(alias
(name package-dep)

View File

@ -18,14 +18,40 @@ module Sexp = struct
|> Usexp.Ast.remove_locs
end
let alias ?action name ~deps =
module Platform = struct
type t = Win | Mac
open Usexp
let to_string = function
| Win -> "win"
| Mac -> "macosx"
let t t = atom (to_string t)
let system_var = Sexp.parse "%{ocaml-config:system}"
let enabled_if = function
| [] -> None
| [x] -> Some (List [atom "<>"; system_var; t x])
| ps ->
Some (List (
atom "and"
:: List.map ps ~f:(fun p -> List [atom "<>"; system_var; t p])
))
end
let alias ?enabled_if ?action name ~deps =
Sexp.constr "alias"
(Sexp.fields (
[ "name", [Usexp.atom name]
; "deps", deps
] @ (match action with
| None -> []
| Some a -> ["action", [a]])))
| Some a -> ["action", [a]])
@ (match enabled_if with
| None -> []
| Some e -> ["enabled_if", [e]])))
module Test = struct
type t =
@ -56,7 +82,7 @@ module Test = struct
| None -> []
| Some s -> ["-skip-versions"; s]
in
let skip_platforms = Platform.to_cmd t.skip_platforms in
let enabled_if = Platform.enabled_if t.skip_platforms in
let action =
List
[ atom "chdir"
@ -67,9 +93,7 @@ module Test = struct
([ atom "run"
; Sexp.parse "%{exe:cram.exe}" ]
@ (List.map ~f:Usexp.atom_or_quoted_string
(skip_version
@ skip_platforms
@ ["-test"; "run.t"])))
(skip_version @ ["-test"; "run.t"])))
; Sexp.strings ["diff?"; "run.t"; "run.t.corrected"]
]
@ -84,6 +108,7 @@ module Test = struct
; v
; action ] in
alias t.name
?enabled_if
~deps:(
[ Sexp.strings ["package"; "dune"]
; Sexp.strings [ "source_tree"

View File

@ -1,30 +0,0 @@
open Stdune
type t = Win | Mac
let to_string = function
| Win -> "win"
| Mac -> "macosx"
let of_string = function
| "macosx" -> Mac
| "win" -> Win
| s -> invalid_arg ("Platform.of_string: " ^ s)
let arg_name = "-skip-platforms"
let to_cmd = function
| [] -> []
| l ->
[ arg_name
; String.concat ~sep:"," (List.map ~f:to_string l)]
let of_args args =
String.split ~on:',' args
|> List.map ~f:of_string
let argv v =
( arg_name
, Arg.String (fun s -> v := of_args s)
, "Comma separated versions of ocaml where to skip test"
)