From b11185a210d98319e1b16999cac51bf8a3d7fda4 Mon Sep 17 00:00:00 2001 From: Vincent Siles Date: Fri, 5 Apr 2019 02:15:37 -0700 Subject: [PATCH] moving more tests into dune Summary: Adding some new test in the dune build: - autocomplete - color - coverage - dump_inheritance - dumpsymbolinfo - typecheck Reviewed By: CatherineGasnier Differential Revision: D14744874 fbshipit-source-id: 007a5169f38bf27f50dd68ed81a838f509ce41b3 --- hphp/hack/Makefile.dune | 9 +-- hphp/hack/test/autocomplete/dune | 9 +++ hphp/hack/test/color/dune | 19 ++++++ hphp/hack/test/coverage/dune | 9 +++ hphp/hack/test/dump_inheritance/dune | 9 +++ hphp/hack/test/dumpsymbolinfo/dune | 10 ++++ hphp/hack/test/tast/dune | 3 +- hphp/hack/test/typecheck/dune | 110 +++++++++++++++++++++++++++++++++++ 8 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 hphp/hack/test/autocomplete/dune create mode 100644 hphp/hack/test/color/dune create mode 100644 hphp/hack/test/coverage/dune create mode 100644 hphp/hack/test/dump_inheritance/dune create mode 100644 hphp/hack/test/dumpsymbolinfo/dune create mode 100644 hphp/hack/test/typecheck/dune diff --git a/hphp/hack/Makefile.dune b/hphp/hack/Makefile.dune index a2c329aec9a..8822a023d88 100644 --- a/hphp/hack/Makefile.dune +++ b/hphp/hack/Makefile.dune @@ -67,11 +67,4 @@ test: build-hack copy-hack-files do-test: dune runtest - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/autocomplete - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/color - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/colour - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/coverage - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/dumpsymbolinfo - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/dump_inheritance - python3 ./test/verify.py --program ./bin/hh_single_type_check ./test/typecheck - python3 ./test/integration/runner.py ./bin/hh_server ./bin/hh_client + # python3 ./test/integration/runner.py ./bin/hh_server ./bin/hh_client diff --git a/hphp/hack/test/autocomplete/dune b/hphp/hack/test/autocomplete/dune new file mode 100644 index 00000000000..f5dcd72b45d --- /dev/null +++ b/hphp/hack/test/autocomplete/dune @@ -0,0 +1,9 @@ +(alias + (name runtest) + (deps %{exe:../../src/hh_single_type_check.exe} + %{project_root}/test/verify.py + (glob_files %{project_root}/test/autocomplete/HH_FLAGS) + (glob_files %{project_root}/test/autocomplete/*.php) + (glob_files %{project_root}/test/autocomplete/*.exp)) + (action (run %{project_root}/test/verify.py %{project_root}/test/autocomplete + --program %{exe:../../src/hh_single_type_check.exe}))) diff --git a/hphp/hack/test/color/dune b/hphp/hack/test/color/dune new file mode 100644 index 00000000000..bfdf6d49601 --- /dev/null +++ b/hphp/hack/test/color/dune @@ -0,0 +1,19 @@ +(alias + (name runtest) + (deps %{exe:../../src/hh_single_type_check.exe} + %{project_root}/test/verify.py + (glob_files %{project_root}/test/color/*.php) + (glob_files %{project_root}/test/color/*.exp)) + (action (run %{project_root}/test/verify.py %{project_root}/test/color + --program %{exe:../../src/hh_single_type_check.exe} + --flags --color))) + +(alias + (name runtest) + (deps %{exe:../../src/hh_single_type_check.exe} + %{project_root}/test/verify.py + (glob_files %{project_root}/test/color/*.php) + (glob_files %{project_root}/test/color/*.exp)) + (action (run %{project_root}/test/verify.py %{project_root}/test/color + --program %{exe:../../src/hh_single_type_check.exe} + --flags --colour))) diff --git a/hphp/hack/test/coverage/dune b/hphp/hack/test/coverage/dune new file mode 100644 index 00000000000..06adaab8a3b --- /dev/null +++ b/hphp/hack/test/coverage/dune @@ -0,0 +1,9 @@ +(alias + (name runtest) + (deps %{exe:../../src/hh_single_type_check.exe} + %{project_root}/test/verify.py + (glob_files %{project_root}/test/coverage/HH_FLAGS) + (glob_files %{project_root}/test/coverage/*.php) + (glob_files %{project_root}/test/coverage/*.exp)) + (action (run %{project_root}/test/verify.py %{project_root}/test/coverage + --program %{exe:../../src/hh_single_type_check.exe}))) diff --git a/hphp/hack/test/dump_inheritance/dune b/hphp/hack/test/dump_inheritance/dune new file mode 100644 index 00000000000..20965dd5b8e --- /dev/null +++ b/hphp/hack/test/dump_inheritance/dune @@ -0,0 +1,9 @@ +(alias + (name runtest) + (deps %{exe:../../src/hh_single_type_check.exe} + %{project_root}/test/verify.py + (glob_files %{project_root}/test/dump_inheritance/HH_FLAGS) + (glob_files %{project_root}/test/dump_inheritance/*.php) + (glob_files %{project_root}/test/dump_inheritance/*.exp)) + (action (run %{project_root}/test/verify.py %{project_root}/test/dump_inheritance + --program %{exe:../../src/hh_single_type_check.exe}))) diff --git a/hphp/hack/test/dumpsymbolinfo/dune b/hphp/hack/test/dumpsymbolinfo/dune new file mode 100644 index 00000000000..acc168fe26f --- /dev/null +++ b/hphp/hack/test/dumpsymbolinfo/dune @@ -0,0 +1,10 @@ +(alias + (name runtest) + (deps %{exe:../../src/hh_single_type_check.exe} + %{project_root}/test/verify.py + (glob_files %{project_root}/test/dumpsymbolinfo/HH_FLAGS) + (glob_files %{project_root}/test/dumpsymbolinfo/*.php) + (glob_files %{project_root}/test/dumpsymbolinfo/*.exp)) + (action (run %{project_root}/test/verify.py %{project_root}/test/dumpsymbolinfo + --program %{exe:../../src/hh_single_type_check.exe} + --flags --new-inference))) diff --git a/hphp/hack/test/tast/dune b/hphp/hack/test/tast/dune index 6a62077537b..711e8ea31c9 100644 --- a/hphp/hack/test/tast/dune +++ b/hphp/hack/test/tast/dune @@ -12,4 +12,5 @@ (glob_files %{project_root}/test/tast/re_prefixed_string/*.php) (glob_files %{project_root}/test/tast/re_prefixed_string/*.exp)) (action (run %{project_root}/test/verify.py %{project_root}/test/tast - --program %{exe:../../src/hh_single_type_check.exe}))) + --program %{exe:../../src/hh_single_type_check.exe} + --flags --new-inference))) diff --git a/hphp/hack/test/typecheck/dune b/hphp/hack/test/typecheck/dune new file mode 100644 index 00000000000..660e46c8058 --- /dev/null +++ b/hphp/hack/test/typecheck/dune @@ -0,0 +1,110 @@ +(* -*- tuareg -*- *) + +(* dune doesn't support recursive global search so we implement it + ourselves since there are way too many files in test/typecheck +*) +let rec sub_folder f acc abs_path rel_path = + if Sys.file_exists abs_path && Sys.is_directory abs_path then + let acc = f (abs_path, rel_path) acc in + let sub = Sys.readdir abs_path in + Array.fold_left (fun acc name -> + sub_folder f acc (Filename.concat abs_path name) + (Filename.concat rel_path name)) acc sub + else acc + +let generate_sub_folders dir rel_dir = + sub_folder (fun x y -> x :: y) [] dir rel_dir + +let generate_glob file = Printf.sprintf "(glob_files %%{project_root}/%s)" file + +let generate_hh_flags dirs = + let aux acc (abs_dir, rel_dir) = + let absname = Filename.concat abs_dir "HH_FLAGS" in + let name = Filename.concat rel_dir "HH_FLAGS" in + if Sys.file_exists absname then + (generate_glob name) :: acc + else acc in + List.fold_left aux [] dirs + +let generate_patterns dirs pattern acc = + let aux acc (_, dir) = + let name = Filename.concat dir pattern in + (generate_glob name) :: acc in + List.fold_left aux acc dirs + + +let () = + (* we are in test/typecheck *) + let test_dir = Sys.getcwd () in + let subdirs = generate_sub_folders test_dir "test/typecheck" in + let files_hh = generate_hh_flags subdirs in + let files_php = generate_patterns subdirs "*.php" files_hh in + let files_tc = generate_patterns subdirs "*.php-only-typecheck" files_php in + let files_tc = generate_patterns subdirs "*.exp" files_tc in + let files_dc = generate_patterns subdirs "*.decl_exp" files_php in + (* let files_tast = generate_patterns subdirs "*.tast_typecheck_exp" files_php in *) + let command batch flags = Printf.sprintf +" (action (run %%{project_root}/test/verify.py %%{project_root}/test/typecheck + --program %%{exe:../../src/hh_single_type_check.exe} + %s %s))" (if batch then "--batch" else "") flags in + let deps files = + Printf.sprintf +" (deps %%{exe:../../src/hh_single_type_check.exe} + %%{project_root}/test/verify.py + %s)" (String.concat "\n " files) in + (* typecheck and typecheck_old_inference *) + let typecheck_deps = deps files_tc in + let cmds = [ "--flags" + ; "--new-inference" + ; "--error-format raw" + ] in + let cmd = String.concat " " cmds in + let typecheck = + Printf.sprintf "; in %s +(alias + (name runtest) + %s + %s)" test_dir typecheck_deps (command true cmd) in + let cmds = [ "--out-extension .legacy.out" + ; "--expect-extension .legacy.exp" + ; "--fallback-expect-extension .exp" + ; "--fallback-out-extension .out" + ; "--flags" + ; "--error-format raw" + ] in + let cmd = String.concat " " cmds in + let typecheck_old_inference = + Printf.sprintf " + +(alias + (name runtest) + %s + %s)" typecheck_deps (command true cmd) in + (* decl_compare *) + let decl_compare = + Printf.sprintf " + +; when the test succeeds, the output file will be empty, so none of the +; decl_exp files will ever exist for this test +(alias + (name runtest) + %s + %s)" (deps files_dc) + (command true "--out-extension .decl_out --expect-extension .decl_exp --flags --decl-compare") in + (* tast_typecheck is marked as disabled, but it should look like this *) + (* let tast_typecheck = *) + (* let cmds = [ "--out-extension .tast_typecheck_out" *) + (* ; "--expect-extension .tast_typecheck_exp" *) + (* ; "--default-expect-regex" *) + (* ; "\"(No errors|Did not typecheck the TAST as there are typing errors.)\"" *) + (* ; "--flags --tast-check" ] in *) + (* let cmd = String.concat " " cmds in *) + (* Printf.sprintf " *) + +(* (alias *) + (* (name runtest) *) + (* %s *) + (* %s)" (deps files_tast) (command false cmd) in *) + + let dune_file = typecheck ^ typecheck_old_inference ^ decl_compare in + Jbuild_plugin.V1.send dune_file -- 2.11.4.GIT