diff --git a/TEST.sh b/TEST.sh index d882d070e..f6c48f115 100755 --- a/TEST.sh +++ b/TEST.sh @@ -7,6 +7,7 @@ shopt -s nullglob # Option flags. declare FORCE_COLOR_OUTPUT="" +declare RUN_CASE_STUDIES="true" declare RUN_EXAMPLES_TESTS="true" declare RUN_COMPILER_TESTS="true" declare RUN_INTERACTIVE_MODE_TESTS="true" @@ -28,6 +29,7 @@ declare -r REPLAY=${REPLAY:-"${BUILDPATH}/replay"} declare -r TESTROOTDIR=${TESTROOTDIR:-"./t"} declare -r TESTDIR=${TESTDIR:-"${TESTROOTDIR}/code"} +declare -r STUDYDIR=${STUDYDIR:-"./case-studies"} declare -r EXAMPLEDIR=${EXAMPLEDIR:-"./examples"} declare -r INTERACTIVE_TESTDIR=${INTERACTIVE_TESTDIR:-"${TESTROOTDIR}/interactive"} declare -r HARPOON_TESTDIR=${HARPOON_TESTDIR:-"${TESTROOTDIR}/harpoon"} @@ -37,6 +39,7 @@ declare -i TIMEOUT=${TIMEOUT:-10} function rsync_test_artifacts { rsync -ak "${ROOTDIR}/.admissible-fail" "${TEMPDIR}/.admissible-fail" rsync -ak --chmod=Fa+w "${ROOTDIR}/${TESTROOTDIR}/" "${TEMPDIR}/${TESTROOTDIR}" + rsync -ak "${ROOTDIR}/${STUDYDIR}/" "${TEMPDIR}/${STUDYDIR}" rsync -ak "${ROOTDIR}/${EXAMPLEDIR}/" "${TEMPDIR}/${EXAMPLEDIR}" } @@ -123,6 +126,16 @@ function do_testing { # Limit runtime of each test case, in seconds. ulimit -t "${TIMEOUT}" + if [[ -n "${RUN_CASE_STUDIES}" ]]; then + echo "===== CASE STUDIES =====" + + while read -r file_path; do + start_test_case "${file_path}" + + check_example_test_case "${file_path}" + done <<< "$(find_compiler_tests_in "${STUDYDIR}" | sort -n)" + fi + if [[ -n "${RUN_EXAMPLES_TESTS}" ]]; then echo "===== EXAMPLES =====" diff --git a/case-studies/.gitkeep b/case-studies/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/test/dune b/test/dune index 623618178..c1b9f9c0a 100644 --- a/test/dune +++ b/test/dune @@ -6,4 +6,5 @@ test_parser/fixtures/disambiguation_state.json (glob_files test_parser/fixtures/*.input.bel) (glob_files test_parser/fixtures/*.output.json) - (glob_files_rec ../examples/*))) + (glob_files_rec ../examples/*) + (glob_files_rec ../case-studies/*))) diff --git a/test/test_parser/test_html_pp.ml b/test/test_parser/test_html_pp.ml index eb05619c4..496f97fc0 100644 --- a/test/test_parser/test_html_pp.ml +++ b/test/test_parser/test_html_pp.ml @@ -28,10 +28,13 @@ let make_html_test ?(save_html_to_file = false) compiler_test_file = ignore (Format.asprintf "%a@." Beluga_html.pp_signature signature : string) +let case_studies_directory = "../case-studies" + let examples_directory = "../examples" let tests () = let compiler_tests = - Files.find_compiler_tests ~directory:examples_directory + Files.find_compiler_tests ~directory:case_studies_directory + @ Files.find_compiler_tests ~directory:examples_directory in List.map make_html_test compiler_tests diff --git a/test/test_parser/test_pp.ml b/test/test_parser/test_pp.ml index 1c9e9361a..8e5eb870a 100644 --- a/test/test_parser/test_pp.ml +++ b/test/test_parser/test_pp.ml @@ -120,10 +120,13 @@ let make_compiler_test ?(save_json_to_file = false) Fun.(json_of_signature >> without_locations) ~expected:signature ~actual:signature' +let case_studies_directory = "../case-studies" + let examples_directory = "../examples" let tests () = let compiler_tests = - Files.find_compiler_tests ~directory:examples_directory + Files.find_compiler_tests ~directory:case_studies_directory + @ Files.find_compiler_tests ~directory:examples_directory in List.map make_compiler_test compiler_tests