From c96c11c80da2e0cfd56189853d45ef880b7a4e7f Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Tue, 31 Oct 2023 14:22:19 +0100 Subject: [PATCH] Add smoke tests --- bin/run-tests-in-docker.sh | 2 +- bin/run-tests.sh | 19 ++++++++++--------- .../approve_1/expected_analysis.json | 4 ++++ .../approve_2/expected_analysis.json | 4 ++++ .../expected_analysis.json | 6 ++++++ .../expected_analysis.json | 6 ++++++ .../expected_analysis.json | 6 ++++++ .../expected_analysis.json | 6 ++++++ .../expected_analysis.json | 6 ++++++ 9 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 snippets/reverse-string/approve_1/expected_analysis.json create mode 100644 snippets/reverse-string/approve_2/expected_analysis.json create mode 100644 snippets/reverse-string/approve_with_suggest_bonus_1/expected_analysis.json create mode 100644 snippets/reverse-string/approve_with_suggest_bonus_2/expected_analysis.json create mode 100644 snippets/reverse-string/approve_with_suggest_removing_extern_crate_1/expected_analysis.json create mode 100644 snippets/reverse-string/approve_with_suggest_removing_extern_crate_2/expected_analysis.json create mode 100644 snippets/reverse-string/disapprove_with_solution_not_found/expected_analysis.json diff --git a/bin/run-tests-in-docker.sh b/bin/run-tests-in-docker.sh index 97b4f8f..90594d7 100755 --- a/bin/run-tests-in-docker.sh +++ b/bin/run-tests-in-docker.sh @@ -23,7 +23,7 @@ docker run \ --rm \ --network none \ --read-only \ - --mount type=bind,src="${PWD}/tests",dst=/opt/analyzer/tests \ + --mount type=bind,src="${PWD}/snippets",dst=/opt/analyzer/snippets \ --mount type=tmpfs,dst=/tmp \ --volume "${PWD}/bin/run-tests.sh:/opt/analyzer/bin/run-tests.sh" \ --workdir /opt/analyzer \ diff --git a/bin/run-tests.sh b/bin/run-tests.sh index d4bbf19..5736fc3 100755 --- a/bin/run-tests.sh +++ b/bin/run-tests.sh @@ -14,20 +14,21 @@ exit_code=0 # Iterate over all test directories -for test_dir in tests/*; do +for analysis_file in $(find snippets -name expected_analysis.json); do + test_dir=$(dirname "${analysis_file}") test_dir_name=$(basename "${test_dir}") test_dir_path=$(realpath "${test_dir}") + slug=$(echo $test_dir | awk -F '/' '{ print $2 }') - bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}" + bin/run.sh "${slug}" "${test_dir_path}" "${test_dir_path}" - for file in analysis.json tags.json; do - expected_file="expected_${file}" - echo "${test_dir_name}: comparing ${file} to ${expected_file}" + file="analysis.json" + expected_file="expected_${file}" + echo "${test_dir_name}: comparing ${file} to ${expected_file}" - if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then - exit_code=1 - fi - done + if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then + exit_code=1 + fi done exit ${exit_code} diff --git a/snippets/reverse-string/approve_1/expected_analysis.json b/snippets/reverse-string/approve_1/expected_analysis.json new file mode 100644 index 0000000..1717f15 --- /dev/null +++ b/snippets/reverse-string/approve_1/expected_analysis.json @@ -0,0 +1,4 @@ +{ + "status": "approve", + "comments": [] +} \ No newline at end of file diff --git a/snippets/reverse-string/approve_2/expected_analysis.json b/snippets/reverse-string/approve_2/expected_analysis.json new file mode 100644 index 0000000..1717f15 --- /dev/null +++ b/snippets/reverse-string/approve_2/expected_analysis.json @@ -0,0 +1,4 @@ +{ + "status": "approve", + "comments": [] +} \ No newline at end of file diff --git a/snippets/reverse-string/approve_with_suggest_bonus_1/expected_analysis.json b/snippets/reverse-string/approve_with_suggest_bonus_1/expected_analysis.json new file mode 100644 index 0000000..258a17c --- /dev/null +++ b/snippets/reverse-string/approve_with_suggest_bonus_1/expected_analysis.json @@ -0,0 +1,6 @@ +{ + "status": "approve", + "comments": [ + "rust.reverse-string.suggest_doing_bonus_test" + ] +} \ No newline at end of file diff --git a/snippets/reverse-string/approve_with_suggest_bonus_2/expected_analysis.json b/snippets/reverse-string/approve_with_suggest_bonus_2/expected_analysis.json new file mode 100644 index 0000000..258a17c --- /dev/null +++ b/snippets/reverse-string/approve_with_suggest_bonus_2/expected_analysis.json @@ -0,0 +1,6 @@ +{ + "status": "approve", + "comments": [ + "rust.reverse-string.suggest_doing_bonus_test" + ] +} \ No newline at end of file diff --git a/snippets/reverse-string/approve_with_suggest_removing_extern_crate_1/expected_analysis.json b/snippets/reverse-string/approve_with_suggest_removing_extern_crate_1/expected_analysis.json new file mode 100644 index 0000000..d668c32 --- /dev/null +++ b/snippets/reverse-string/approve_with_suggest_removing_extern_crate_1/expected_analysis.json @@ -0,0 +1,6 @@ +{ + "status": "approve", + "comments": [ + "rust.reverse-string.suggest_removing_extern_crate" + ] +} \ No newline at end of file diff --git a/snippets/reverse-string/approve_with_suggest_removing_extern_crate_2/expected_analysis.json b/snippets/reverse-string/approve_with_suggest_removing_extern_crate_2/expected_analysis.json new file mode 100644 index 0000000..d668c32 --- /dev/null +++ b/snippets/reverse-string/approve_with_suggest_removing_extern_crate_2/expected_analysis.json @@ -0,0 +1,6 @@ +{ + "status": "approve", + "comments": [ + "rust.reverse-string.suggest_removing_extern_crate" + ] +} \ No newline at end of file diff --git a/snippets/reverse-string/disapprove_with_solution_not_found/expected_analysis.json b/snippets/reverse-string/disapprove_with_solution_not_found/expected_analysis.json new file mode 100644 index 0000000..c7c974f --- /dev/null +++ b/snippets/reverse-string/disapprove_with_solution_not_found/expected_analysis.json @@ -0,0 +1,6 @@ +{ + "status": "disapprove", + "comments": [ + "rust.reverse-string.solution_function_not_found" + ] +} \ No newline at end of file